Compare commits
1801 Commits
@0x/sol-co
...
protocol@3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3bebc7cd62 | ||
|
|
56dab6ae8c | ||
|
|
285f98e9e9 | ||
|
|
8ae9f59f20 | ||
|
|
4c341c5ca3 | ||
|
|
a3c912c2af | ||
|
|
5e72eb9af9 | ||
|
|
9b08b73c06 | ||
|
|
76c7eb7c3e | ||
|
|
9b2e5a3adb | ||
|
|
813d703d12 | ||
|
|
83005d0f3d | ||
|
|
d07ffd2688 | ||
|
|
4170f970d0 | ||
|
|
dcde12dd70 | ||
|
|
84a60ec982 | ||
|
|
9615570dc6 | ||
|
|
880a9c3da0 | ||
|
|
c44bd9d42d | ||
|
|
90b441330b | ||
|
|
e12ed1eddf | ||
|
|
ac94023ab3 | ||
|
|
281e6acca5 | ||
|
|
2f1b520409 | ||
|
|
21b4eb3d26 | ||
|
|
644f6c7d28 | ||
|
|
0647b9e4f8 | ||
|
|
82d42eeede | ||
|
|
6ef4d95043 | ||
|
|
6044140f86 | ||
|
|
4da1ef0f56 | ||
|
|
8c668a3918 | ||
|
|
f1ff1cde39 | ||
|
|
1668a24e31 | ||
|
|
4b7c376d96 | ||
|
|
bb4a9c656c | ||
|
|
6ab07b6304 | ||
|
|
8903f1ab01 | ||
|
|
415535612a | ||
|
|
5248a135c3 | ||
|
|
602290925c | ||
|
|
01813746e8 | ||
|
|
7d668d8801 | ||
|
|
797a00a33a | ||
|
|
4b3d98f43c | ||
|
|
9ff77c1cd5 | ||
|
|
18a8351671 | ||
|
|
9a994dfcd3 | ||
|
|
b7adc5a889 | ||
|
|
10b0d7f363 | ||
|
|
e2c905a15f | ||
|
|
8589ba728c | ||
|
|
43512fd07a | ||
|
|
c090608d99 | ||
|
|
89817428ed | ||
|
|
fce3664258 | ||
|
|
aa522fe49b | ||
|
|
c03653ebd7 | ||
|
|
ae08f77381 | ||
|
|
73a07e512d | ||
|
|
7cff09f40a | ||
|
|
a6d690f10a | ||
|
|
d7cff52e75 | ||
|
|
cf1f29a37d | ||
|
|
9af22110b4 | ||
|
|
2c187c7e85 | ||
|
|
d46756ae2e | ||
|
|
d9a16ed1f9 | ||
|
|
57a1120997 | ||
|
|
0945d4cef2 | ||
|
|
8f6f7ad453 | ||
|
|
bb4fad37fa | ||
|
|
d06daf2957 | ||
|
|
34314960ef | ||
|
|
832ba737ec | ||
|
|
6950fdbebb | ||
|
|
1849b1bb9a | ||
|
|
a883139220 | ||
|
|
bb2c26cb94 | ||
|
|
ba09a0b2bf | ||
|
|
b2d54f0238 | ||
|
|
4a3096495b | ||
|
|
23f6e9e53c | ||
|
|
d7dbc0576d | ||
|
|
15fb00e958 | ||
|
|
1d9295cc94 | ||
|
|
79f36cf6fb | ||
|
|
6ce4458a5d | ||
|
|
fad6e65c07 | ||
|
|
840c85373e | ||
|
|
0479bb5fe1 | ||
|
|
9ecc31ed54 | ||
|
|
eb29abd36c | ||
|
|
d202e01522 | ||
|
|
e838a6801b | ||
|
|
7439871aa0 | ||
|
|
317f2138c5 | ||
|
|
e5834f1901 | ||
|
|
5063446f93 | ||
|
|
0caf495a1a | ||
|
|
a20de0fc69 | ||
|
|
9aa0065d2d | ||
|
|
c24855e627 | ||
|
|
6bb72dd775 | ||
|
|
77d1ed257c | ||
|
|
5d265360c4 | ||
|
|
c9097f6e8b | ||
|
|
d3df985a42 | ||
|
|
7267420874 | ||
|
|
17e81432f1 | ||
|
|
57c767c3b1 | ||
|
|
dbb1c88ad9 | ||
|
|
254b850a8b | ||
|
|
e2242e5955 | ||
|
|
7a0255fee7 | ||
|
|
ec6522cfbf | ||
|
|
1bf96e91bb | ||
|
|
eb733cc58f | ||
|
|
d9fdcf813b | ||
|
|
88bd1c9cea | ||
|
|
9e759e82b4 | ||
|
|
da433854ac | ||
|
|
ed3524e0d7 | ||
|
|
20e23bf3f6 | ||
|
|
be4f85690e | ||
|
|
e061dfa59b | ||
|
|
cb4f42dfea | ||
|
|
9727f0cebe | ||
|
|
68656b4a4d | ||
|
|
aae46bef84 | ||
|
|
a0bb36954e | ||
|
|
4f32f3174f | ||
|
|
b84107d142 | ||
|
|
b46eeadc64 | ||
|
|
692231c2ea | ||
|
|
3a1becc3e4 | ||
|
|
3653e2d7f9 | ||
|
|
65def38d98 | ||
|
|
859c36cb10 | ||
|
|
3e34386812 | ||
|
|
a35af11981 | ||
|
|
59eabec71e | ||
|
|
bf4c7e7d50 | ||
|
|
fd098ca4df | ||
|
|
c360f8d8fd | ||
|
|
b358559421 | ||
|
|
df5aad8e8e | ||
|
|
8dbf79db59 | ||
|
|
1839608e84 | ||
|
|
6e3e795b8b | ||
|
|
d9c410a7e3 | ||
|
|
609727afe8 | ||
|
|
8a5c74c0b4 | ||
|
|
cd93f3b07e | ||
|
|
8397b12de6 | ||
|
|
3f85acec3a | ||
|
|
d6a9e3d600 | ||
|
|
361569ac2f | ||
|
|
719664c145 | ||
|
|
f800d6c24c | ||
|
|
a9a81bcafb | ||
|
|
4280307a15 | ||
|
|
7b57d3ae51 | ||
|
|
8a8a5bbda0 | ||
|
|
76987c8db1 | ||
|
|
6f8971cc42 | ||
|
|
71ab882143 | ||
|
|
5a4961c8d9 | ||
|
|
4c4fb99d87 | ||
|
|
872abf09e9 | ||
|
|
f10bfe7d04 | ||
|
|
a74d8deff3 | ||
|
|
835ee4e8de | ||
|
|
63ec42303f | ||
|
|
f789aebddc | ||
|
|
efd83be779 | ||
|
|
603bc1d51c | ||
|
|
32a930a7fc | ||
|
|
f464bf68d7 | ||
|
|
ebdc4fb509 | ||
|
|
7580719586 | ||
|
|
aba9db2be7 | ||
|
|
a6680411c8 | ||
|
|
0d0e87de94 | ||
|
|
ccf2000c09 | ||
|
|
3eb2e0f56a | ||
|
|
d07c7d5b69 | ||
|
|
adf6684c29 | ||
|
|
9bf889aa30 | ||
|
|
e81c88564e | ||
|
|
901d400d62 | ||
|
|
289474e2ce | ||
|
|
407ca21168 | ||
|
|
5c68fc24d2 | ||
|
|
548800e0a9 | ||
|
|
bde3d6dc6a | ||
|
|
56550a6acc | ||
|
|
e51b83accc | ||
|
|
d5ae971f1c | ||
|
|
5a2f5f9a42 | ||
|
|
75a3b70cef | ||
|
|
803cf65ba1 | ||
|
|
5d3947b838 | ||
|
|
4397a59008 | ||
|
|
966d54c935 | ||
|
|
234ddb495d | ||
|
|
a744acc7bc | ||
|
|
27c624633c | ||
|
|
7ef75101b4 | ||
|
|
6f8aace00d | ||
|
|
6c264b2f18 | ||
|
|
df055e1958 | ||
|
|
70d2117470 | ||
|
|
2c173ccaf3 | ||
|
|
d2f4a0c5f3 | ||
|
|
0d6021e5e3 | ||
|
|
bb04726e7f | ||
|
|
220ca370c2 | ||
|
|
63af4e3e98 | ||
|
|
9754e12d82 | ||
|
|
d72ebed246 | ||
|
|
587fc71058 | ||
|
|
7d34e09a12 | ||
|
|
7d15baad0f | ||
|
|
1e6476ada7 | ||
|
|
1d6ca5f6b5 | ||
|
|
fb249f02fc | ||
|
|
fdf04ef275 | ||
|
|
b0f5f634f2 | ||
|
|
6ee0108565 | ||
|
|
c73097e688 | ||
|
|
a2d42b07b5 | ||
|
|
f9a794af93 | ||
|
|
a2643674ca | ||
|
|
c00ce9daac | ||
|
|
c68b5d7844 | ||
|
|
09ed106d4c | ||
|
|
a6b92fc658 | ||
|
|
4be4a1a30b | ||
|
|
9bede5d331 | ||
|
|
b50d4aee6d | ||
|
|
55bc367bd6 | ||
|
|
7a59b7eafe | ||
|
|
9e59d41e44 | ||
|
|
475e6c7bca | ||
|
|
dbc5a5293e | ||
|
|
f4bd2bd0d8 | ||
|
|
f1782a83ba | ||
|
|
cbade0d558 | ||
|
|
fe0c26387c | ||
|
|
c03a014740 | ||
|
|
84e6d788aa | ||
|
|
cd296b8767 | ||
|
|
5946d32a7d | ||
|
|
842dd8572b | ||
|
|
33e260f9db | ||
|
|
c44f8d0060 | ||
|
|
411548a33e | ||
|
|
9a17ce1383 | ||
|
|
2b120d0669 | ||
|
|
6d877d5242 | ||
|
|
e4abd690e7 | ||
|
|
2a194384b6 | ||
|
|
1e069e6f8a | ||
|
|
a019bb913d | ||
|
|
9ce73931f7 | ||
|
|
97020df178 | ||
|
|
dfb7b3de8f | ||
|
|
9e152912fe | ||
|
|
b2c2f1e1aa | ||
|
|
629c7d8e92 | ||
|
|
62f24d4356 | ||
|
|
ae281c33ca | ||
|
|
5d034dd106 | ||
|
|
c1f8df0eca | ||
|
|
76dda9eeda | ||
|
|
a9b84a92ac | ||
|
|
0f7e881899 | ||
|
|
6045f777ab | ||
|
|
5a15044ead | ||
|
|
a69d76e487 | ||
|
|
3adfcdffa8 | ||
|
|
164a5d44d9 | ||
|
|
70ddab0231 | ||
|
|
7bf009fbf6 | ||
|
|
525bc8197b | ||
|
|
24397c51a8 | ||
|
|
06b3464756 | ||
|
|
bbaa90bd9a | ||
|
|
5c683cbc0f | ||
|
|
95345f18bc | ||
|
|
4c3fbe83ac | ||
|
|
7caa43d02c | ||
|
|
3d4c03c9df | ||
|
|
22e1ed35d3 | ||
|
|
dabe6fd793 | ||
|
|
3cc639c8d0 | ||
|
|
22c8e0b6db | ||
|
|
f3ca4293bc | ||
|
|
db3e076d03 | ||
|
|
1a6759820a | ||
|
|
61c5e7b948 | ||
|
|
5fd78ef32f | ||
|
|
14ff9b827c | ||
|
|
598dc2cd71 | ||
|
|
08e1c5109f | ||
|
|
6f7a843742 | ||
|
|
c9c9615bb5 | ||
|
|
f98609686d | ||
|
|
5b8bbc34e8 | ||
|
|
49cb00a9ab | ||
|
|
74b240fb88 | ||
|
|
514f9d2621 | ||
|
|
fa78d1092a | ||
|
|
297342092b | ||
|
|
076f263a86 | ||
|
|
0c56207abc | ||
|
|
23953d8a5a | ||
|
|
c6919eb25a | ||
|
|
d509604b52 | ||
|
|
a74a3450eb | ||
|
|
72c5399b9d | ||
|
|
b29196b983 | ||
|
|
ce76a7033d | ||
|
|
3f4bb933d1 | ||
|
|
501b7b9b65 | ||
|
|
c0ea88e864 | ||
|
|
48f8bea460 | ||
|
|
f4e5b6e38d | ||
|
|
477cb0a48d | ||
|
|
d6bc0a3368 | ||
|
|
e544a804c2 | ||
|
|
96e0ad7899 | ||
|
|
5a1fee5d31 | ||
|
|
3557a5e5a9 | ||
|
|
0bd43d5265 | ||
|
|
8fd7c1b386 | ||
|
|
50068750f5 | ||
|
|
a7a905de4c | ||
|
|
f283108586 | ||
|
|
9afe05095a | ||
|
|
3dab892978 | ||
|
|
e40ddb800e | ||
|
|
72a74e7c66 | ||
|
|
e8ae64673f | ||
|
|
2451f419c8 | ||
|
|
2394eb62aa | ||
|
|
f9078bb1c3 | ||
|
|
bf25c81f1c | ||
|
|
03ecc530c3 | ||
|
|
d52b1d24d0 | ||
|
|
5083fab06a | ||
|
|
1249bf9ccc | ||
|
|
681f6b3f07 | ||
|
|
d3ca1fe96b | ||
|
|
9e4f5815e4 | ||
|
|
c3c27eaedc | ||
|
|
4bf6a23d23 | ||
|
|
aaaf0d02de | ||
|
|
825cc4d035 | ||
|
|
c2d44e5c10 | ||
|
|
0efd0860c8 | ||
|
|
a890a06664 | ||
|
|
5befb87071 | ||
|
|
12ba4c373a | ||
|
|
7fd25be02e | ||
|
|
aa688c4a92 | ||
|
|
fb437551c9 | ||
|
|
6fa1de7889 | ||
|
|
7a42df9a65 | ||
|
|
15a508f3ea | ||
|
|
b3c20ff909 | ||
|
|
682c07cb73 | ||
|
|
602605ab4b | ||
|
|
0eff2548d5 | ||
|
|
93ee681204 | ||
|
|
d7bea98075 | ||
|
|
437a3b048d | ||
|
|
f55a9454b5 | ||
|
|
3b03ad0db4 | ||
|
|
27d679e1f1 | ||
|
|
1e16d59c23 | ||
|
|
1e7c9bbb1f | ||
|
|
edda1edc50 | ||
|
|
d1eb6279b4 | ||
|
|
4ace79d947 | ||
|
|
e5eee96487 | ||
|
|
907adf9145 | ||
|
|
c046fe6220 | ||
|
|
84bf20de41 | ||
|
|
f5a6f74d9a | ||
|
|
7c7fc51ccf | ||
|
|
fa22f6de0d | ||
|
|
4f41214af2 | ||
|
|
607b7169bc | ||
|
|
1253490a38 | ||
|
|
0a37a588e8 | ||
|
|
23ee108089 | ||
|
|
64feeeea75 | ||
|
|
2ebef23b8c | ||
|
|
cc9f43ba3b | ||
|
|
5f1c139176 | ||
|
|
9eea7de340 | ||
|
|
4480f84efa | ||
|
|
5a8b8afff1 | ||
|
|
67c95bc0b7 | ||
|
|
e70ec02be8 | ||
|
|
db81a94adb | ||
|
|
475b608338 | ||
|
|
27e36b112e | ||
|
|
f698721484 | ||
|
|
0c08353b2c | ||
|
|
a074b49732 | ||
|
|
43b75c7953 | ||
|
|
84a78eafc4 | ||
|
|
3c1ab889dd | ||
|
|
012fff46f6 | ||
|
|
6307ebc3a2 | ||
|
|
88d7e73eba | ||
|
|
9653eb9e70 | ||
|
|
ad337271d3 | ||
|
|
7591e99316 | ||
|
|
ca20df4752 | ||
|
|
841e4ee666 | ||
|
|
e2ee3414ea | ||
|
|
5306cc03e9 | ||
|
|
85f5d32de2 | ||
|
|
ab698cec14 | ||
|
|
b463a39bfa | ||
|
|
018e25345b | ||
|
|
b60fa8a7d7 | ||
|
|
048d8dee60 | ||
|
|
927fe2b58b | ||
|
|
89948b360c | ||
|
|
561b60a24d | ||
|
|
4f82543bdf | ||
|
|
3133c509f9 | ||
|
|
426c15692d | ||
|
|
8c87a77faa | ||
|
|
d2018f07a2 | ||
|
|
d2e57d8163 | ||
|
|
7403c0255a | ||
|
|
75dcd687e2 | ||
|
|
afd4805421 | ||
|
|
6aa582d140 | ||
|
|
534d92fa00 | ||
|
|
37aae134ab | ||
|
|
36bd8f68c9 | ||
|
|
c3ad42221e | ||
|
|
602ac1f626 | ||
|
|
3126795efe | ||
|
|
dbcb221a59 | ||
|
|
6bbc179f52 | ||
|
|
48e7a391c8 | ||
|
|
2334e64d0c | ||
|
|
14f920ee84 | ||
|
|
e10a81023a | ||
|
|
f4709ed1cb | ||
|
|
e2e14a977a | ||
|
|
866f958a10 | ||
|
|
717db99b38 | ||
|
|
02006118c7 | ||
|
|
9816019bc5 | ||
|
|
9c821dbfc3 | ||
|
|
af1b890423 | ||
|
|
673835d2de | ||
|
|
500b57e935 | ||
|
|
3f7d0580c1 | ||
|
|
a71c356bba | ||
|
|
c3a95b7fb1 | ||
|
|
f01540fb35 | ||
|
|
689a8881c2 | ||
|
|
99f5be8378 | ||
|
|
8de0282d92 | ||
|
|
f99804d56a | ||
|
|
f13d27b749 | ||
|
|
465fd59cbc | ||
|
|
5fdabe6612 | ||
|
|
861871134b | ||
|
|
c246d98093 | ||
|
|
02076dba1b | ||
|
|
7b136a5ad8 | ||
|
|
0c4a67fa35 | ||
|
|
668aeb77f7 | ||
|
|
135ae392d5 | ||
|
|
88ba04307c | ||
|
|
e4b8000a48 | ||
|
|
b9df108314 | ||
|
|
6106185bf6 | ||
|
|
3a3e289864 | ||
|
|
6558632f10 | ||
|
|
376ee6bdff | ||
|
|
fc5d759131 | ||
|
|
7c16bb3df8 | ||
|
|
5df74d35d0 | ||
|
|
72fc0c845a | ||
|
|
b995715a2c | ||
|
|
857b5c97b0 | ||
|
|
178d9c280a | ||
|
|
2416deba25 | ||
|
|
0ce6243653 | ||
|
|
40dc10729b | ||
|
|
0571244e9e | ||
|
|
3213131cad | ||
|
|
61bf93aac2 | ||
|
|
a9d0cec6d1 | ||
|
|
b5e3f0b90c | ||
|
|
61f1fe42b0 | ||
|
|
1cfdc49021 | ||
|
|
c4d58277cf | ||
|
|
9ac66c2130 | ||
|
|
6366163006 | ||
|
|
85fde8f9a5 | ||
|
|
a03d0800b0 | ||
|
|
9cb21006a7 | ||
|
|
649202f1c4 | ||
|
|
b798556774 | ||
|
|
03bc15fbdf | ||
|
|
b2dfd8740c | ||
|
|
3182c12b4d | ||
|
|
f783625d60 | ||
|
|
891aa8e8bf | ||
|
|
4b508d255d | ||
|
|
1cad43bf5d | ||
|
|
a0cd727832 | ||
|
|
ab90e15015 | ||
|
|
52cbddf054 | ||
|
|
db98ff8cb7 | ||
|
|
1d8dd2f89c | ||
|
|
0ae1c926d3 | ||
|
|
1fcab58e2f | ||
|
|
a8cbd1a16c | ||
|
|
3aaa0ad6b2 | ||
|
|
e34bc77157 | ||
|
|
088b331f19 | ||
|
|
56f2dec441 | ||
|
|
ac8b08d3cf | ||
|
|
c4ead689a9 | ||
|
|
07ab10b000 | ||
|
|
c969a8652a | ||
|
|
fb21ca5404 | ||
|
|
bbfa9c34ab | ||
|
|
7161bbe836 | ||
|
|
ef65aa5bf6 | ||
|
|
2cf31f05a1 | ||
|
|
2b1a1ba0db | ||
|
|
05b25c6229 | ||
|
|
2db52c6983 | ||
|
|
4803e2f68c | ||
|
|
7030572f1d | ||
|
|
6e2eb9c5bb | ||
|
|
eb27e260e0 | ||
|
|
c72aa653e8 | ||
|
|
4d04b72674 | ||
|
|
e3b92d2c8b | ||
|
|
4aa5a89cd7 | ||
|
|
c6b9ea5723 | ||
|
|
2dc0bff1ea | ||
|
|
408e66e8b4 | ||
|
|
40fe12a86b | ||
|
|
1adb56f092 | ||
|
|
629d48c766 | ||
|
|
c8886febb9 | ||
|
|
efe598c8fd | ||
|
|
32218ce25e | ||
|
|
f7ae697475 | ||
|
|
6e954385ce | ||
|
|
f8df89b506 | ||
|
|
a3ff406461 | ||
|
|
221de054f4 | ||
|
|
98e6aa4bac | ||
|
|
199808dc44 | ||
|
|
5d8e35fb68 | ||
|
|
36546480b1 | ||
|
|
cd9e408ea3 | ||
|
|
7698f21517 | ||
|
|
10724e5745 | ||
|
|
dde76a4dbb | ||
|
|
86ff5c53bb | ||
|
|
efef5f122f | ||
|
|
83c942ad8c | ||
|
|
31e90e314c | ||
|
|
33caae705e | ||
|
|
961273a2ff | ||
|
|
46e512a27c | ||
|
|
290a04a0ad | ||
|
|
12ff4ec438 | ||
|
|
1c15ecacb0 | ||
|
|
c6d738ed0c | ||
|
|
f089f5d87f | ||
|
|
78e3cd39d1 | ||
|
|
1588c1f362 | ||
|
|
a35d1b8a9d | ||
|
|
32923ec7e1 | ||
|
|
5a3bd716ad | ||
|
|
84862f15c1 | ||
|
|
9e42dce5c4 | ||
|
|
a360109013 | ||
|
|
68d6b3a033 | ||
|
|
733c3046bc | ||
|
|
23d4b6bf1c | ||
|
|
39bd0c5459 | ||
|
|
c13ffb2072 | ||
|
|
38bcab1f86 | ||
|
|
a24f01c90f | ||
|
|
708e34602b | ||
|
|
d60c8ddd5a | ||
|
|
eea63292f0 | ||
|
|
a97342a594 | ||
|
|
00f55be83e | ||
|
|
90ed283b20 | ||
|
|
61272961a8 | ||
|
|
507690f9db | ||
|
|
90ad5eb6c4 | ||
|
|
7bc9701c81 | ||
|
|
a7d502a501 | ||
|
|
fbe99b41f8 | ||
|
|
66e2d93e9c | ||
|
|
4672c72fef | ||
|
|
ac6b03cd4a | ||
|
|
d7de191947 | ||
|
|
de7f1fc207 | ||
|
|
99de5a3814 | ||
|
|
4cf566cad8 | ||
|
|
6138955f93 | ||
|
|
a57cf68ee4 | ||
|
|
20edcd1ae5 | ||
|
|
5333befd89 | ||
|
|
235e406620 | ||
|
|
5f570b772d | ||
|
|
f2507cb94a | ||
|
|
f84b375cde | ||
|
|
32d11d1ba5 | ||
|
|
5c9b6eb078 | ||
|
|
f53a512e70 | ||
|
|
ec08715090 | ||
|
|
79e0a9ef37 | ||
|
|
1ce8a33937 | ||
|
|
b3053dfb91 | ||
|
|
3da05f2812 | ||
|
|
0ba79b060d | ||
|
|
c4bcc26e29 | ||
|
|
630108ccb6 | ||
|
|
1ab33aa132 | ||
|
|
ee456ea6e7 | ||
|
|
e7541ac2af | ||
|
|
d34d46b7fd | ||
|
|
08ae43aad3 | ||
|
|
eb141075c7 | ||
|
|
bd3387a408 | ||
|
|
e1a48e80e1 | ||
|
|
bf899d40a0 | ||
|
|
dc66f1b886 | ||
|
|
3753b1a7d0 | ||
|
|
05c5acdb15 | ||
|
|
ca63bcc9b0 | ||
|
|
3733d503db | ||
|
|
ab28e42c22 | ||
|
|
7e53b4f834 | ||
|
|
3bb60fee19 | ||
|
|
9f7840e12b | ||
|
|
f41e13b574 | ||
|
|
4049143630 | ||
|
|
705f46717f | ||
|
|
a6cf8ae0b6 | ||
|
|
dba6972281 | ||
|
|
52d36f5a8b | ||
|
|
889b58a914 | ||
|
|
43810835d7 | ||
|
|
4b9867f167 | ||
|
|
e9c91e59bd | ||
|
|
d8844f6970 | ||
|
|
1cdc6e7184 | ||
|
|
36ad373f03 | ||
|
|
78dfb6d525 | ||
|
|
79254de7bc | ||
|
|
1d6aef5cd6 | ||
|
|
f9d02c9e27 | ||
|
|
228246089e | ||
|
|
b6319ba3d8 | ||
|
|
2636384ead | ||
|
|
0425f76284 | ||
|
|
d93e72f56a | ||
|
|
195d543ce3 | ||
|
|
9cda9f69cd | ||
|
|
7b0a1c3630 | ||
|
|
a8f3a47240 | ||
|
|
db0f3a8780 | ||
|
|
514db24ceb | ||
|
|
e738743c89 | ||
|
|
f471e1a8a3 | ||
|
|
a2f0d5eedf | ||
|
|
2f9b894d71 | ||
|
|
bab34c2d21 | ||
|
|
a68421b0f8 | ||
|
|
e9b0ac8820 | ||
|
|
4f78f55c2a | ||
|
|
156093127b | ||
|
|
47d91bb4e0 | ||
|
|
cc31445189 | ||
|
|
af78238507 | ||
|
|
b30f87f50c | ||
|
|
3cd03ed0f1 | ||
|
|
e7ad7c3af7 | ||
|
|
7e8b56eef4 | ||
|
|
458a014e6d | ||
|
|
9b6703398e | ||
|
|
71700e69af | ||
|
|
14d6330b40 | ||
|
|
d31d646ecc | ||
|
|
270d7a3f19 | ||
|
|
e078f3d479 | ||
|
|
6aa8f17ed5 | ||
|
|
8e73ae3614 | ||
|
|
89117beda2 | ||
|
|
e27e6baabe | ||
|
|
15ce90c0ec | ||
|
|
39e157499d | ||
|
|
d22c0641fb | ||
|
|
82806b6fcb | ||
|
|
fe293d91ee | ||
|
|
7842bb4cad | ||
|
|
6f7e156f49 | ||
|
|
0d19cac487 | ||
|
|
f30dfcc572 | ||
|
|
3df39d8cfe | ||
|
|
ece93fed78 | ||
|
|
3a2c6ae9d6 | ||
|
|
2ed71b36b6 | ||
|
|
ae9c301795 | ||
|
|
68206ffb6e | ||
|
|
25a3c18bfe | ||
|
|
d28476e9f7 | ||
|
|
7cd30610f9 | ||
|
|
ceb90989d0 | ||
|
|
bb39d63d37 | ||
|
|
213709d020 | ||
|
|
d0e9081852 | ||
|
|
71cde281b9 | ||
|
|
c03f1586e6 | ||
|
|
10aceb164d | ||
|
|
34f516a417 | ||
|
|
5dd686f22f | ||
|
|
5f47ad3363 | ||
|
|
e166e9762a | ||
|
|
341c5782e5 | ||
|
|
d5180d3ebc | ||
|
|
2c73bbd689 | ||
|
|
b10522479c | ||
|
|
2b39ae4800 | ||
|
|
788bdba8cd | ||
|
|
222fd5d822 | ||
|
|
eedfc64a8c | ||
|
|
78170b26e9 | ||
|
|
f966b6f4df | ||
|
|
053b55fbbf | ||
|
|
84a55a2d84 | ||
|
|
498a50b229 | ||
|
|
766888ec41 | ||
|
|
466d962c07 | ||
|
|
ae2a6fb685 | ||
|
|
5afe2616a4 | ||
|
|
72c869649a | ||
|
|
34138fc3b5 | ||
|
|
f67d2b96ac | ||
|
|
d877d3686c | ||
|
|
8260615b4e | ||
|
|
c3f6d48966 | ||
|
|
02f979bc74 | ||
|
|
de1c71aacc | ||
|
|
ca2aa72e0f | ||
|
|
9a16f5736e | ||
|
|
82774df715 | ||
|
|
314f53c0b3 | ||
|
|
6553ee0130 | ||
|
|
d7918ea047 | ||
|
|
4aa9c85503 | ||
|
|
f172591059 | ||
|
|
dfa7e30e42 | ||
|
|
3fe2013398 | ||
|
|
391d501ce6 | ||
|
|
9edaa3a64e | ||
|
|
6e4e313792 | ||
|
|
e6dcf92ec8 | ||
|
|
f359de2cac | ||
|
|
2d29014091 | ||
|
|
0450e430f1 | ||
|
|
b6700af6a8 | ||
|
|
bcee7546ae | ||
|
|
4dac620156 | ||
|
|
74d9df2fb0 | ||
|
|
9d1615fa23 | ||
|
|
b1b9949e72 | ||
|
|
957ef5ab77 | ||
|
|
07a681c77e | ||
|
|
145ec8ede1 | ||
|
|
5f5a158060 | ||
|
|
3e99c95791 | ||
|
|
4f83521be8 | ||
|
|
aae93bb6a7 | ||
|
|
b5eb1c9ee8 | ||
|
|
9d3755db36 | ||
|
|
762e0aec2d | ||
|
|
ff9c9241d8 | ||
|
|
5c1ffe7fc8 | ||
|
|
b1c3c60def | ||
|
|
8763713596 | ||
|
|
3e823cc9e3 | ||
|
|
1c84709db3 | ||
|
|
9150d6bd2a | ||
|
|
10f29b66b8 | ||
|
|
259aec52a9 | ||
|
|
6554bf9f08 | ||
|
|
d8558f5956 | ||
|
|
18bc701e8b | ||
|
|
a47795fd3f | ||
|
|
a55e8b268c | ||
|
|
e8106f04b5 | ||
|
|
bdc1dbf08a | ||
|
|
06eeb2088b | ||
|
|
7da9ec2c75 | ||
|
|
297ff10c14 | ||
|
|
1305f4314d | ||
|
|
55474c0599 | ||
|
|
687c79ae81 | ||
|
|
829a353b14 | ||
|
|
aced474dc5 | ||
|
|
7c08d5f198 | ||
|
|
c546787994 | ||
|
|
31fa530845 | ||
|
|
120714ecfc | ||
|
|
615874d2ec | ||
|
|
67b195c942 | ||
|
|
75689cee96 | ||
|
|
8ba77e95a4 | ||
|
|
7967a8416c | ||
|
|
934fbca860 | ||
|
|
e78c8038c7 | ||
|
|
f64a42ebb5 | ||
|
|
9164cff234 | ||
|
|
017f98e87e | ||
|
|
f33d8670aa | ||
|
|
e79db7de89 | ||
|
|
845a42e73a | ||
|
|
e58c25aa18 | ||
|
|
8ec44b63b1 | ||
|
|
41907936a1 | ||
|
|
406d2cefc5 | ||
|
|
41cdbc0ec4 | ||
|
|
c6ec261c5c | ||
|
|
a2db1a3275 | ||
|
|
1e8f2f0e83 | ||
|
|
8491abe142 | ||
|
|
d4302538bf | ||
|
|
c34e3765ef | ||
|
|
1f86bc06ef | ||
|
|
7e892fac2d | ||
|
|
23789b0692 | ||
|
|
89adbe4127 | ||
|
|
11940fb98e | ||
|
|
13ae335811 | ||
|
|
b2dc6ad2fa | ||
|
|
85ca926fd0 | ||
|
|
676698a59b | ||
|
|
22408ecd58 | ||
|
|
d36acc7ec7 | ||
|
|
a5a68acfec | ||
|
|
7431651666 | ||
|
|
4f91bfd907 | ||
|
|
8d2086870b | ||
|
|
1511ef1a98 | ||
|
|
4e030ce1e8 | ||
|
|
2507ad274b | ||
|
|
fb1c149eb9 | ||
|
|
d4662f428a | ||
|
|
73c779c13a | ||
|
|
b8cc164af1 | ||
|
|
64a391b5f8 | ||
|
|
21a202dd16 | ||
|
|
187dd2fdc3 | ||
|
|
c18f3f0b33 | ||
|
|
7162935028 | ||
|
|
9215a73b6c | ||
|
|
edd840794c | ||
|
|
c30a6eb1aa | ||
|
|
233642af29 | ||
|
|
7dffd0a03e | ||
|
|
f7bc3ff49d | ||
|
|
53aabe3cdb | ||
|
|
09b8d7cfc9 | ||
|
|
1512afc7e6 | ||
|
|
dde0c76112 | ||
|
|
f14b6f2ba2 | ||
|
|
4fced276c4 | ||
|
|
7590471d62 | ||
|
|
0b6bcf6739 | ||
|
|
3a5ce86ed9 | ||
|
|
7b298939e2 | ||
|
|
f1f6aa7d80 | ||
|
|
7ce7dd7252 | ||
|
|
01aa556ede | ||
|
|
48ad39c1c7 | ||
|
|
9cab034448 | ||
|
|
0d7a22634c | ||
|
|
3e3bc5c06d | ||
|
|
2a81e468c7 | ||
|
|
0ba67a363e | ||
|
|
deae846864 | ||
|
|
3a0d48ad77 | ||
|
|
81d4803b4d | ||
|
|
e936c7c507 | ||
|
|
ad868af96e | ||
|
|
cd14a45414 | ||
|
|
f7cd7110ea | ||
|
|
44262bf747 | ||
|
|
0fbbabe208 | ||
|
|
b39189fde3 | ||
|
|
18fc1d78f4 | ||
|
|
d44a91d10b | ||
|
|
5e9829b2d8 | ||
|
|
2176deae36 | ||
|
|
7c5035aa39 | ||
|
|
5707993995 | ||
|
|
f81697527c | ||
|
|
967eff4c58 | ||
|
|
d5d07dd34e | ||
|
|
b91cc3781d | ||
|
|
87ed0071c4 | ||
|
|
0fed48630c | ||
|
|
7b3e7c98ac | ||
|
|
09f44b0375 | ||
|
|
ebfa62637e | ||
|
|
cb2cc05cac | ||
|
|
f9c9131d81 | ||
|
|
1be9a1cbc7 | ||
|
|
b7fda8ecf0 | ||
|
|
db16392821 | ||
|
|
7127f541c3 | ||
|
|
32793cc008 | ||
|
|
fbaf55cb25 | ||
|
|
b8d51fc4e8 | ||
|
|
0c6e05d220 | ||
|
|
4066c17a0f | ||
|
|
429f2bb8dd | ||
|
|
112f4fc4f0 | ||
|
|
ecfbd6280f | ||
|
|
bf84409839 | ||
|
|
a7ce72cae0 | ||
|
|
28402ff7d8 | ||
|
|
e1d213d1a3 | ||
|
|
c610dd96f5 | ||
|
|
2ba3818b65 | ||
|
|
0e1a5a375a | ||
|
|
cfc3daeb65 | ||
|
|
6359f1950e | ||
|
|
d2f581853d | ||
|
|
030cb285da | ||
|
|
af45409959 | ||
|
|
d9a9bc35e3 | ||
|
|
c911c3352c | ||
|
|
654abbac25 | ||
|
|
46d5f42c9d | ||
|
|
1509da1215 | ||
|
|
98a99d96aa | ||
|
|
d62d81af17 | ||
|
|
dba67eb927 | ||
|
|
548c30d6a0 | ||
|
|
1b8b9186a8 | ||
|
|
a8cfcfb371 | ||
|
|
f7a414bc29 | ||
|
|
e05cd1d66b | ||
|
|
511cd90c44 | ||
|
|
8fb2d8da88 | ||
|
|
2fce332ed7 | ||
|
|
b23f1eb145 | ||
|
|
f694072b5a | ||
|
|
10de266e0f | ||
|
|
71811ed04f | ||
|
|
e9638ef95e | ||
|
|
5226bb5596 | ||
|
|
b9984b6df4 | ||
|
|
9c11835fee | ||
|
|
d9e13d6b99 | ||
|
|
dede076835 | ||
|
|
c929782e0d | ||
|
|
a43c7e36f8 | ||
|
|
b95cec9c32 | ||
|
|
9a7d9abe3c | ||
|
|
c77b620453 | ||
|
|
b348084e2a | ||
|
|
ff1811ef90 | ||
|
|
39cf4a7576 | ||
|
|
21b67625a6 | ||
|
|
fb0311e675 | ||
|
|
8a14b4afff | ||
|
|
e42701599a | ||
|
|
352b1b43f2 | ||
|
|
2922ebd095 | ||
|
|
a9e72085dd | ||
|
|
ed3d194c90 | ||
|
|
125c53827b | ||
|
|
38781807cd | ||
|
|
c046943269 | ||
|
|
fe36cd86bb | ||
|
|
401410089c | ||
|
|
fa23337519 | ||
|
|
ae5421f76e | ||
|
|
a2e2b429d5 | ||
|
|
ac852b23b3 | ||
|
|
e12389a002 | ||
|
|
da18e42d2a | ||
|
|
93bdaba8ee | ||
|
|
4cb08a61d5 | ||
|
|
133692ca92 | ||
|
|
4bcc4b3cf8 | ||
|
|
4eb20ca4b6 | ||
|
|
69f7343be5 | ||
|
|
19b28a58d6 | ||
|
|
3c33a93b9c | ||
|
|
f2e16dfb21 | ||
|
|
0f689e8051 | ||
|
|
5b44e6ef64 | ||
|
|
49e4ade66f | ||
|
|
3bae27d039 | ||
|
|
a77f0c606d | ||
|
|
f1de64dcaf | ||
|
|
feb672c3cd | ||
|
|
a90b463a7d | ||
|
|
5f5f25c978 | ||
|
|
351ea8bc1c | ||
|
|
b34edcbf87 | ||
|
|
160519e1fe | ||
|
|
44d626e12e | ||
|
|
efb9dc51c9 | ||
|
|
deb51434fd | ||
|
|
501070bfb0 | ||
|
|
712958d8c8 | ||
|
|
4d8d944fe5 | ||
|
|
0042e42160 | ||
|
|
85509ea251 | ||
|
|
6063854d06 | ||
|
|
456f8a90b1 | ||
|
|
980246d07a | ||
|
|
141c30b173 | ||
|
|
22f9b03fce | ||
|
|
be2db504b9 | ||
|
|
cac6f5234f | ||
|
|
eb6b32b6ee | ||
|
|
07acc9529e | ||
|
|
f7f0152573 | ||
|
|
153533f1d5 | ||
|
|
11622c586a | ||
|
|
7396bb508a | ||
|
|
7df6530f3a | ||
|
|
80787456fa | ||
|
|
4446ac1ca3 | ||
|
|
220039ab00 | ||
|
|
12f2250ab5 | ||
|
|
0c33aa16a1 | ||
|
|
72908b02fe | ||
|
|
223aa04424 | ||
|
|
e53248cca6 | ||
|
|
c11d661b39 | ||
|
|
4212a08337 | ||
|
|
c0553fa9eb | ||
|
|
7f26fafed7 | ||
|
|
3e9309c003 | ||
|
|
1017707475 | ||
|
|
e8ff5da209 | ||
|
|
03ed3ac1b0 | ||
|
|
2c97208e74 | ||
|
|
a458e81f8d | ||
|
|
83289bc801 | ||
|
|
ba2ac6a7b5 | ||
|
|
245b6da577 | ||
|
|
8875f924b0 | ||
|
|
ad7868ebe1 | ||
|
|
5effc6ec90 | ||
|
|
4cc9ceabd2 | ||
|
|
464c918134 | ||
|
|
2456adcb68 | ||
|
|
45bc967f30 | ||
|
|
d6d4d29257 | ||
|
|
33fdfdc8c0 | ||
|
|
80c8712b2a | ||
|
|
957e3eb93c | ||
|
|
110e1afa8e | ||
|
|
1da8f68871 | ||
|
|
513ddb4cca | ||
|
|
3bdfcb8542 | ||
|
|
aee758eca2 | ||
|
|
47ef7fffce | ||
|
|
58d6256607 | ||
|
|
b854fcdb72 | ||
|
|
27ca75d94f | ||
|
|
bb15f78af0 | ||
|
|
ccc9e18132 | ||
|
|
d55108ab60 | ||
|
|
84adbcb683 | ||
|
|
0cb5e4553b | ||
|
|
264407b707 | ||
|
|
eb5ec58453 | ||
|
|
39c2a757be | ||
|
|
8cdc05f582 | ||
|
|
5f4778c852 | ||
|
|
70add44fc1 | ||
|
|
fa617d2e9d | ||
|
|
3c795d365d | ||
|
|
93872ad7a3 | ||
|
|
227676c150 | ||
|
|
5f23833b43 | ||
|
|
121d51b414 | ||
|
|
0e196a59d9 | ||
|
|
63bfd23310 | ||
|
|
aadcf8fed0 | ||
|
|
37390e03b4 | ||
|
|
98fc780ade | ||
|
|
1670b21123 | ||
|
|
5602aacbd2 | ||
|
|
6ddbea207f | ||
|
|
261bced822 | ||
|
|
a80d1f861c | ||
|
|
c541340ef5 | ||
|
|
434af0ae64 | ||
|
|
c6379ca1d4 | ||
|
|
cdbcada49b | ||
|
|
282930cb9b | ||
|
|
b09c751942 | ||
|
|
b2047b90b3 | ||
|
|
0c8aec30bd | ||
|
|
fafaa3e69b | ||
|
|
d19bb3de8d | ||
|
|
481136166c | ||
|
|
4df81a0b9e | ||
|
|
da1e9c2d97 | ||
|
|
4b5a02c246 | ||
|
|
0e1572cfd7 | ||
|
|
343caa1ff6 | ||
|
|
403fb3826d | ||
|
|
3cdccb7b4e | ||
|
|
d9be78cdb4 | ||
|
|
16dc8255e1 | ||
|
|
2086bfff25 | ||
|
|
b9a68c0b8e | ||
|
|
74647f0e88 | ||
|
|
6e29c8bea9 | ||
|
|
b36373ab81 | ||
|
|
dc437aacf1 | ||
|
|
e19dae9b28 | ||
|
|
424cbd4831 | ||
|
|
350feed993 | ||
|
|
7ca4aa0ff4 | ||
|
|
bf00e67245 | ||
|
|
c5a6e49681 | ||
|
|
a509af2875 | ||
|
|
1f789bf396 | ||
|
|
0ccbc7d3d2 | ||
|
|
f3c6f26f85 | ||
|
|
338c358df2 | ||
|
|
4bdaa48303 | ||
|
|
36267746da | ||
|
|
7775541eed | ||
|
|
5029be4c83 | ||
|
|
277dbacf68 | ||
|
|
0fdfb03f3c | ||
|
|
17d81bf014 | ||
|
|
568e9be07e | ||
|
|
99b0a95f8a | ||
|
|
0fdd31892a | ||
|
|
7a682604f9 | ||
|
|
ce96e35d7d | ||
|
|
b7fb5394a7 | ||
|
|
aaa62beca7 | ||
|
|
2b58a7242b | ||
|
|
5ed919df79 | ||
|
|
baf6372179 | ||
|
|
1a9063a55b | ||
|
|
87999f402f | ||
|
|
109d466260 | ||
|
|
37597eca75 | ||
|
|
5fd767b739 | ||
|
|
0e7a473116 | ||
|
|
05bf55dca8 | ||
|
|
cc12ad8d86 | ||
|
|
847a7f470c | ||
|
|
95bebd6d1d | ||
|
|
8179a964ea | ||
|
|
d0805d4bbb | ||
|
|
f901c401b7 | ||
|
|
6ccadcb928 | ||
|
|
58b6c25d5c | ||
|
|
9cbab26202 | ||
|
|
74bcb468ca | ||
|
|
07a6ba88f4 | ||
|
|
49dff49993 | ||
|
|
68207aac80 | ||
|
|
64652b2ff0 | ||
|
|
659e8991de | ||
|
|
9f495b6dc9 | ||
|
|
d8498134ad | ||
|
|
17b2320b0d | ||
|
|
36c457f483 | ||
|
|
b8ec7f5e26 | ||
|
|
dbc5c0d5d8 | ||
|
|
fa886aa849 | ||
|
|
32e1ae2b18 | ||
|
|
61f03b0ea2 | ||
|
|
c47825a820 | ||
|
|
2d7cb63c7b | ||
|
|
c3d4c13936 | ||
|
|
3f51b9322f | ||
|
|
b604e2bd4e | ||
|
|
bcd92473d1 | ||
|
|
6f5bf9d146 | ||
|
|
490094939f | ||
|
|
d0d7d2772f | ||
|
|
59091896b4 | ||
|
|
3eb1429a25 | ||
|
|
bc7504c469 | ||
|
|
99dc4b8e07 | ||
|
|
807904bb86 | ||
|
|
7b8c8348f4 | ||
|
|
9c5ac26170 | ||
|
|
5db065644c | ||
|
|
0cc3a99169 | ||
|
|
2b1545145b | ||
|
|
49b7c9c8a4 | ||
|
|
114119f7c8 | ||
|
|
b4ef866c10 | ||
|
|
15f75a08d5 | ||
|
|
29f9c5473d | ||
|
|
ea1528aea6 | ||
|
|
18ce19a84d | ||
|
|
b0fd78d68d | ||
|
|
8186d6277e | ||
|
|
599af2b1a9 | ||
|
|
82de5adbe9 | ||
|
|
82b0f85258 | ||
|
|
cded58c30d | ||
|
|
da17b49b81 | ||
|
|
4728cdfa7c | ||
|
|
d97b30dcee | ||
|
|
fa8e8ad52d | ||
|
|
7495ac8111 | ||
|
|
08619e2c06 | ||
|
|
5d4bbd5b37 | ||
|
|
9d2aef5006 | ||
|
|
bcc3e5ebb0 | ||
|
|
e5df51a83a | ||
|
|
97fb843f01 | ||
|
|
8afb044877 | ||
|
|
7f869868c9 | ||
|
|
31275228ac | ||
|
|
7181be8768 | ||
|
|
3b446e887a | ||
|
|
431196c391 | ||
|
|
9608d8fb46 | ||
|
|
d574ca1628 | ||
|
|
8be60e2ff5 | ||
|
|
3c0fd540b1 | ||
|
|
23a7dc9a8a | ||
|
|
f97e6892b6 | ||
|
|
7742901e5c | ||
|
|
de68cb25d0 | ||
|
|
77d7afe505 | ||
|
|
68fb6c2c27 | ||
|
|
a47c031ad1 | ||
|
|
817049456c | ||
|
|
e1a061789f | ||
|
|
28573ba772 | ||
|
|
880b9413f6 | ||
|
|
9a7c4b21a9 | ||
|
|
ac56038eca | ||
|
|
4dd2fb6903 | ||
|
|
0baec61f06 | ||
|
|
d4751788d1 | ||
|
|
ae68c061d1 | ||
|
|
b0387245f0 | ||
|
|
c2d06a4a23 | ||
|
|
270108abb7 | ||
|
|
e76c33232d | ||
|
|
58ff2dc492 | ||
|
|
13c45a0e96 | ||
|
|
90cb86911a | ||
|
|
be7b1a1bd4 | ||
|
|
132a3c6705 | ||
|
|
5e73257557 | ||
|
|
e83346fbbb | ||
|
|
2dd47a2103 | ||
|
|
f31e530b6e | ||
|
|
eb50f3fa9c | ||
|
|
8417fe4fdb | ||
|
|
0f1c15a6ca | ||
|
|
9345c4fb7f | ||
|
|
5e0758917b | ||
|
|
f56839ec6b | ||
|
|
cbb23a42e2 | ||
|
|
5a59c286d0 | ||
|
|
2e8c600d7a | ||
|
|
e851cb1cbc | ||
|
|
3da03da32a | ||
|
|
3ec8924e7f | ||
|
|
a04722b612 | ||
|
|
f9a7857a90 | ||
|
|
58f772c74e | ||
|
|
a425c7e260 | ||
|
|
809885afd0 | ||
|
|
bf9b4b993f | ||
|
|
d94a26f0f4 | ||
|
|
bd9c9cedca | ||
|
|
651e94bd94 | ||
|
|
162b6f1a74 | ||
|
|
865a253eb5 | ||
|
|
9b3781abf1 | ||
|
|
d89243a0d3 | ||
|
|
b4cefc64b4 | ||
|
|
2fd26587e5 | ||
|
|
282a351859 | ||
|
|
a84b848ea9 | ||
|
|
d329320fc2 | ||
|
|
bc096554b5 | ||
|
|
5902d878d8 | ||
|
|
4a133ca36f | ||
|
|
f7252f919a | ||
|
|
e05a03a842 | ||
|
|
dcce8276b8 | ||
|
|
fd47947e55 | ||
|
|
ae151df2eb | ||
|
|
79de188683 | ||
|
|
6e5c788e13 | ||
|
|
f53606007d | ||
|
|
a4ac418bc9 | ||
|
|
a8c09d0bdb | ||
|
|
871105a48a | ||
|
|
3b61129ade | ||
|
|
f471c79b59 | ||
|
|
dfd9443f74 | ||
|
|
a36ff9e365 | ||
|
|
12e65bbf26 | ||
|
|
ab9841e60b | ||
|
|
7a52f12e57 | ||
|
|
11fd4506ac | ||
|
|
0c9c68030e | ||
|
|
55d6eddbb2 | ||
|
|
8341e60edb | ||
|
|
6273a1ca73 | ||
|
|
1b83ebdf89 | ||
|
|
fef7f0506f | ||
|
|
f44eb4e383 | ||
|
|
05df485c4a | ||
|
|
44857c526b | ||
|
|
b8ad5d5d32 | ||
|
|
e3e0d00e21 | ||
|
|
a9b1ea9690 | ||
|
|
8e5dd0f8d9 | ||
|
|
3b0c8f6d92 | ||
|
|
21058c2227 | ||
|
|
f3b8ae0781 | ||
|
|
d590b004c1 | ||
|
|
02e21141c6 | ||
|
|
f839a3087d | ||
|
|
f458815541 | ||
|
|
7ba754d2a4 | ||
|
|
09706e4ae2 | ||
|
|
d18de4c541 | ||
|
|
001c7bfdbc | ||
|
|
d4e04dc712 | ||
|
|
8650cb5217 | ||
|
|
0eaaddeb95 | ||
|
|
1cf8663f20 | ||
|
|
5130259552 | ||
|
|
ba5e19a015 | ||
|
|
c0400fa986 | ||
|
|
51179d10ce | ||
|
|
78752f9178 | ||
|
|
762db417d7 | ||
|
|
85bdccbc06 | ||
|
|
9f8cb99340 | ||
|
|
87b90bb04b | ||
|
|
e961d88277 | ||
|
|
5754c11e34 | ||
|
|
7bd88c1bb8 | ||
|
|
445b686c6c | ||
|
|
0cb7b75214 | ||
|
|
a08399dfee | ||
|
|
4016808fa4 | ||
|
|
8635849977 | ||
|
|
1a9ed4d4fe | ||
|
|
e7b3246dd0 | ||
|
|
19589aec57 | ||
|
|
4d33ff0417 | ||
|
|
93a5ab5b33 | ||
|
|
59ada06cdf | ||
|
|
ae650849b0 | ||
|
|
3e8f9a6b53 | ||
|
|
79362b0dba | ||
|
|
3e3df06d57 | ||
|
|
6b220eb1c5 | ||
|
|
a1c61cae11 | ||
|
|
d48a917bf3 | ||
|
|
646b6dafb2 | ||
|
|
8d10f33a3f | ||
|
|
5d603b2f80 | ||
|
|
0e1b08ff54 | ||
|
|
befc22d718 | ||
|
|
4a62e80967 | ||
|
|
ee9ef9f2c1 | ||
|
|
93dcb68437 | ||
|
|
0691cc7909 | ||
|
|
d82f34fe59 | ||
|
|
d2313b30af | ||
|
|
329719472a | ||
|
|
a2fcab47d4 | ||
|
|
4ab5951c25 | ||
|
|
403cabb201 | ||
|
|
3da7c5d3e2 | ||
|
|
c5e0de51aa | ||
|
|
c581f1bba4 | ||
|
|
b8ac9c2edd | ||
|
|
1027ee2481 | ||
|
|
2f311f7821 | ||
|
|
a98c95b514 | ||
|
|
5bbbae5b23 | ||
|
|
f9c9b9f924 | ||
|
|
5921208ea6 | ||
|
|
f89c78abd1 | ||
|
|
74d3b9334c | ||
|
|
919fc66b9d | ||
|
|
400fb5a5bb | ||
|
|
3bb4f9085c | ||
|
|
714c6cec3c | ||
|
|
cb69921202 | ||
|
|
277a0adac9 | ||
|
|
02d14f504f | ||
|
|
1ab7664a60 | ||
|
|
1be46ffb7e | ||
|
|
6ca52aed0d | ||
|
|
74e20970e2 | ||
|
|
93f2b6b4d8 | ||
|
|
00e616b57a | ||
|
|
e436673304 | ||
|
|
ce04d3ce41 | ||
|
|
4e46bf4697 | ||
|
|
9b95508f99 | ||
|
|
c8c24456c1 | ||
|
|
80a6e82e1b | ||
|
|
80cec20d38 | ||
|
|
26cb22020d | ||
|
|
09d05d09c9 | ||
|
|
160c91f908 | ||
|
|
58f41bcd42 | ||
|
|
0235429995 | ||
|
|
f79697e117 | ||
|
|
6f0019c71e | ||
|
|
1a04a18245 | ||
|
|
0cf3ff8209 | ||
|
|
7f56091fbd | ||
|
|
391f9b31f6 | ||
|
|
1d7c0f504a | ||
|
|
9cdc62f918 | ||
|
|
6027d0481e | ||
|
|
277fb92f9e | ||
|
|
79b6c3c1af | ||
|
|
ad17174119 | ||
|
|
6c2692eec0 | ||
|
|
08640e8575 | ||
|
|
4a2575136f | ||
|
|
e792afad17 | ||
|
|
5ecc4b027d | ||
|
|
bc540f0cf0 | ||
|
|
a24b14c465 | ||
|
|
c3f36c3123 | ||
|
|
1d34da7557 | ||
|
|
27d74a4327 | ||
|
|
8a20cc682c | ||
|
|
9b20359e7b | ||
|
|
8866d0ccef | ||
|
|
7fa91a9971 | ||
|
|
28d1f3eef0 | ||
|
|
f321cf6655 | ||
|
|
14ade737da | ||
|
|
41b1b1f141 | ||
|
|
25dfd47d32 | ||
|
|
6afa9c8b92 | ||
|
|
2fc449da4c | ||
|
|
5dd3b8cf9d | ||
|
|
e834fa0050 | ||
|
|
9a97401606 | ||
|
|
410a3fef18 | ||
|
|
969b9814d5 | ||
|
|
2275e27b87 | ||
|
|
62b06cd204 | ||
|
|
350934ca21 | ||
|
|
6332673434 | ||
|
|
f217840998 | ||
|
|
089ec35ceb | ||
|
|
fecd0b809e | ||
|
|
4707a46561 | ||
|
|
616533c5a8 | ||
|
|
c5b2991821 | ||
|
|
c36d0fdc7c | ||
|
|
544e09cf4b | ||
|
|
c110dc9e6a | ||
|
|
3bf37d6afd | ||
|
|
b80ae5796b | ||
|
|
2083632299 | ||
|
|
3ca2f8ac9e | ||
|
|
7172432084 | ||
|
|
0e6afd147f | ||
|
|
46275a4f43 | ||
|
|
1dca378e03 | ||
|
|
06669594b1 | ||
|
|
c09ac58ac0 | ||
|
|
e01d32ef1a | ||
|
|
5ea3bcf59e | ||
|
|
aa8b14b7ee | ||
|
|
e1722cf739 | ||
|
|
7a7f70e15d | ||
|
|
b3c3ec16e5 | ||
|
|
149f863951 | ||
|
|
684d09faac | ||
|
|
8a42691c80 | ||
|
|
d591b3dd98 | ||
|
|
a90fb4d8b6 | ||
|
|
ebd08d9c63 | ||
|
|
71731d223b | ||
|
|
726ea5e01e | ||
|
|
16c7d2964b | ||
|
|
5a6e494bda | ||
|
|
88c6d89fbb | ||
|
|
de12da18da | ||
|
|
8d10736934 | ||
|
|
2328e02d82 | ||
|
|
87cd5fca90 | ||
|
|
b70cb726c5 | ||
|
|
295811ed5a | ||
|
|
4bc55551c6 | ||
|
|
2b8c6dc8f9 | ||
|
|
8b27380feb | ||
|
|
8de3a90851 | ||
|
|
f8bb94d721 | ||
|
|
0c6d06e7bb | ||
|
|
b0aa5d3af2 | ||
|
|
27d09713fd | ||
|
|
ff18852879 | ||
|
|
e515c91e5e | ||
|
|
1d5800c4f7 | ||
|
|
de8f190945 | ||
|
|
f371e3c8d3 | ||
|
|
b15a6290a7 | ||
|
|
0f151db355 | ||
|
|
fa99b75d1f | ||
|
|
4a299c1f39 | ||
|
|
30a2015a68 | ||
|
|
c7c8a4891f | ||
|
|
fe9fc6b459 | ||
|
|
2113fb490d | ||
|
|
0afedbd252 | ||
|
|
3dec38450a | ||
|
|
d7a00b05e3 | ||
|
|
ff2cc8c887 | ||
|
|
0571a96cea | ||
|
|
b7b457b076 | ||
|
|
d2c12005b2 | ||
|
|
25f26d7e5f | ||
|
|
9d5724e1a0 | ||
|
|
784d23ec87 | ||
|
|
709689a7ee | ||
|
|
35d5d3d995 | ||
|
|
630a8d8a4e | ||
|
|
54eb1d9055 | ||
|
|
cb63caea61 | ||
|
|
8e046bb022 | ||
|
|
189b53b8c4 | ||
|
|
9b7277d464 | ||
|
|
551a65c069 | ||
|
|
4c21a697f4 | ||
|
|
a8506c07ae | ||
|
|
b0feb85b5c | ||
|
|
f371eba8ad | ||
|
|
265fa52ace | ||
|
|
c1f5322d38 | ||
|
|
4415e00b38 | ||
|
|
d4e46c5a9c | ||
|
|
bf5b9949fe | ||
|
|
3c11a2b1da | ||
|
|
1248868169 | ||
|
|
930b95a548 | ||
|
|
27c9f68c7c | ||
|
|
358d4d86a7 | ||
|
|
d55eea2239 | ||
|
|
4507954ea5 | ||
|
|
8e0a83f8d8 | ||
|
|
b6ec09e6cf | ||
|
|
ed4e90623d | ||
|
|
38cdb48748 | ||
|
|
71bfe9b745 | ||
|
|
9e7645a167 | ||
|
|
6dccc37143 | ||
|
|
3310310d8c | ||
|
|
abb499aad8 | ||
|
|
1afc09b08a | ||
|
|
0e86d72f05 | ||
|
|
c9857a2764 | ||
|
|
701ba3902c | ||
|
|
bb3ec970a9 | ||
|
|
1d023e6db5 | ||
|
|
1bd906ecb3 | ||
|
|
7cbffdb86b | ||
|
|
b979196ffd | ||
|
|
2949db5f49 | ||
|
|
47c3ed9705 | ||
|
|
51ca3109eb | ||
|
|
2bcb79dc44 | ||
|
|
ecec985649 | ||
|
|
994908549d | ||
|
|
e00f059a4a | ||
|
|
6808e0d531 | ||
|
|
410c95308a | ||
|
|
bec1f23616 | ||
|
|
34596b7f83 | ||
|
|
5ca7169ee5 | ||
|
|
3300aaa1b9 | ||
|
|
54afc8a4a1 | ||
|
|
f19f4310f4 | ||
|
|
444125a7e1 | ||
|
|
56cbb69401 | ||
|
|
70870ffcd2 | ||
|
|
a556d91673 | ||
|
|
8ecbde8e1e | ||
|
|
a24b293818 | ||
|
|
cab5ebf94b | ||
|
|
a54b5baef2 | ||
|
|
c324fe204e | ||
|
|
37d972ed9e | ||
|
|
e4a3b1cb05 | ||
|
|
49538f272e | ||
|
|
1283232144 | ||
|
|
2f9891f0aa | ||
|
|
865a2b1fb0 | ||
|
|
1fde62eeb6 | ||
|
|
6754cd48e2 | ||
|
|
ccb477687a | ||
|
|
be0e6c8925 | ||
|
|
1c2cb947c0 | ||
|
|
4663eec950 | ||
|
|
fff3c1eb36 | ||
|
|
4b7434d1e8 | ||
|
|
8cc35a60e6 | ||
|
|
130653a1aa | ||
|
|
1dcbebd130 | ||
|
|
faf306ad23 | ||
|
|
d11cdcd5d2 | ||
|
|
0e59bd0bf3 | ||
|
|
c0c6154ec1 | ||
|
|
cb5384c2fb | ||
|
|
038c836fe5 | ||
|
|
6b0f3570b9 | ||
|
|
71de0d04f3 | ||
|
|
99debff5d2 | ||
|
|
3bac6fcb27 | ||
|
|
4b842b81a0 | ||
|
|
e2e4d048ab | ||
|
|
5574c368cd | ||
|
|
0d34f7b92e | ||
|
|
5be0632e01 | ||
|
|
79ea0bf9f4 | ||
|
|
b1929cb688 | ||
|
|
5ad98700e5 | ||
|
|
a54624b697 | ||
|
|
ca34c865af | ||
|
|
dde57b1eca | ||
|
|
264b06938e | ||
|
|
99edb303e2 | ||
|
|
104cc24dfc | ||
|
|
fcbcbac889 | ||
|
|
b86d19028c | ||
|
|
4f17a251d3 | ||
|
|
731a823cc2 | ||
|
|
3d79fe2bf4 | ||
|
|
474399154f | ||
|
|
19f5153d0e | ||
|
|
ce11271866 | ||
|
|
86cf353296 | ||
|
|
36df5dc721 | ||
|
|
1e44a9c942 | ||
|
|
8685cf9036 | ||
|
|
2232870b09 | ||
|
|
b68acd101e | ||
|
|
173ba9b2b5 | ||
|
|
64ed1f87d3 | ||
|
|
1ca085ec4a | ||
|
|
e332b7535c | ||
|
|
79eb613b3e | ||
|
|
5a79ec28d1 | ||
|
|
97e65a02c0 | ||
|
|
e87c786b77 | ||
|
|
251d30d47f | ||
|
|
761d0a0f18 | ||
|
|
ae4b1e74f9 | ||
|
|
ac44618e58 | ||
|
|
d634cbf924 | ||
|
|
21db0e6275 | ||
|
|
ce426fd3f4 | ||
|
|
b5d4c91207 | ||
|
|
b43263be77 | ||
|
|
207cf7ca24 | ||
|
|
00e34758c4 | ||
|
|
7a3f878c11 | ||
|
|
b8439598bc | ||
|
|
7fb0818923 | ||
|
|
a7c435adc4 | ||
|
|
dd90aabad6 | ||
|
|
5bded1946e | ||
|
|
3642e96154 | ||
|
|
9da09ee3a6 | ||
|
|
141c140f53 | ||
|
|
84b660d2ef | ||
|
|
6beedba957 | ||
|
|
d73982819b | ||
|
|
6ac5bcc907 | ||
|
|
389d4d10f1 | ||
|
|
89dcbd0229 | ||
|
|
ad8caa2b51 | ||
|
|
9c42241269 | ||
|
|
38dd45cce2 | ||
|
|
aa90253c62 | ||
|
|
41576652dc | ||
|
|
74830854ca | ||
|
|
2542b1b44d | ||
|
|
51f5e60224 | ||
|
|
bb5885e2bb | ||
|
|
d51bbb0008 | ||
|
|
49e898b189 | ||
|
|
42c4fe5705 | ||
|
|
4b5f2c36b9 | ||
|
|
935dca67e6 | ||
|
|
d431790e19 | ||
|
|
56310b7bd4 | ||
|
|
f15e21faad | ||
|
|
44aa6a2b38 | ||
|
|
9f32347c01 | ||
|
|
3d5b229c46 | ||
|
|
5863ccc0a0 | ||
|
|
d220a16b99 | ||
|
|
79784fc8ee | ||
|
|
a83bc53c6a | ||
|
|
85de0b91b1 | ||
|
|
d91c6e5702 | ||
|
|
ab7689d188 | ||
|
|
c81455c760 | ||
|
|
39bfc97a7a | ||
|
|
88aac78282 | ||
|
|
863e830d24 | ||
|
|
6c705728a4 | ||
|
|
7f00279ffb | ||
|
|
c198d0079e | ||
|
|
1135d5a971 | ||
|
|
e299fa27a0 | ||
|
|
46e0bc940a | ||
|
|
9a552012f2 | ||
|
|
6498d385ee | ||
|
|
dd00f2016f | ||
|
|
64d25e6522 | ||
|
|
1462ab08de | ||
|
|
a8e93a594d | ||
|
|
dea30b37ef | ||
|
|
39571dda0b | ||
|
|
c7d801b6c2 | ||
|
|
57731be689 | ||
|
|
f00524e518 | ||
|
|
5567c40bae | ||
|
|
5d1a7613dd | ||
|
|
fa768dc112 | ||
|
|
27fb51d37f | ||
|
|
d02db3864e | ||
|
|
a26c3036a7 | ||
|
|
0af346aad8 | ||
|
|
c3c8ee7292 | ||
|
|
5fbdfa66d9 | ||
|
|
15b75715ee | ||
|
|
1fd92b6cbd | ||
|
|
2918b5d74e | ||
|
|
669c5be344 | ||
|
|
e1b40ec46e | ||
|
|
15767538eb | ||
|
|
de2b16c464 | ||
|
|
d5e6b38450 | ||
|
|
a636e87a4f | ||
|
|
50d5b4fa37 | ||
|
|
f6d26392fb | ||
|
|
2705bcce15 | ||
|
|
379a31ece6 | ||
|
|
daa593d225 | ||
|
|
ed8340affa | ||
|
|
b3c1e72577 | ||
|
|
3da09d140a | ||
|
|
51f254bbb1 | ||
|
|
30ee456d4c | ||
|
|
460d5f2517 | ||
|
|
5da1fc8445 |
@@ -1,35 +1,25 @@
|
|||||||
version: 2
|
version: 2.1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
resource_class: medium+
|
resource_class: xlarge
|
||||||
docker:
|
docker:
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
- image: node:12
|
||||||
environment:
|
environment:
|
||||||
CONTRACTS_COMMIT_HASH: '9ed05f5'
|
NODE_OPTIONS: '--max-old-space-size=16384'
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV
|
- run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV
|
||||||
# HACK(feuGeneA): commented out this hack as we're changing
|
|
||||||
# from a circleci-maintained container to a different
|
|
||||||
# container, and this hack may not apply anymore, as
|
|
||||||
# suggested by the non-existance of `/home/circleci/.bashrc`
|
|
||||||
# when running the command below.
|
|
||||||
# - run:
|
|
||||||
# # HACK(albrow): Without this, yarn commands will sometimes
|
|
||||||
# # fail with a "permission denied" error.
|
|
||||||
# name: Set npm path
|
|
||||||
# command: npm set prefix=/home/circleci/npm && echo 'export PATH=$HOME/circleci/npm/bin:$PATH' >> /home/circleci/.bashrc
|
|
||||||
- run:
|
- run:
|
||||||
name: install-yarn
|
name: install-yarn
|
||||||
command: npm install --global yarn@1.17.0
|
command: npm install --force --global yarn@1.22.0
|
||||||
- run:
|
- run:
|
||||||
name: yarn
|
name: yarn
|
||||||
command: yarn --frozen-lockfile --ignore-engines install || yarn --frozen-lockfile --ignore-engines install
|
command: yarn --frozen-lockfile --ignore-engines install || yarn --frozen-lockfile --ignore-engines install
|
||||||
- setup_remote_docker
|
- setup_remote_docker
|
||||||
- run: yarn build:ci
|
- run: yarn build:ci || yarn build:ci || yarn build:ci || yarn build:ci || yarn build:ci || yarn build:ci
|
||||||
- run: yarn build:ts
|
- run: yarn build:ts || yarn build:ts || yarn build:ts || yarn build:ts || yarn build:ts || yarn build:ts
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: repo-{{ .Environment.CIRCLE_SHA1 }}
|
key: repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
@@ -37,55 +27,63 @@ jobs:
|
|||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
path: ~/repo/packages/abi-gen/test-cli/output
|
path: ~/repo/packages/abi-gen/test-cli/output
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
path: ~/repo/packages/abi-gen-wrappers/generated_docs
|
path: ~/repo/packages/contract-wrappers/generated_docs
|
||||||
test-contracts-ganache:
|
test-exchange-ganache:
|
||||||
resource_class: medium+
|
resource_class: medium+
|
||||||
docker:
|
docker:
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
- image: node:12
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run: yarn wsrun test:circleci @0x/contracts-multisig @0x/contracts-utils @0x/contracts-exchange-libs @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-erc1155 @0x/contracts-extensions @0x/contracts-asset-proxy @0x/contracts-exchange @0x/contracts-exchange-forwarder @0x/contracts-coordinator @0x/contracts-tests @0x/contracts-staking
|
- run: yarn wsrun -p @0x/contracts-exchange -m --serial -c test:circleci
|
||||||
test-exchange-ganache-3.0:
|
test-integrations-ganache:
|
||||||
resource_class: medium+
|
resource_class: medium+
|
||||||
docker:
|
docker:
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
- image: node:12
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run: yarn wsrun test:circleci @0x/contracts-exchange
|
- run: yarn wsrun -p @0x/contracts-integrations -m --serial -c test:circleci
|
||||||
test-integrations-ganache-3.0:
|
test-contracts-staking-ganache:
|
||||||
resource_class: medium+
|
resource_class: medium+
|
||||||
docker:
|
docker:
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
- image: node:12
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run: yarn wsrun test:circleci @0x/contracts-integrations
|
- run: yarn wsrun -p @0x/contracts-staking -m --serial -c test:circleci
|
||||||
test-contracts-rest-ganache-3.0:
|
test-contracts-extra-ganache:
|
||||||
resource_class: medium+
|
resource_class: medium+
|
||||||
docker:
|
docker:
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
- image: node:12
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run: yarn wsrun test:circleci @0x/contracts-multisig @0x/contracts-utils @0x/contracts-exchange-libs @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-erc1155 @0x/contracts-asset-proxy @0x/contracts-exchange-forwarder @0x/contracts-tests @0x/contracts-staking @0x/contracts-coordinator
|
- run: yarn wsrun -p @0x/contracts-exchange-forwarder -p @0x/contracts-coordinator -m --serial -c test:circleci
|
||||||
# TODO(dorothy-zbornak): Re-enable after updating this package for
|
test-contracts-rest-ganache:
|
||||||
# 3.0. At that time, also remove exclusion from monorepo
|
resource_class: medium+
|
||||||
# package.json's test script.
|
docker:
|
||||||
# - run: yarn wsrun test:circleci @0x/contracts-extensions
|
- image: node:12
|
||||||
|
working_directory: ~/repo
|
||||||
|
steps:
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
|
- run: yarn wsrun -p @0x/contracts-multisig -p @0x/contracts-utils -p @0x/contracts-exchange-libs -p @0x/contracts-erc20 -p @0x/contracts-erc721 -p @0x/contracts-erc1155 -p @0x/contracts-asset-proxy -p @0x/contracts-broker -p @0x/contracts-zero-ex -m --serial -c test:circleci
|
||||||
test-publish:
|
test-publish:
|
||||||
resource_class: medium+
|
resource_class: large
|
||||||
|
environment:
|
||||||
|
NODE_OPTIONS: '--max-old-space-size=6442'
|
||||||
docker:
|
docker:
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
- image: node:12
|
||||||
- image: 0xorg/verdaccio
|
- image: 0xorg/verdaccio
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
@@ -93,256 +91,52 @@ jobs:
|
|||||||
keys:
|
keys:
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run:
|
- run:
|
||||||
command: yarn test:publish:circleci
|
command: yarn test:publish:circleci
|
||||||
no_output_timeout: 1800
|
no_output_timeout: 1800
|
||||||
|
- store_artifacts:
|
||||||
|
path: ~/.npm/_logs
|
||||||
test-doc-generation:
|
test-doc-generation:
|
||||||
docker:
|
docker:
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
- image: node:12
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run:
|
- run:
|
||||||
command: yarn test:generate_docs:circleci
|
command: yarn test:generate_docs:circleci
|
||||||
no_output_timeout: 1200
|
no_output_timeout: 1200
|
||||||
test-rest:
|
test-rest:
|
||||||
docker:
|
docker:
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
- image: node:12
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run: yarn wsrun test:circleci @0x/contracts-test-utils
|
- run: yarn wsrun -p @0x/contracts-test-utils -m --serial -c test:circleci
|
||||||
- run: yarn wsrun test:circleci @0x/abi-gen
|
- run: yarn wsrun -p @0x/contract-artifacts -m --serial -c test:circleci
|
||||||
# TODO (xianny): Needs to be updated for 3.0
|
- run: yarn wsrun -p @0x/contract-wrappers-test -m --serial -c test:circleci
|
||||||
# - run: yarn wsrun test:circleci @0x/asset-buyer
|
- run: yarn wsrun -p @0x/migrations -m --serial -c test:circleci
|
||||||
# TODO: Needs to be updated for 3.0. At that time, also remove
|
- run: yarn wsrun -p @0x/order-utils -m --serial -c test:circleci
|
||||||
# exclusion from monorepo package.json's test script.
|
- run: yarn wsrun -p @0x/asset-swapper -m --serial -c test:circleci
|
||||||
# - run: yarn wsrun test:circleci @0x/asset-swapper
|
|
||||||
- run: yarn wsrun test:circleci @0x/contract-artifacts
|
|
||||||
- run: yarn wsrun test:circleci @0x/assert
|
|
||||||
- run: yarn wsrun test:circleci @0x/base-contract
|
|
||||||
# TODO (xianny): Needs to be updated for 3.0
|
|
||||||
# - run: yarn wsrun test:circleci @0x/connect
|
|
||||||
- run: yarn wsrun test:circleci @0x/contract-wrappers
|
|
||||||
- run: yarn wsrun test:circleci @0x/dev-utils
|
|
||||||
- run: yarn wsrun test:circleci @0x/json-schemas
|
|
||||||
- run: yarn wsrun test:circleci @0x/order-utils
|
|
||||||
# TODO: Needs to be updated for 3.0. At that time, also remove
|
|
||||||
# exclusion from monorepo package.json's test script.
|
|
||||||
# - run: yarn wsrun test:circleci @0x/orderbook
|
|
||||||
- run: yarn wsrun test:circleci @0x/sol-compiler
|
|
||||||
- run: yarn wsrun test:circleci @0x/sol-tracing-utils
|
|
||||||
- run: yarn wsrun test:circleci @0x/sol-doc
|
|
||||||
- run: yarn wsrun test:circleci @0x/subproviders
|
|
||||||
- run: yarn wsrun test:circleci @0x/web3-wrapper
|
|
||||||
- run: yarn wsrun test:circleci @0x/utils
|
|
||||||
- run: yarn wsrun test:circleci @0x/instant
|
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
|
key: coverage-contract-wrappers-test-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
- ~/repo/packages/abi-gen/coverage/lcov.info
|
- ~/repo/packages/contract-wrappers-test/coverage/lcov.info
|
||||||
- save_cache:
|
|
||||||
key: coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/packages/assert/coverage/lcov.info
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-asset-buyer-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/packages/asset-buyer/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:
|
|
||||||
- ~/repo/packages/dev-utils/coverage/lcov.info
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/packages/json-schemas/coverage/lcov.info
|
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: coverage-order-utils-{{ .Environment.CIRCLE_SHA1 }}
|
key: coverage-order-utils-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
- ~/repo/packages/order-utils/coverage/lcov.info
|
- ~/repo/packages/order-utils/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-tracing-utils-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/packages/sol-tracing-utils/coverage/lcov.info
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/packages/sol-doc/coverage/lcov.info
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/packages/subproviders/coverage/lcov.info
|
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: coverage-web3-wrapper-{{ .Environment.CIRCLE_SHA1 }}
|
key: coverage-web3-wrapper-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
- ~/repo/packages/web3-wrapper/coverage/lcov.info
|
- ~/repo/packages/web3-wrapper/coverage/lcov.info
|
||||||
test-python:
|
|
||||||
working_directory: ~/repo
|
|
||||||
docker:
|
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
|
||||||
- image: 0xorg/ganache-cli:4.4.0-beta.1
|
|
||||||
environment:
|
|
||||||
VERSION: 4.4.0-beta.1
|
|
||||||
SNAPSHOT_NAME: 0x_ganache_snapshot-v3-beta
|
|
||||||
- image: 0xorg/mesh:6.0.0-beta-0xv3
|
|
||||||
environment:
|
|
||||||
ETHEREUM_RPC_URL: 'http://localhost:8545'
|
|
||||||
ETHEREUM_NETWORK_ID: '50'
|
|
||||||
ETHEREUM_CHAIN_ID: '1337'
|
|
||||||
USE_BOOTSTRAP_LIST: 'true'
|
|
||||||
VERBOSITY: 3
|
|
||||||
PRIVATE_KEY_PATH: ''
|
|
||||||
BLOCK_POLLING_INTERVAL: '5s'
|
|
||||||
P2P_LISTEN_PORT: '60557'
|
|
||||||
command: |
|
|
||||||
sh -c "waitForGanache () { until printf 'POST /\r\nContent-Length: 26\r\n\r\n{\"method\":\"net_listening\"}' | nc localhost 8545 | grep true; do continue; done }; waitForGanache && ./mesh"
|
|
||||||
- image: 0xorg/launch-kit-backend:v3
|
|
||||||
environment:
|
|
||||||
RPC_URL: 'http://localhost:8545'
|
|
||||||
CHAIN_ID: 1337
|
|
||||||
WHITELIST_ALL_TOKENS: True
|
|
||||||
FEE_RECIPIENT: '0x0000000000000000000000000000000000000001'
|
|
||||||
MAKER_FEE_UNIT_AMOUNT: 0
|
|
||||||
TAKER_FEE_UNIT_AMOUNT: 0
|
|
||||||
MESH_ENDPOINT: 'ws://localhost:60557'
|
|
||||||
command: |
|
|
||||||
sh -c "waitForMesh () { sleep 5; }; waitForMesh && node_modules/.bin/forever ts/lib/index.js"
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- run:
|
|
||||||
command: |
|
|
||||||
cd python-packages
|
|
||||||
python -m ensurepip
|
|
||||||
./pre_install
|
|
||||||
./install
|
|
||||||
- save_cache:
|
|
||||||
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- '/usr/local/bin'
|
|
||||||
- '/usr/local/lib/python3.7/site-packages'
|
|
||||||
- run:
|
|
||||||
command: |
|
|
||||||
cd python-packages
|
|
||||||
./parallel coverage run setup.py test
|
|
||||||
./build_docs
|
|
||||||
- run:
|
|
||||||
command: |
|
|
||||||
# copy generated wrappers into contract_wrappers/build,
|
|
||||||
# JUST so CircleCI will persist them as build artifacts.
|
|
||||||
cd python-packages/contract_wrappers/src/zero_ex
|
|
||||||
for i in contract_wrappers/[^__]*/; do mkdir -p ../../build/$i; cp $i/__init__.py ../../build/$i; done
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-python-contract-addresses-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/python-packages/contract_addresses/.coverage
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-python-contract-artifacts-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/python-packages/contract_artifacts/.coverage
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-python-contract-demo-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/python-packages/contract_demo/.coverage
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/python-packages/json_schemas/.coverage
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-python-order-utils-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/python-packages/order_utils/.coverage
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-python-sra-client-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/python-packages/sra_client/.coverage
|
|
||||||
- store_artifacts:
|
|
||||||
path: ~/repo/python-packages/contract_addresses/build
|
|
||||||
- store_artifacts:
|
|
||||||
path: ~/repo/python-packages/contract_artifacts/build
|
|
||||||
- store_artifacts:
|
|
||||||
path: ~/repo/python-packages/contract_wrappers/build
|
|
||||||
- store_artifacts:
|
|
||||||
path: ~/repo/python-packages/json_schemas/build
|
|
||||||
- store_artifacts:
|
|
||||||
path: ~/repo/python-packages/middlewares/build
|
|
||||||
- store_artifacts:
|
|
||||||
path: ~/repo/python-packages/order_utils/build
|
|
||||||
- store_artifacts:
|
|
||||||
path: ~/repo/python-packages/sra_client/build
|
|
||||||
test-rest-python:
|
|
||||||
working_directory: ~/repo
|
|
||||||
docker:
|
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- run:
|
|
||||||
command: |
|
|
||||||
cd python-packages/order_utils
|
|
||||||
python -m ensurepip
|
|
||||||
python -m pip install .
|
|
||||||
- save_cache:
|
|
||||||
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- '/usr/local/bin'
|
|
||||||
- '/usr/local/lib/python3.7/site-packages'
|
|
||||||
- '.eggs'
|
|
||||||
- '.mypy_cache'
|
|
||||||
- '.pytest_cache'
|
|
||||||
- '.tox'
|
|
||||||
- run:
|
|
||||||
command: |
|
|
||||||
cd python-packages/order_utils
|
|
||||||
tox
|
|
||||||
static-tests-python:
|
|
||||||
working_directory: ~/repo
|
|
||||||
docker:
|
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- run:
|
|
||||||
command: |
|
|
||||||
python -m ensurepip
|
|
||||||
cd python-packages
|
|
||||||
./pre_install
|
|
||||||
./install
|
|
||||||
./lint
|
|
||||||
static-tests:
|
static-tests:
|
||||||
resource_class: large
|
resource_class: large
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
docker:
|
docker:
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
- image: node:12
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
@@ -351,11 +145,9 @@ jobs:
|
|||||||
- run: yarn prettier:ci
|
- run: yarn prettier:ci
|
||||||
- run: yarn deps_versions:ci
|
- run: yarn deps_versions:ci
|
||||||
- run: yarn diff_md_docs:ci
|
- run: yarn diff_md_docs:ci
|
||||||
- run: cd packages/0x.js && yarn build:umd:prod
|
|
||||||
- run: yarn bundlewatch
|
|
||||||
submit-coverage:
|
submit-coverage:
|
||||||
docker:
|
docker:
|
||||||
- image: nikolaik/python-nodejs:python3.7-nodejs8
|
- image: node:12
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
@@ -363,80 +155,33 @@ jobs:
|
|||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
|
- coverage-contract-wrappers-test-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-asset-buyer-{{ .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 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- coverage-order-utils-{{ .Environment.CIRCLE_SHA1 }}
|
- coverage-order-utils-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-sol-tracing-utils-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-web3-wrapper-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- coverage-contracts-{{ .Environment.CIRCLE_SHA1 }}
|
- coverage-contracts-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-python-contract-addresses-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-python-contract-artifacts-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-python-contract-demo-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-python-sra-client-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-python-order-utils-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- run: yarn report_coverage
|
- run: yarn report_coverage
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
main:
|
main:
|
||||||
jobs:
|
jobs:
|
||||||
- build
|
- build
|
||||||
- test-exchange-ganache-3.0:
|
# Disabled until we begin actively developing on these packages again.
|
||||||
requires:
|
# - test-exchange-ganache:
|
||||||
- build
|
# requires:
|
||||||
- test-integrations-ganache-3.0:
|
# - build
|
||||||
requires:
|
# - test-integrations-ganache:
|
||||||
- build
|
# requires:
|
||||||
- test-contracts-rest-ganache-3.0:
|
# - build
|
||||||
|
# - test-contracts-staking-ganache:
|
||||||
|
# requires:
|
||||||
|
# - build
|
||||||
|
# - test-contracts-extra-ganache:
|
||||||
|
# requires:
|
||||||
|
# - build
|
||||||
|
- test-contracts-rest-ganache:
|
||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
- test-rest:
|
- test-rest:
|
||||||
@@ -451,17 +196,14 @@ workflows:
|
|||||||
- test-doc-generation:
|
- test-doc-generation:
|
||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
- submit-coverage:
|
# Disabled until this repo has a coveralls API key
|
||||||
requires:
|
# - submit-coverage:
|
||||||
- test-contracts-rest-ganache-3.0
|
# requires:
|
||||||
- test-exchange-ganache-3.0
|
# # Disabled until we begin actively developing on these packages again.
|
||||||
- test-rest
|
# # - test-exchange-ganache
|
||||||
- static-tests
|
# # - test-integrations-ganache
|
||||||
- test-python:
|
# # - test-contracts-staking-ganache
|
||||||
requires:
|
# # - test-contracts-extra-ganache
|
||||||
- build
|
# - test-contracts-rest-ganache
|
||||||
- static-tests-python:
|
# - test-rest
|
||||||
requires:
|
# - static-tests
|
||||||
- build
|
|
||||||
# skip python tox run for now, as we don't yet have multiple test environments to support.
|
|
||||||
# - test-rest-python
|
|
||||||
|
|||||||
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -2,7 +2,3 @@
|
|||||||
|
|
||||||
# Automatically collapse generated files in GitHub.
|
# Automatically collapse generated files in GitHub.
|
||||||
*.svg linguist-generated=true
|
*.svg linguist-generated=true
|
||||||
packages/contract-artifacts/artifacts/*json linguist-generated=true
|
|
||||||
packages/abi-gen-wrappers/src/generated-wrappers/*.ts linguist-generated=true
|
|
||||||
packages/contract-wrappers/src/generated-wrappers/*.ts linguist-generated=true
|
|
||||||
|
|
||||||
|
|||||||
27
.github/autolabeler.yml
vendored
27
.github/autolabeler.yml
vendored
@@ -1,34 +1,7 @@
|
|||||||
python: ['python-packages']
|
python: ['python-packages']
|
||||||
contracts: ['contracts']
|
contracts: ['contracts']
|
||||||
@0x/sol-doc: ['packages/sol-doc']
|
|
||||||
@0x/sol-resolver: ['packages/sol-resolver']
|
|
||||||
@0x/contracts-gen: ['packages/contracts-gen']
|
|
||||||
@0x/sra-spec: ['packages/sra-spec']
|
|
||||||
@0x/subproviders: ['packages/subproviders']
|
|
||||||
@0x/contract-addresses: ['packages/contract-addresses']
|
@0x/contract-addresses: ['packages/contract-addresses']
|
||||||
@0x/migrations: ['packages/migrations']
|
@0x/migrations: ['packages/migrations']
|
||||||
@0x/web3-wrapper: ['packages/web3-wrapper']
|
|
||||||
@0x/sol-compiler: ['packages/sol-compiler']
|
|
||||||
@0x/types: ['packages/types']
|
|
||||||
@0x/instant: ['packages/instant']
|
|
||||||
@0x/abi-gen-templates: ['packages/abi-gen-templates']
|
|
||||||
@0x/abi-gen: ['packages/abi-gen']
|
|
||||||
@0x/sol-coverage: ['packages/sol-coverage']
|
|
||||||
@0x/sol-profiler: ['packages/sol-profiler']
|
|
||||||
@0x/sol-trace: ['packages/sol-trace']
|
|
||||||
@0x/sol-tracing-utils: ['packages/sol-tracing-utils']
|
|
||||||
@0x/utils: ['packages/utils']
|
|
||||||
@0x/tslint-config: ['packages/tslint-config']
|
|
||||||
@0x/asset-buyer: ['packages/asset-buyer']
|
|
||||||
@0x/order-utils: ['packages/order-utils']
|
@0x/order-utils: ['packages/order-utils']
|
||||||
@0x/assert: ['packages/assert']
|
|
||||||
@0x/base-contract: ['packages/base-contract']
|
|
||||||
@0x/typescript-typings: ['packages/typescript-typings']
|
|
||||||
0x.js: ['packages/0x.js']
|
|
||||||
@0x/abi-gen-wrappers: ['packages/abi-gen-wrappers']
|
|
||||||
@0x/contract-artifacts: ['packages/contract-artifacts']
|
@0x/contract-artifacts: ['packages/contract-artifacts']
|
||||||
@0x/dev-utils: ['packages/dev-utils']
|
|
||||||
@0x/contract-wrappers: ['packages/contract-wrappers']
|
@0x/contract-wrappers: ['packages/contract-wrappers']
|
||||||
@0x/json-schemas: ['packages/json-schemas']
|
|
||||||
@0x/ethereum-types: ['ethereum-types']
|
|
||||||
@0x/connect: ['packages/connect']
|
|
||||||
|
|||||||
53
.github/workflows/publish.yml
vendored
Normal file
53
.github/workflows/publish.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
name: publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
ci_status:
|
||||||
|
description: 'required CI status'
|
||||||
|
default: 'success'
|
||||||
|
required: true
|
||||||
|
prerelease:
|
||||||
|
description: 'prerelease name'
|
||||||
|
required: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 'check successful status'
|
||||||
|
run: |
|
||||||
|
REF_STATUS=$(curl -s \
|
||||||
|
'https://api.github.com/repos/${{ github.repository }}/commits/${{ github.ref }}/status' \
|
||||||
|
| jq .state)
|
||||||
|
[[ "${REF_STATUS}" == '"${{ github.event.inputs.ci_status }}"' ]] || \
|
||||||
|
(echo "::error ::${{ github.ref }} does not have a successful CI status" && false)
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
fetch-depth: 0
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 10
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
- name: 'configure git'
|
||||||
|
run: |
|
||||||
|
git config --global user.email "github-actions@github.com"
|
||||||
|
git config --global user.name "Github Actions"
|
||||||
|
- name: 'install dependencies'
|
||||||
|
run: |
|
||||||
|
yarn -D
|
||||||
|
- name: 'build and publish'
|
||||||
|
run: |
|
||||||
|
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
|
||||||
|
npm run run:publish:gha
|
||||||
|
env:
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||||
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
PUBLISH_PRERELEASE: ${{ github.event.inputs.prerelease }}
|
||||||
|
- name: 'merge into main branch'
|
||||||
|
if: github.event.inputs.prerelease == '' # unless it's a prerelease
|
||||||
|
run: |
|
||||||
|
git checkout main && \
|
||||||
|
git merge ${{ github.ref }} && \
|
||||||
|
git push
|
||||||
65
.gitignore
vendored
65
.gitignore
vendored
@@ -75,10 +75,15 @@ generated_docs/
|
|||||||
|
|
||||||
TODO.md
|
TODO.md
|
||||||
|
|
||||||
# VSCode file
|
# IDE file
|
||||||
.vscode
|
.vscode
|
||||||
|
.idea
|
||||||
|
|
||||||
# generated contract artifacts/
|
# generated contract artifacts/
|
||||||
|
contracts/broker/generated-artifacts/
|
||||||
|
contracts/broker/test/generated-artifacts/
|
||||||
|
contracts/erc20-bridge-sampler/generated-artifacts/
|
||||||
|
contracts/erc20-bridge-sampler/test/generated-artifacts/
|
||||||
contracts/integrations/generated-artifacts/
|
contracts/integrations/generated-artifacts/
|
||||||
contracts/integrations/test/generated-artifacts/
|
contracts/integrations/test/generated-artifacts/
|
||||||
contracts/staking/generated-artifacts/
|
contracts/staking/generated-artifacts/
|
||||||
@@ -107,10 +112,14 @@ contracts/exchange-forwarder/generated-artifacts/
|
|||||||
contracts/exchange-forwarder/test/generated-artifacts/
|
contracts/exchange-forwarder/test/generated-artifacts/
|
||||||
contracts/dev-utils/generated-artifacts/
|
contracts/dev-utils/generated-artifacts/
|
||||||
contracts/dev-utils/test/generated-artifacts/
|
contracts/dev-utils/test/generated-artifacts/
|
||||||
packages/sol-tracing-utils/test/fixtures/artifacts/
|
contracts/zero-ex/generated-artifacts/
|
||||||
python-packages/contract_artifacts/src/zero_ex/contract_artifacts/artifacts/
|
contracts/zero-ex/test/generated-artifacts/
|
||||||
|
contracts/treasury/generated-artifacts/
|
||||||
|
contracts/treasury/test/generated-artifacts/
|
||||||
|
|
||||||
# generated truffle contract artifacts/
|
# generated truffle contract artifacts/
|
||||||
|
contracts/broker/build/
|
||||||
|
contracts/erc20-bridge-sampler/build/
|
||||||
contracts/staking/build/
|
contracts/staking/build/
|
||||||
contracts/coordinator/build/
|
contracts/coordinator/build/
|
||||||
contracts/exchange/build/
|
contracts/exchange/build/
|
||||||
@@ -126,7 +135,11 @@ contracts/exchange-forwarder/build/
|
|||||||
contracts/dev-utils/build/
|
contracts/dev-utils/build/
|
||||||
|
|
||||||
# generated contract wrappers
|
# generated contract wrappers
|
||||||
|
contracts/broker/generated-wrappers/
|
||||||
|
contracts/broker/test/generated-wrappers/
|
||||||
packages/python-contract-wrappers/generated/
|
packages/python-contract-wrappers/generated/
|
||||||
|
contracts/erc20-bridge-sampler/generated-wrappers/
|
||||||
|
contracts/erc20-bridge-sampler/test/generated-wrappers/
|
||||||
contracts/integrations/generated-wrappers/
|
contracts/integrations/generated-wrappers/
|
||||||
contracts/integrations/test/generated-wrappers/
|
contracts/integrations/test/generated-wrappers/
|
||||||
contracts/staking/generated-wrappers/
|
contracts/staking/generated-wrappers/
|
||||||
@@ -155,48 +168,10 @@ contracts/exchange-forwarder/generated-wrappers/
|
|||||||
contracts/exchange-forwarder/test/generated-wrappers/
|
contracts/exchange-forwarder/test/generated-wrappers/
|
||||||
contracts/dev-utils/generated-wrappers/
|
contracts/dev-utils/generated-wrappers/
|
||||||
contracts/dev-utils/test/generated-wrappers/
|
contracts/dev-utils/test/generated-wrappers/
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/dev_utils/__init__.py
|
contracts/zero-ex/generated-wrappers/
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc20_token/__init__.py
|
contracts/zero-ex/test/generated-wrappers/
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/exchange/__init__.py
|
contracts/treasury/generated-wrappers/
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/asset_proxy_owner/__init__.py
|
contracts/treasury/test/generated-wrappers/
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/coordinator/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/coordinator_registry/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/dummy_erc20_token/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/dummy_erc721_token/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/dutch_auction/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc1155_mintable/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc1155_proxy/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc20_proxy/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc721_proxy/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/erc721_token/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/forwarder/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/i_asset_proxy/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/i_validator/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/i_wallet/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/multi_asset_proxy/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/order_validator/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/staking/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/staking_proxy/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/static_call_proxy/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/weth9/__init__.py
|
|
||||||
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/zrx_token/__init__.py
|
|
||||||
|
|
||||||
# solc-bin in sol-compiler
|
|
||||||
packages/sol-compiler/solc_bin/
|
|
||||||
|
|
||||||
# python stuff
|
|
||||||
.eggs
|
|
||||||
.mypy_cache
|
|
||||||
.tox
|
|
||||||
python-packages/*/build
|
|
||||||
python-packages/*/dist
|
|
||||||
__pycache__
|
|
||||||
python-packages/*/src/*.egg-info
|
|
||||||
python-packages/*/.coverage
|
|
||||||
|
|
||||||
# python keeps package-local copies of json schemas and contract addresses
|
|
||||||
python-packages/json_schemas/src/zero_ex/json_schemas/schemas
|
|
||||||
python-packages/contract_addresses/src/zero_ex/contract_addresses/addresses.json
|
|
||||||
|
|
||||||
# Doc README copy
|
# Doc README copy
|
||||||
packages/*/docs/README.md
|
packages/*/docs/README.md
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
lib
|
lib
|
||||||
.nyc_output
|
.nyc_output
|
||||||
|
/contracts/broker/generated-wrappers
|
||||||
|
/contracts/broker/test/generated-wrappers
|
||||||
|
/contracts/broker/generated-artifacts
|
||||||
|
/contracts/broker/test/generated-artifacts
|
||||||
/contracts/integrations/generated-wrappers
|
/contracts/integrations/generated-wrappers
|
||||||
/contracts/integrations/test/generated-wrappers
|
/contracts/integrations/test/generated-wrappers
|
||||||
/contracts/integrations/generated-artifacts
|
/contracts/integrations/generated-artifacts
|
||||||
@@ -56,6 +60,14 @@ lib
|
|||||||
/contracts/dev-utils/test/generated-wrappers
|
/contracts/dev-utils/test/generated-wrappers
|
||||||
/contracts/dev-utils/generated-artifacts
|
/contracts/dev-utils/generated-artifacts
|
||||||
/contracts/dev-utils/test/generated-artifacts
|
/contracts/dev-utils/test/generated-artifacts
|
||||||
|
/contracts/zero-ex/generated-wrappers
|
||||||
|
/contracts/zero-ex/test/generated-wrappers
|
||||||
|
/contracts/zero-ex/generated-artifacts
|
||||||
|
/contracts/zero-ex/test/generated-artifacts
|
||||||
|
/contracts/treasury/generated-wrappers
|
||||||
|
/contracts/treasury/test/generated-wrappers
|
||||||
|
/contracts/treasury/generated-artifacts
|
||||||
|
/contracts/treasury/test/generated-artifacts
|
||||||
/contracts/staking/build/
|
/contracts/staking/build/
|
||||||
/contracts/coordinator/build/
|
/contracts/coordinator/build/
|
||||||
/contracts/exchange/build/
|
/contracts/exchange/build/
|
||||||
@@ -68,18 +80,11 @@ lib
|
|||||||
/contracts/erc1155/build/
|
/contracts/erc1155/build/
|
||||||
/contracts/extensions/build/
|
/contracts/extensions/build/
|
||||||
/contracts/exchange-forwarder/build/
|
/contracts/exchange-forwarder/build/
|
||||||
/contracts/dev-utils/build/
|
/packages/asset-swapper/generated-artifacts
|
||||||
/packages/abi-gen/test-cli/output
|
/packages/asset-swapper/generated-wrappers
|
||||||
/packages/json-schemas/schemas
|
/packages/asset-swapper/test/generated-artifacts
|
||||||
/python-packages/json_schemas/src/zero_ex/json_schemas/schemas
|
/packages/asset-swapper/test/generated-wrappers
|
||||||
/packages/sra-spec/public/
|
|
||||||
package.json
|
package.json
|
||||||
scripts/postpublish_utils.js
|
|
||||||
packages/sol-coverage/test/fixtures/artifacts
|
|
||||||
.pytest_cache
|
|
||||||
.mypy_cache
|
|
||||||
.tox
|
|
||||||
packages/abi-gen/test-cli/fixtures/artifacts/AbiGenDummy.json
|
|
||||||
packages/abi-gen/test-cli/fixtures/artifacts/LibDummy.json
|
|
||||||
packages/abi-gen/test-cli/fixtures/artifacts/TestLibDummy.json
|
|
||||||
packages/*/docs
|
packages/*/docs
|
||||||
|
docs/
|
||||||
|
*.sol
|
||||||
|
|||||||
@@ -2,5 +2,7 @@
|
|||||||
"printWidth": 120,
|
"printWidth": 120,
|
||||||
"tabWidth": 4,
|
"tabWidth": 4,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"trailingComma": "all"
|
"trailingComma": "all",
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"arrowParens": "avoid"
|
||||||
}
|
}
|
||||||
|
|||||||
23
.readthedocs.yaml
Normal file
23
.readthedocs.yaml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Read the Docs configuration file
|
||||||
|
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||||
|
|
||||||
|
# Required
|
||||||
|
version: 2
|
||||||
|
|
||||||
|
# Build documentation in the docs/ directory with Sphinx
|
||||||
|
sphinx:
|
||||||
|
configuration: docs/conf.py
|
||||||
|
|
||||||
|
# Build documentation with MkDocs
|
||||||
|
#mkdocs:
|
||||||
|
# configuration: mkdocs.yml
|
||||||
|
|
||||||
|
# Optionally build your docs in additional formats such as PDF
|
||||||
|
#formats:
|
||||||
|
# - pdf
|
||||||
|
|
||||||
|
# Optionally set the version of Python and requirements required to build your docs
|
||||||
|
python:
|
||||||
|
version: 3.7
|
||||||
|
install:
|
||||||
|
- requirements: docs/requirements.txt
|
||||||
34
CODEOWNERS
34
CODEOWNERS
@@ -5,34 +5,14 @@
|
|||||||
# https://git-scm.com/docs/gitignore#_pattern_format
|
# https://git-scm.com/docs/gitignore#_pattern_format
|
||||||
|
|
||||||
# Website
|
# Website
|
||||||
packages/asset-buyer/ @BMillman19 @fragosti @steveklebanoff
|
packages/asset-swapper/ @BMillman19 @fragosti @dave4506
|
||||||
packages/instant/ @BMillman19 @fragosti @steveklebanoff
|
packages/instant/ @BMillman19 @fragosti @dave4506
|
||||||
|
|
||||||
# Dev tools & setup
|
# Dev tools & setup
|
||||||
.circleci/ @LogvinovLeon
|
.circleci/ @dorothy-zbornak
|
||||||
packages/abi-gen/ @feuGeneA
|
packages/contract-addresses/ @abandeali1
|
||||||
packages/base-contract/ @xianny
|
packages/contract-artifacts/ @abandeali1
|
||||||
packages/connect/ @fragosti
|
packages/order-utils/ @dorothy-zbornak
|
||||||
packages/abi-gen-templates/ @feuGeneA @xianny
|
|
||||||
packages/contract-addresses/ @albrow
|
|
||||||
packages/contract-artifacts/ @albrow
|
|
||||||
packages/dev-utils/ @LogvinovLeon @fabioberger
|
|
||||||
packages/devnet/ @albrow
|
|
||||||
packages/ethereum-types/ @LogvinovLeon
|
|
||||||
packages/monorepo-scripts/ @fabioberger
|
|
||||||
packages/order-utils/ @fabioberger @LogvinovLeon
|
|
||||||
packages/python-contract-wrappers/ @feuGeneA
|
|
||||||
packages/sol-compiler/ @LogvinovLeon
|
|
||||||
packages/sol-coverage/ @LogvinovLeon
|
|
||||||
packages/sol-profiler/ @LogvinovLeon
|
|
||||||
packages/sol-trace/ @LogvinovLeon
|
|
||||||
packages/sol-tracing-utils/ @LogvinovLeon
|
|
||||||
packages/sol-resolver/ @LogvinovLeon
|
|
||||||
packages/subproviders/ @fabioberger @dekz
|
|
||||||
packages/verdaccio/ @albrow
|
|
||||||
packages/web3-wrapper/ @LogvinovLeon @fabioberger
|
|
||||||
python-packages/ @feuGeneA
|
|
||||||
packages/utils/ @hysz
|
|
||||||
|
|
||||||
# Protocol/smart contracts
|
# Protocol/smart contracts
|
||||||
contracts/ @abandeali1 @hysz
|
contracts/ @abandeali1 @hysz @dorothy-zbornak @mzhu25
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ We welcome contributions from anyone on the internet and are grateful for even t
|
|||||||
|
|
||||||
### Getting started
|
### Getting started
|
||||||
|
|
||||||
1. Fork `0xproject/0x-monorepo`
|
1. Fork `0xproject/0x-tools`
|
||||||
2. Clone your fork
|
2. Clone your fork
|
||||||
3. Follow the [installation & build steps](https://github.com/0xProject/0x-monorepo#install-dependencies) in the repo's top-level README.
|
3. Follow the [installation & build steps](https://github.com/0xProject/0x-tools#install-dependencies) in the repo's top-level README.
|
||||||
4. Setup the recommended [Development Tooling](#development-tooling).
|
4. Setup the recommended [Development Tooling](#development-tooling).
|
||||||
5. Open a PR with the `[WIP]` flag against the `development` branch and describe the change you are intending to undertake in the PR description. (see [our branch naming conventions](#branch-structure))
|
5. Open a PR with the `[WIP]` flag against the `development` branch and describe the change you are intending to undertake in the PR description. (see [our branch naming conventions](#branch-structure))
|
||||||
|
|
||||||
@@ -59,11 +59,11 @@ We strongly recommend you use the [VSCode](https://code.visualstudio.com/) text
|
|||||||
|
|
||||||
#### Linter
|
#### Linter
|
||||||
|
|
||||||
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.
|
We use [TSLint](https://palantir.github.io/tslint/) with [custom configs](https://github.com/0xProject/0x-tools/tree/development/packages/tslint-config) to keep our code-style consistent.
|
||||||
|
|
||||||
Use `yarn:lint` to lint the entire monorepo, and `PKG={PACKAGE_NAME} yarn lint` to lint a specific package.
|
Use `yarn:lint` to lint the entire monorepo, and `PKG={PACKAGE_NAME} yarn lint` to lint a specific package.
|
||||||
|
|
||||||
If you want to change a rule, or add a custom rule, please make these changes to our [tslint-config](https://github.com/0xProject/0x-monorepo/tree/development/packages/tslint-config) package. All other packages have it as a dependency.
|
If you want to change a rule, or add a custom rule, please make these changes to our [tslint-config](https://github.com/0xProject/0x-tools/tree/development/packages/tslint-config) package. All other packages have it as a dependency.
|
||||||
|
|
||||||
Integrate it into your text editor:
|
Integrate it into your text editor:
|
||||||
|
|
||||||
@@ -94,12 +94,12 @@ A few of our coding conventions are not yet enforced by the linter/auto-formatte
|
|||||||
|
|
||||||
### Fix `submit-coverage` CI failure
|
### Fix `submit-coverage` CI failure
|
||||||
|
|
||||||
If you simply fork the repo and then create a PR from it, your PR will fail the `submit-coverage` check on CI. 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 your repo's name `your-username/0x-monorepo`.
|
If you simply fork the repo and then create a PR from it, your PR will fail the `submit-coverage` check on CI. This is because the 0x CircleCI configuration sets the `COVERALLS_REPO_TOKEN` environment variable to the token for `0xProject/0x-tools`, but when running the check against your fork the token needs to match your repo's name `your-username/0x-tools`.
|
||||||
|
|
||||||
To facilitate this check, after creating your fork, but before creating the branch for your PR, do the following:
|
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.
|
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.)
|
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-tools, 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.
|
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.
|
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.
|
||||||
|
|||||||
@@ -49,7 +49,6 @@
|
|||||||
| Package | Version |
|
| Package | Version |
|
||||||
| ------: | :------ |
|
| ------: | :------ |
|
||||||
|
|
||||||
|
|
||||||
<!-- For example:
|
<!-- For example:
|
||||||
| `0x.js` | 2.0.4 |
|
| `0x.js` | 2.0.4 |
|
||||||
| `Exchange Contract` | v2 |
|
| `Exchange Contract` | v2 |
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
Copyright 2017 ZeroEx Intl.
|
Copyright 2020 ZeroEx Labs
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
107
README.md
107
README.md
@@ -2,103 +2,44 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
[0x][website-url] is an open protocol that facilitates trustless, low friction exchange of Ethereum-based assets. For more information on how it works, check out the [0x protocol specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
|
[0x][website-url] is an open protocol that facilitates trustless, low friction exchange of Ethereum-based assets. For more information on how it works, check out the [0x protocol specification](https://protocol.0x.org/).
|
||||||
|
|
||||||
This repository is a monorepo including the 0x protocol smart contracts and numerous developer tools. Each public sub-package is independently published to NPM.
|
This repository is a monorepo including the 0x protocol smart contracts and numerous developer tools. Each public sub-package is independently published to NPM.
|
||||||
|
|
||||||
[website-url]: https://0x.org
|
[website-url]: https://0x.org
|
||||||
|
|
||||||
[](https://circleci.com/gh/0xProject/0x-monorepo)
|
[](https://circleci.com/gh/0xProject/protocool)
|
||||||
[](https://coveralls.io/github/0xProject/0x-monorepo?branch=development)
|
[](https://coveralls.io/github/0xProject/0x-monorepo?branch=development)
|
||||||
[](https://discordapp.com/invite/d3FTX3M)
|
[](https://discordapp.com/invite/d3FTX3M)
|
||||||
[](https://opensource.org/licenses/Apache-2.0)
|
[](https://opensource.org/licenses/Apache-2.0)
|
||||||
|
|
||||||
## Packages
|
## Packages
|
||||||
|
|
||||||
Visit our [developer portal](https://0x.org/docs/tools/order-utils) for a comprehensive list of core & community maintained packages. All packages maintained with this monorepo are listed below.
|
Visit our [developer portal](https://0x.org/docs/) for a comprehensive list of core & community maintained packages. All packages maintained with this monorepo are listed below.
|
||||||
|
|
||||||
### Python Packages
|
|
||||||
|
|
||||||
| Package | Version | Description |
|
|
||||||
| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
||||||
| [`0x-contract-addresses`](/python-packages/contract_addresses) | [](https://pypi.org/project/0x-contract-addresses/) | A tiny utility library for getting known deployed contract addresses for a particular network |
|
|
||||||
| [`0x-contract-artifacts`](/python-packages/contract_artifacts) | [](https://pypi.org/project/0x-contract-artifacts/) | 0x smart contract compilation artifacts |
|
|
||||||
| [`0x-contract-wrappers`](/python-packages/contract_wrappers) | [](https://pypi.org/project/0x-contract-wrappers/) | 0x smart contract wrappers |
|
|
||||||
| [`0x-json-schemas`](/python-packages/json_schemas) | [](https://pypi.org/project/0x-json-schemas/) | 0x-related JSON schemas |
|
|
||||||
| [`0x-order-utils`](/python-packages/order_utils) | [](https://pypi.org/project/0x-order-utils/) | A set of utilities for generating, parsing, signing and validating 0x orders |
|
|
||||||
| [`0x-sra-client`](/python-packages/sra_client) | [](https://pypi.org/project/0x-sra-client/) | A Python client for interacting with servers conforming to the Standard Relayer API specification |
|
|
||||||
|
|
||||||
### Solidity Packages
|
### Solidity Packages
|
||||||
|
|
||||||
These packages are all under development. See [/contracts/README.md](/contracts/README.md) for a list of deployed packages.
|
These packages are all under development. See [/contracts/README.md](/contracts/README.md) for a list of deployed packages.
|
||||||
|
|
||||||
| Package | Version | Description |
|
| Package | Version | Description |
|
||||||
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
||||||
| [`@0x/contracts-asset-proxy`](/contracts/asset-proxy) | [](https://www.npmjs.com/package/@0x/contracts-asset-proxy) | [`AssetProxy`](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#assetproxy) contracts used within the protocol |
|
| [`@0x/contracts-zero-ex`](/contracts/zero-ex) | [](https://www.npmjs.com/package/@0x/contracts-zero-ex) | The contracts used for settling trades within the protocol |
|
||||||
| [`@0x/contracts-erc20`](/contracts/erc20) | [](https://www.npmjs.com/package/@0x/contracts-erc20) | Implementations of various ERC20 tokens |
|
| [`@0x/contracts-erc20`](/contracts/erc20) | [](https://www.npmjs.com/package/@0x/contracts-erc20) | Implementations of various ERC20 tokens |
|
||||||
| [`@0x/contracts-erc721`](/contracts/erc721) | [](https://www.npmjs.com/package/@0x/contracts-erc721) | Implementations of various ERC721 tokens |
|
| [`@0x/contracts-test-utils`](/contracts/test-utils) | [](https://www.npmjs.com/package/@0x/contracts-test-utils) | TypeScript/Javascript shared utilities used for testing contracts |
|
||||||
| [`@0x/contracts-erc1155`](/contracts/erc1155) | [](https://www.npmjs.com/package/@0x/contracts-erc1155) | Implementations of various ERC1155 tokens |
|
| [`@0x/contracts-utils`](/contracts/utils) | [](https://www.npmjs.com/package/@0x/contracts-utils) | Generic libraries and utilities used throughout all of the contracts |
|
||||||
| [`@0x/contracts-exchange`](/contracts/exchange) | [](https://www.npmjs.com/package/@0x/contracts-exchange) | The [`Exchange`](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#exchange) contract used for settling trades within the protocol |
|
|
||||||
| [`@0x/contracts-exchange-forwarder`](/contracts/exchange-forwarder) | [](https://www.npmjs.com/package/@0x/contracts-exchange-forwarder) | A [`Forwarder`](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md) contract used to simplify UX for interacting with the protocol |
|
|
||||||
| [`@0x/contracts-exchange-libs`](/contracts/exchange-libs) | [](https://www.npmjs.com/package/@0x/contracts-exchange-libs) | Protocol specific libraries used within the [`Exchange`](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#exchange) contract |
|
|
||||||
| [`@0x/contracts-extensions`](/contracts/extensions) | [](https://www.npmjs.com/package/@0x/contracts-extensions) | Contracts that interact with and extend the functionality of the core protocol |
|
|
||||||
| [`@0x/contracts-multisig`](/contracts/multisig) | [](https://www.npmjs.com/package/@0x/contracts-multisig) | Various implementations of multisignature wallets, including the [`AssetProxyOwner`](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#assetproxyowner) contract that has permissions to upgrade the protocol |
|
|
||||||
| [`@0x/contracts-test-utils`](/contracts/test-utils) | [](https://www.npmjs.com/package/@0x/contracts-test-utils) | TypeScript/Javascript shared utilities used for testing contracts |
|
|
||||||
| [`@0x/contracts-utils`](/contracts/utils) | [](https://www.npmjs.com/package/@0x/contracts-utils) | Generic libraries and utilities used throughout all of the contracts |
|
|
||||||
| [`@0x/contracts-coordinator`](/contracts/coordinator) | [](https://www.npmjs.com/package/@0x/contracts-coordinator) | A contract that allows users to execute 0x transactions with permission from a Coordinator |
|
|
||||||
| [`@0x/contracts-dev-utils`](/contracts/dev-utils) | [](https://www.npmjs.com/package/@0x/contracts-dev-utils) | A contract contains utility functions for developers (such as validating many orders using a single eth_call) |
|
|
||||||
| [`@0x/contracts-staking`](/contracts/staking) | [](https://www.npmjs.com/package/@0x/contracts-staking) | Implements the stake-based liquidity incentives defined by [`ZEIP-31`](https://github.com/0xProject/ZEIPs/issues/31) |
|
|
||||||
|
|
||||||
### TypeScript/Javascript Packages
|
### TypeScript/Javascript Packages
|
||||||
|
|
||||||
#### 0x-specific packages
|
#### 0x-specific packages
|
||||||
|
|
||||||
| Package | Version | Description |
|
| Package | Version | Description |
|
||||||
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
||||||
| [`0x.js`](/packages/0x.js) | [](https://www.npmjs.com/package/0x.js) | An aggregate package combining many smaller utility packages for interacting with the 0x protocol |
|
| [`@0x/asset-swapper`](/packages/asset-swapper) | [](https://www.npmjs.com/package/@0x/asset-swapper) | Package used to find and create aggregated swaps |
|
||||||
| [`@0x/contract-addresses`](/packages/contract-addresses) | [](https://www.npmjs.com/package/@0x/contract-addresses) | A tiny utility library for getting known deployed contract addresses for a particular network. |
|
| [`@0x/protocol-utils`](/packages/protocol-utils) | [](https://www.npmjs.com/package/@0x/protocol-utils) | A set of utilities for generating, parsing, signing and validating 0x orders |
|
||||||
| [`@0x/contract-wrappers`](/packages/contract-wrappers) | [](https://www.npmjs.com/package/@0x/contract-wrappers) | JS/TS wrappers for interacting with the 0x smart contracts |
|
| [`@0x/contract-addresses`](/packages/contract-addresses) | [](https://www.npmjs.com/package/@0x/contract-addresses) | A tiny utility library for getting known deployed contract addresses for a particular network. |
|
||||||
| [`@0x/order-utils`](/packages/order-utils) | [](https://www.npmjs.com/package/@0x/order-utils) | A set of utilities for generating, parsing, signing and validating 0x orders |
|
| [`@0x/contract-wrappers`](/packages/contract-wrappers) | [](https://www.npmjs.com/package/@0x/contract-wrappers) | JS/TS wrappers for interacting with the 0x smart contracts |
|
||||||
| [`@0x/json-schemas`](/packages/json-schemas) | [](https://www.npmjs.com/package/@0x/json-schemas) | 0x-related JSON schemas | |
|
| [`@0x/migrations`](/packages/migrations) | [](https://www.npmjs.com/package/@0x/migrations) | Migration tool for deploying 0x smart contracts on private testnets |
|
||||||
| [`@0x/migrations`](/packages/migrations) | [](https://www.npmjs.com/package/@0x/migrations) | Migration tool for deploying 0x smart contracts on private testnets |
|
| [`@0x/contract-artifacts`](/packages/contract-artifacts) | [](https://www.npmjs.com/package/@0x/contract-artifacts) | 0x smart contract compilation artifacts | |
|
||||||
| [`@0x/contract-artifacts`](/packages/contract-artifacts) | [](https://www.npmjs.com/package/@0x/contract-artifacts) | 0x smart contract compilation artifacts |
|
|
||||||
| [`@0x/abi-gen-wrappers`](/packages/abi-gen-wrappers) | [](https://www.npmjs.com/package/@0x/abi-gen-wrappers) | Low-level 0x smart contract wrappers generated using `@0x/abi-gen` |
|
|
||||||
| [`@0x/sra-spec`](/packages/sra-spec) | [](https://www.npmjs.com/package/@0x/sra-spec) | OpenAPI specification for the Standard Relayer API |
|
|
||||||
| [`@0x/connect`](/packages/connect) | [](https://www.npmjs.com/package/@0x/connect) | An HTTP/WS client for interacting with the Standard Relayer API |
|
|
||||||
| [`@0x/asset-buyer`](/packages/asset-buyer) | [](https://www.npmjs.com/package/@0x/asset-buyer) | Convenience package for discovering and buying assets with Ether |
|
|
||||||
| [`@0x/asset-swapper`](/packages/asset-swapper) | [](https://www.npmjs.com/package/@0x/asset-swapper) | Convenience package for discovering and performing swaps for any ERC20 Assets |
|
|
||||||
|
|
||||||
#### Ethereum tooling
|
|
||||||
|
|
||||||
| Package | Version | Description |
|
|
||||||
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| [`@0x/web3-wrapper`](/packages/web3-wrapper) | [](https://www.npmjs.com/package/@0x/web3-wrapper) | An Ethereum JSON RPC client |
|
|
||||||
| [`@0x/sol-compiler`](/packages/sol-compiler) | [](https://www.npmjs.com/package/@0x/sol-compiler) | A wrapper around solc-js that adds smart re-compilation, ability to compile an entire project, Solidity version specific compilation, standard input description support and much more. |
|
|
||||||
| [`@0x/sol-coverage`](/packages/sol-coverage) | [](https://www.npmjs.com/package/@0x/sol-coverage) | A solidity test coverage tool |
|
|
||||||
| [`@0x/sol-profiler`](/packages/sol-profiler) | [](https://www.npmjs.com/package/@0x/sol-profiler) | A solidity gas cost profiler |
|
|
||||||
| [`@0x/sol-trace`](/packages/sol-trace) | [](https://www.npmjs.com/package/@0x/sol-trace) | A solidity stack trace tool |
|
|
||||||
| [`@0x/sol-resolver`](/packages/sol-resolver) | [](https://www.npmjs.com/package/@0x/sol-resolver) | Import resolver for smart contracts dependencies |
|
|
||||||
| [`@0x/subproviders`](/packages/subproviders) | [](https://www.npmjs.com/package/@0x/subproviders) | Web3 provider middlewares (e.g. LedgerSubprovider) |
|
|
||||||
| [`@0x/sol-doc`](/packages/sol-doc) | [](https://www.npmjs.com/package/@0x/sol-doc) | Solidity documentation generator |
|
|
||||||
|
|
||||||
#### Utilities
|
|
||||||
|
|
||||||
| Package | Version | Description |
|
|
||||||
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
|
|
||||||
| [`@0x/abi-gen`](/packages/abi-gen) | [](https://www.npmjs.com/package/@0x/abi-gen) | Tool to generate TS wrappers from smart contract ABIs |
|
|
||||||
| [`@0x/tslint-config`](/packages/tslint-config) | [](https://www.npmjs.com/package/@0x/tslint-config) | Custom TSLint rules used by the 0x core team |
|
|
||||||
| [`@0x/types`](/packages/types) | [](https://www.npmjs.com/package/@0x/types) | Shared type declarations |
|
|
||||||
| [`@0x/typescript-typings`](/packages/typescript-typings) | [](https://www.npmjs.com/package/@0x/typescript-typings) | Repository of types for external packages |
|
|
||||||
| [`@0x/utils`](/packages/utils) | [](https://www.npmjs.com/package/@0x/utils) | Shared utilities |
|
|
||||||
| [`@0x/assert`](/packages/assert) | [](https://www.npmjs.com/package/@0x/assert) | Type and schema assertions used by our packages |
|
|
||||||
| [`@0x/base-contract`](/packages/base-contract) | [](https://www.npmjs.com/package/@0x/base-contract) | BaseContract used by auto-generated `abi-gen` wrapper contracts |
|
|
||||||
| [`@0x/dev-utils`](/packages/dev-utils) | [](https://www.npmjs.com/package/@0x/dev-utils) | Dev utils to be shared across 0x packages |
|
|
||||||
|
|
||||||
#### Private Packages
|
|
||||||
|
|
||||||
| Package | Description |
|
|
||||||
| ---------------------------------- | -------------------------------------------------------------------------------- |
|
|
||||||
| [`@0x/instant`](/packages/instant) | A free and flexible way to offer simple crypto purchasing in any app or website. |
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -131,8 +72,6 @@ Then install dependencies
|
|||||||
yarn install
|
yarn install
|
||||||
```
|
```
|
||||||
|
|
||||||
You will also need to have Python 3 installed, in order to build and run the tests of `abi-gen`'s command-line interface, which is integrated with the yarn build, yarn test, and yarn lint commands described below. More specifically, your local pip should resolve to the Python 3 version of pip, not a Python 2.x version.
|
|
||||||
|
|
||||||
### Build
|
### Build
|
||||||
|
|
||||||
To build all packages:
|
To build all packages:
|
||||||
@@ -144,7 +83,7 @@ yarn build
|
|||||||
To build a specific package:
|
To build a specific package:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
PKG=@0x/web3-wrapper yarn build
|
PKG=@0x/asset-swapper yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
To build all contracts packages:
|
To build all contracts packages:
|
||||||
@@ -167,7 +106,7 @@ To watch a specific package and all it's dependent packages:
|
|||||||
PKG=[NPM_PACKAGE_NAME] yarn watch
|
PKG=[NPM_PACKAGE_NAME] yarn watch
|
||||||
|
|
||||||
e.g
|
e.g
|
||||||
PKG=@0x/web3-wrapper yarn watch
|
PKG=@0x/asset-swapper yarn watch
|
||||||
```
|
```
|
||||||
|
|
||||||
### Clean
|
### Clean
|
||||||
@@ -181,7 +120,7 @@ yarn clean
|
|||||||
Clean a specific package
|
Clean a specific package
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
PKG=0x.js yarn clean
|
PKG=@0x/asset-swapper yarn clean
|
||||||
```
|
```
|
||||||
|
|
||||||
### Rebuild
|
### Rebuild
|
||||||
@@ -195,7 +134,7 @@ yarn rebuild
|
|||||||
To re-build (clean & build) a specific package & it's deps:
|
To re-build (clean & build) a specific package & it's deps:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
PKG=0x.js yarn rebuild
|
PKG=@0x/asset-swapper yarn rebuild
|
||||||
```
|
```
|
||||||
|
|
||||||
### Lint
|
### Lint
|
||||||
@@ -209,7 +148,7 @@ yarn lint
|
|||||||
Lint a specific package:
|
Lint a specific package:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
PKG=0x.js yarn lint
|
PKG=@0x/asset-swapper yarn lint
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run Tests
|
### Run Tests
|
||||||
@@ -223,7 +162,7 @@ yarn test
|
|||||||
Run a specific package's test:
|
Run a specific package's test:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
PKG=@0x/web3-wrapper yarn test
|
PKG=@0x/asset-swapper yarn test
|
||||||
```
|
```
|
||||||
|
|
||||||
Run all contracts packages tests:
|
Run all contracts packages tests:
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"quotes": ["error", "double"],
|
"quotes": ["error", "double"],
|
||||||
"separate-by-one-line-in-contract": "error",
|
"separate-by-one-line-in-contract": "error",
|
||||||
"space-after-comma": "error",
|
"space-after-comma": "error",
|
||||||
"statement-indent": "error"
|
"statement-indent": "error",
|
||||||
|
"no-empty-blocks": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
#### Deployed Contract Packages
|
|
||||||
|
|
||||||
| Contract | Package | Version | Git Tag |
|
|
||||||
| --------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| AssetProxyOwner | [`@0x/contracts-multisig`](/contracts/multisig) | [v1.0.2](https://www.npmjs.com/package/@0x/contracts-multisig/v/1.0.2) | [@0x/contracts-multisig@1.0.2](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-multisig@1.0.2) |
|
|
||||||
| ERC20Proxy | [`@0x/contracts-asset-proxy`](/contracts/asset-proxy) | [v1.0.1](https://www.npmjs.com/package/@0x/contracts-asset-proxy/v/1.0.1) | [@0x/contracts-asset-proxy@1.0.1](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-asset-proxy@1.0.1) |
|
|
||||||
| ERC721Proxy | [`@0x/contracts-asset-proxy`](/contracts/asset-proxy) | [v1.0.1](https://www.npmjs.com/package/@0x/contracts-asset-proxy/v/1.0.1) | [@0x/contracts-asset-proxy@1.0.1](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-asset-proxy@1.0.1) |
|
|
||||||
| Exchange | [`@0x/contracts-exchange`](/contracts/exchange) | [v1.0.1](https://www.npmjs.com/package/@0x/contracts-exchange/v/1.0.1) | [@0x/contracts-exchange@1.0.1](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-exchange@1.0.1) |
|
|
||||||
| DutchAuction | [`@0x/contracts-extensions`](/contracts/extensions) | [v1.0.2](https://www.npmjs.com/package/@0x/contracts-extensions/v/1.0.2) | [@0x/contracts-extensions@1.0.2](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-extensions@1.0.2) |
|
|
||||||
| Forwarder | [`@0x/contracts-exchange-forwarder`](/contracts/exchange-forwarder) | [v1.0.1](https://www.npmjs.com/package/@0x/contracts-exchange-forwarder/v/1.0.1) | [@0x/contracts-exchange-forwarder@1.0.1](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-exchange-forwarder@1.0.1) |
|
|
||||||
| MultiAssetProxy | [`@0x/contracts-asset-proxy`](/contracts/asset-proxy) | [v1.0.1](https://www.npmjs.com/package/@0x/contracts-asset-proxy/v/1.0.1) | [@0x/contracts-asset-proxy@1.0.1](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-asset-proxy@1.0.1) |
|
|
||||||
| ZRXToken | [`@0x/contracts-erc20`](/contracts/erc20) | [v1.0.1](https://www.npmjs.com/package/@0x/contracts-erc20/v/1.0.1) | [@0x/contracts-erc20@1.0.1](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-erc20@1.0.1) |
|
|
||||||
|
|
||||||
#### Development
|
#### Development
|
||||||
|
|
||||||
Building solidity files will update the contract artifact in `{package-name}/generated-artifacts/{contract}.json`, but does not automatically update the `abi-gen-wrappers` package, which are generated from the artifact JSON. To ensure consistency, clean and rebuild `abi-gen-wrappers` after any changes to the artifact JSON.
|
Building solidity files will update the contract artifact in `{package-name}/generated-artifacts/{contract}.json`, but does not automatically update the `contract-artifacts` or `contract-wrappers` packages, which are generated from the artifact JSON. See `contract-artifacts/README.md` for instructions on updating these packages.
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
# Contracts testing options
|
|
||||||
|
|
||||||
## Revert stack traces
|
|
||||||
|
|
||||||
If you want to see helpful stack traces (incl. line number, code snippet) for smart contract reverts, run the tests with:
|
|
||||||
|
|
||||||
```
|
|
||||||
yarn test:trace
|
|
||||||
```
|
|
||||||
|
|
||||||
**Note:** This currently slows down the test runs and is therefore not enabled by default.
|
|
||||||
|
|
||||||
## Backing Ethereum node
|
|
||||||
|
|
||||||
By default, our tests run against an in-process [Ganache](https://github.com/trufflesuite/ganache-core) instance. In order to run the tests against [Geth](https://github.com/ethereum/go-ethereum), first follow the instructions in the README for the devnet package to start the devnet Geth node. Then run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
TEST_PROVIDER=geth yarn test
|
|
||||||
```
|
|
||||||
|
|
||||||
## Code coverage
|
|
||||||
|
|
||||||
In order to see the Solidity code coverage output generated by `@0x/sol-coverage`, run:
|
|
||||||
|
|
||||||
```
|
|
||||||
yarn test:coverage
|
|
||||||
```
|
|
||||||
|
|
||||||
## Gas profiler
|
|
||||||
|
|
||||||
In order to profile the gas costs for a specific smart contract call/transaction, you can run the tests in `profiler` mode.
|
|
||||||
|
|
||||||
**Note:** Traces emitted by ganache have incorrect gas costs so we recommend using Geth for profiling.
|
|
||||||
|
|
||||||
```
|
|
||||||
TEST_PROVIDER=geth yarn test:profiler
|
|
||||||
```
|
|
||||||
|
|
||||||
You'll see a warning that you need to explicitly enable and disable the profiler before and after the block of code you want to profile.
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
import { profiler } from './utils/profiler';
|
|
||||||
profiler.start();
|
|
||||||
// Some call to a smart contract
|
|
||||||
profiler.stop();
|
|
||||||
```
|
|
||||||
|
|
||||||
Without explicitly starting and stopping the profiler, the profiler output will be too busy, and therefore unusable.
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# solhint can't parse `abi.decode` syntax.
|
|
||||||
contracts/src/ERC1155Proxy.sol
|
|
||||||
@@ -1,340 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"version": "2.3.0-beta.3",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1574238768
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.3.0-beta.2",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils",
|
|
||||||
"pr": 2330
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1574030254
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.3.0-beta.1",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "ERC20Wrapper and ERC1155ProxyWrapper constructors now require an instance of DevUtilsContract",
|
|
||||||
"pr": 2034
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1573159180
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.3.0-beta.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Disallow the zero address from being made an authorized address in MixinAuthorizable, and created an archive directory that includes an old version of Ownable",
|
|
||||||
"pr": 2019
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Remove `LibAssetProxyIds` contract",
|
|
||||||
"pr": 2055
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Compile and export all contracts, artifacts, and wrappers by default",
|
|
||||||
"pr": 2055
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Remove unused dependency on IAuthorizable in IAssetProxy",
|
|
||||||
"pr": 1910
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add `ERC20BridgeProxy`",
|
|
||||||
"pr": 2220
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add `Eth2DaiBridge`",
|
|
||||||
"pr": 2221
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add `UniswapBridge`",
|
|
||||||
"pr": 2233
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Replaced `SafeMath` with `LibSafeMath`",
|
|
||||||
"pr": 2254
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1570135330
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1568744790,
|
|
||||||
"version": "2.2.8",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1567521715,
|
|
||||||
"version": "2.2.7",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1566446343,
|
|
||||||
"version": "2.2.6",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1565296576,
|
|
||||||
"version": "2.2.5",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.2.4",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Updated calls to <contract wrapper>.deployFrom0xArtifactAsync to include artifact dependencies.",
|
|
||||||
"pr": 1995
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1564607468
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1563957393,
|
|
||||||
"version": "2.2.3",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1563193019,
|
|
||||||
"version": "2.2.2",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1563047529,
|
|
||||||
"version": "2.2.1",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.2.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Add `LibAssetProxyIds` contract",
|
|
||||||
"pr": 1835
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Updated ERC1155 Asset Proxy. Less optimization. More explicit handling of edge cases.",
|
|
||||||
"pr": 1852
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Implement StaticCallProxy",
|
|
||||||
"pr": 1863
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1563006338
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1558712885,
|
|
||||||
"version": "2.1.5",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1557961111,
|
|
||||||
"version": "2.1.4",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1557799313,
|
|
||||||
"version": "2.1.3",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.1.2",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Update tests to use contract-built-in `awaitTransactionSuccessAsync`",
|
|
||||||
"pr": 1797
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Make `ERC721Wrapper.setApprovalForAll()` take an owner address instead of a token ID",
|
|
||||||
"pr": 1819
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Automatically set unlimited proxy allowances in `ERC721.setBalancesAndAllowancesAsync()`",
|
|
||||||
"pr": 1819
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add `setProxyAllowanceForAllAsync()` to `ERC1155ProxyWrapper`.",
|
|
||||||
"pr": 1819
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1557507213
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.1.1",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1554997931
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.1.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Run Web3ProviderEngine without excess block polling",
|
|
||||||
"pr": 1695
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1553183790
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Do not reexport external dependencies",
|
|
||||||
"pr": 1682
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add ERC1155Proxy",
|
|
||||||
"pr": 1661
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Bumped solidity version to ^0.5.5",
|
|
||||||
"pr": 1701
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Integration testing for ERC1155Proxy",
|
|
||||||
"pr": 1673
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1553091633
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1551479279,
|
|
||||||
"version": "1.0.9",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1551299797,
|
|
||||||
"version": "1.0.8",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1551220833,
|
|
||||||
"version": "1.0.7",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1551130135,
|
|
||||||
"version": "1.0.6",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1549733923,
|
|
||||||
"version": "1.0.5",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "1.0.4",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1549547375
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "1.0.3",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Fake publish to enable pinning"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1549504360
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1549452781,
|
|
||||||
"version": "1.0.2",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1549373905,
|
|
||||||
"version": "1.0.1",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "1.0.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Move all AssetProxy contracts out of contracts-protocol to new package",
|
|
||||||
"pr": 1539
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
<!--
|
|
||||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
|
||||||
Edit the package's CHANGELOG.json file only.
|
|
||||||
-->
|
|
||||||
|
|
||||||
CHANGELOG
|
|
||||||
|
|
||||||
## v2.3.0-beta.3 - _November 20, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.3.0-beta.2 - _November 17, 2019_
|
|
||||||
|
|
||||||
* Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils (#2330)
|
|
||||||
|
|
||||||
## v2.3.0-beta.1 - _November 7, 2019_
|
|
||||||
|
|
||||||
* ERC20Wrapper and ERC1155ProxyWrapper constructors now require an instance of DevUtilsContract (#2034)
|
|
||||||
|
|
||||||
## v2.3.0-beta.0 - _October 3, 2019_
|
|
||||||
|
|
||||||
* Disallow the zero address from being made an authorized address in MixinAuthorizable, and created an archive directory that includes an old version of Ownable (#2019)
|
|
||||||
* Remove `LibAssetProxyIds` contract (#2055)
|
|
||||||
* Compile and export all contracts, artifacts, and wrappers by default (#2055)
|
|
||||||
* Remove unused dependency on IAuthorizable in IAssetProxy (#1910)
|
|
||||||
* Add `ERC20BridgeProxy` (#2220)
|
|
||||||
* Add `Eth2DaiBridge` (#2221)
|
|
||||||
* Add `UniswapBridge` (#2233)
|
|
||||||
* Replaced `SafeMath` with `LibSafeMath` (#2254)
|
|
||||||
|
|
||||||
## v2.2.8 - _September 17, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.2.7 - _September 3, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.2.6 - _August 22, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.2.5 - _August 8, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.2.4 - _July 31, 2019_
|
|
||||||
|
|
||||||
* Updated calls to <contract wrapper>.deployFrom0xArtifactAsync to include artifact dependencies. (#1995)
|
|
||||||
|
|
||||||
## v2.2.3 - _July 24, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.2.2 - _July 15, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.2.1 - _July 13, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.2.0 - _July 13, 2019_
|
|
||||||
|
|
||||||
* Add `LibAssetProxyIds` contract (#1835)
|
|
||||||
* Updated ERC1155 Asset Proxy. Less optimization. More explicit handling of edge cases. (#1852)
|
|
||||||
* Implement StaticCallProxy (#1863)
|
|
||||||
|
|
||||||
## v2.1.5 - _May 24, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.1.4 - _May 15, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.1.3 - _May 14, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.1.2 - _May 10, 2019_
|
|
||||||
|
|
||||||
* Update tests to use contract-built-in `awaitTransactionSuccessAsync` (#1797)
|
|
||||||
* Make `ERC721Wrapper.setApprovalForAll()` take an owner address instead of a token ID (#1819)
|
|
||||||
* Automatically set unlimited proxy allowances in `ERC721.setBalancesAndAllowancesAsync()` (#1819)
|
|
||||||
* Add `setProxyAllowanceForAllAsync()` to `ERC1155ProxyWrapper`. (#1819)
|
|
||||||
|
|
||||||
## v2.1.1 - _April 11, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.1.0 - _March 21, 2019_
|
|
||||||
|
|
||||||
* Run Web3ProviderEngine without excess block polling (#1695)
|
|
||||||
|
|
||||||
## v2.0.0 - _March 20, 2019_
|
|
||||||
|
|
||||||
* Do not reexport external dependencies (#1682)
|
|
||||||
* Add ERC1155Proxy (#1661)
|
|
||||||
* Bumped solidity version to ^0.5.5 (#1701)
|
|
||||||
* Integration testing for ERC1155Proxy (#1673)
|
|
||||||
|
|
||||||
## v1.0.9 - _March 1, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v1.0.8 - _February 27, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v1.0.7 - _February 26, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v1.0.6 - _February 25, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v1.0.5 - _February 9, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v1.0.4 - _February 7, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v1.0.3 - _February 7, 2019_
|
|
||||||
|
|
||||||
* Fake publish to enable pinning
|
|
||||||
|
|
||||||
## v1.0.2 - _February 6, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v1.0.1 - _February 5, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v1.0.0 - _Invalid date_
|
|
||||||
|
|
||||||
* Move all AssetProxy contracts out of contracts-protocol to new package (#1539)
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"name": "MultiAssetProxy",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Add MultiAssetProxy implementation",
|
|
||||||
"pr": 1224,
|
|
||||||
"networks": {
|
|
||||||
"3": "0xab8fbd189c569ccdee3a4d929bb7f557be4028f6",
|
|
||||||
"4": "0xb34cde0ad3a83d04abebc0b66e75196f22216621",
|
|
||||||
"42": "0xf6313a772c222f51c28f2304c0703b8cf5428fd8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ERC20Proxy",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "protocol v2 deploy",
|
|
||||||
"networks": {
|
|
||||||
"1": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
|
|
||||||
"3": "0xb1408f4c245a23c31b98d2c626777d4c0d766caa",
|
|
||||||
"4": "0x3e809c563c15a295e832e37053798ddc8d6c8dab",
|
|
||||||
"42": "0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ERC721Proxy",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "protocol v2 deploy",
|
|
||||||
"networks": {
|
|
||||||
"1": "0x208e41fb445f1bb1b6780d58356e81405f3e6127",
|
|
||||||
"3": "0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4",
|
|
||||||
"4": "0x8e1ff02637cb5e39f2fa36c14706aa348b065b09",
|
|
||||||
"42": "0x2a9127c745688a165106c11cd4d647d2220af821"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
## AssetProxy
|
|
||||||
|
|
||||||
This package contains the implementations of all of the [`AssetProxy`](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#assetproxy) contracts available within the 0x protocol. These contracts are responsible for decoding the `assetData` sent to them and performing the actual transfer of assets. Addresses of the deployed contracts can be found in this 0x [guide](https://0x.org/docs/guides/0x-cheat-sheet) or the [DEPLOYS](./DEPLOYS.json) file within this package.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
**Install**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install @0x/contracts-asset-proxy --save
|
|
||||||
```
|
|
||||||
|
|
||||||
## Bug bounty
|
|
||||||
|
|
||||||
A bug bounty for the 2.0.0 contracts is ongoing! Instructions can be found [here](https://0x.org/docs/guides/bug-bounty-program).
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein.
|
|
||||||
|
|
||||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
|
||||||
|
|
||||||
### Install Dependencies
|
|
||||||
|
|
||||||
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn config set workspaces-experimental true
|
|
||||||
```
|
|
||||||
|
|
||||||
Then install dependencies
|
|
||||||
|
|
||||||
```bash
|
|
||||||
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
|
|
||||||
PKG=@0x/contracts-asset-proxy yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
Or continuously rebuild on change:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
PKG=@0x/contracts-asset-proxy yarn watch
|
|
||||||
```
|
|
||||||
|
|
||||||
### Clean
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn clean
|
|
||||||
```
|
|
||||||
|
|
||||||
### Lint
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn lint
|
|
||||||
```
|
|
||||||
|
|
||||||
### Run Tests
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn test
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Testing options
|
|
||||||
|
|
||||||
Contracts testing options like coverage, profiling, revert traces or backing node choosing - are described [here](../TESTING.md).
|
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "../archive/Ownable.sol";
|
|
||||||
import "../src/interfaces/IAssetProxy.sol";
|
|
||||||
import "../src/interfaces/IAssetProxyDispatcher.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MixinAssetProxyDispatcher is
|
|
||||||
Ownable,
|
|
||||||
IAssetProxyDispatcher
|
|
||||||
{
|
|
||||||
// Mapping from Asset Proxy Id's to their respective Asset Proxy
|
|
||||||
mapping (bytes4 => address) public assetProxies;
|
|
||||||
|
|
||||||
/// @dev Registers an asset proxy to its asset proxy id.
|
|
||||||
/// Once an asset proxy is registered, it cannot be unregistered.
|
|
||||||
/// @param assetProxy Address of new asset proxy to register.
|
|
||||||
function registerAssetProxy(address assetProxy)
|
|
||||||
external
|
|
||||||
onlyOwner
|
|
||||||
{
|
|
||||||
// Ensure that no asset proxy exists with current id.
|
|
||||||
bytes4 assetProxyId = IAssetProxy(assetProxy).getProxyId();
|
|
||||||
address currentAssetProxy = assetProxies[assetProxyId];
|
|
||||||
require(
|
|
||||||
currentAssetProxy == address(0),
|
|
||||||
"ASSET_PROXY_ALREADY_EXISTS"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add asset proxy and log registration.
|
|
||||||
assetProxies[assetProxyId] = assetProxy;
|
|
||||||
emit AssetProxyRegistered(
|
|
||||||
assetProxyId,
|
|
||||||
assetProxy
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Gets an asset proxy.
|
|
||||||
/// @param assetProxyId Id of the asset proxy.
|
|
||||||
/// @return The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered.
|
|
||||||
function getAssetProxy(bytes4 assetProxyId)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (address)
|
|
||||||
{
|
|
||||||
return assetProxies[assetProxyId];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Forwards arguments to assetProxy and calls `transferFrom`. Either succeeds or throws.
|
|
||||||
/// @param assetData Byte array encoded for the asset.
|
|
||||||
/// @param from Address to transfer token from.
|
|
||||||
/// @param to Address to transfer token to.
|
|
||||||
/// @param amount Amount of token to transfer.
|
|
||||||
function _dispatchTransferFrom(
|
|
||||||
bytes memory assetData,
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
{
|
|
||||||
// Do nothing if no amount should be transferred.
|
|
||||||
if (amount > 0 && from != to) {
|
|
||||||
// Ensure assetData length is valid
|
|
||||||
require(
|
|
||||||
assetData.length > 3,
|
|
||||||
"LENGTH_GREATER_THAN_3_REQUIRED"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Lookup assetProxy. We do not use `LibBytes.readBytes4` for gas efficiency reasons.
|
|
||||||
bytes4 assetProxyId;
|
|
||||||
assembly {
|
|
||||||
assetProxyId := and(mload(
|
|
||||||
add(assetData, 32)),
|
|
||||||
0xFFFFFFFF00000000000000000000000000000000000000000000000000000000
|
|
||||||
)
|
|
||||||
}
|
|
||||||
address assetProxy = assetProxies[assetProxyId];
|
|
||||||
|
|
||||||
// Ensure that assetProxy exists
|
|
||||||
require(
|
|
||||||
assetProxy != address(0),
|
|
||||||
"ASSET_PROXY_DOES_NOT_EXIST"
|
|
||||||
);
|
|
||||||
|
|
||||||
// We construct calldata for the `assetProxy.transferFrom` ABI.
|
|
||||||
// The layout of this calldata is in the table below.
|
|
||||||
//
|
|
||||||
// | Area | Offset | Length | Contents |
|
|
||||||
// | -------- |--------|---------|-------------------------------------------- |
|
|
||||||
// | Header | 0 | 4 | function selector |
|
|
||||||
// | Params | | 4 * 32 | function parameters: |
|
|
||||||
// | | 4 | | 1. offset to assetData (*) |
|
|
||||||
// | | 36 | | 2. from |
|
|
||||||
// | | 68 | | 3. to |
|
|
||||||
// | | 100 | | 4. amount |
|
|
||||||
// | Data | | | assetData: |
|
|
||||||
// | | 132 | 32 | assetData Length |
|
|
||||||
// | | 164 | ** | assetData Contents |
|
|
||||||
|
|
||||||
assembly {
|
|
||||||
/////// Setup State ///////
|
|
||||||
// `cdStart` is the start of the calldata for `assetProxy.transferFrom` (equal to free memory ptr).
|
|
||||||
let cdStart := mload(64)
|
|
||||||
// `dataAreaLength` is the total number of words needed to store `assetData`
|
|
||||||
// As-per the ABI spec, this value is padded up to the nearest multiple of 32,
|
|
||||||
// and includes 32-bytes for length.
|
|
||||||
let dataAreaLength := and(add(mload(assetData), 63), 0xFFFFFFFFFFFE0)
|
|
||||||
// `cdEnd` is the end of the calldata for `assetProxy.transferFrom`.
|
|
||||||
let cdEnd := add(cdStart, add(132, dataAreaLength))
|
|
||||||
|
|
||||||
|
|
||||||
/////// Setup Header Area ///////
|
|
||||||
// This area holds the 4-byte `transferFromSelector`.
|
|
||||||
// bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4
|
|
||||||
mstore(cdStart, 0xa85e59e400000000000000000000000000000000000000000000000000000000)
|
|
||||||
|
|
||||||
/////// Setup Params Area ///////
|
|
||||||
// Each parameter is padded to 32-bytes. The entire Params Area is 128 bytes.
|
|
||||||
// Notes:
|
|
||||||
// 1. The offset to `assetData` is the length of the Params Area (128 bytes).
|
|
||||||
// 2. A 20-byte mask is applied to addresses to zero-out the unused bytes.
|
|
||||||
mstore(add(cdStart, 4), 128)
|
|
||||||
mstore(add(cdStart, 36), and(from, 0xffffffffffffffffffffffffffffffffffffffff))
|
|
||||||
mstore(add(cdStart, 68), and(to, 0xffffffffffffffffffffffffffffffffffffffff))
|
|
||||||
mstore(add(cdStart, 100), amount)
|
|
||||||
|
|
||||||
/////// Setup Data Area ///////
|
|
||||||
// This area holds `assetData`.
|
|
||||||
let dataArea := add(cdStart, 132)
|
|
||||||
// solhint-disable-next-line no-empty-blocks
|
|
||||||
for {} lt(dataArea, cdEnd) {} {
|
|
||||||
mstore(dataArea, mload(assetData))
|
|
||||||
dataArea := add(dataArea, 32)
|
|
||||||
assetData := add(assetData, 32)
|
|
||||||
}
|
|
||||||
|
|
||||||
/////// Call `assetProxy.transferFrom` using the constructed calldata ///////
|
|
||||||
let success := call(
|
|
||||||
gas, // forward all gas
|
|
||||||
assetProxy, // call address of asset proxy
|
|
||||||
0, // don't send any ETH
|
|
||||||
cdStart, // pointer to start of input
|
|
||||||
sub(cdEnd, cdStart), // length of input
|
|
||||||
cdStart, // write output over input
|
|
||||||
512 // reserve 512 bytes for output
|
|
||||||
)
|
|
||||||
if iszero(success) {
|
|
||||||
revert(cdStart, returndatasize())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "../archive/Ownable.sol";
|
|
||||||
import "../src/interfaces/IAuthorizable.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MixinAuthorizable is
|
|
||||||
Ownable,
|
|
||||||
IAuthorizable
|
|
||||||
{
|
|
||||||
/// @dev Only authorized addresses can invoke functions with this modifier.
|
|
||||||
modifier onlyAuthorized {
|
|
||||||
require(
|
|
||||||
authorized[msg.sender],
|
|
||||||
"SENDER_NOT_AUTHORIZED"
|
|
||||||
);
|
|
||||||
_;
|
|
||||||
}
|
|
||||||
|
|
||||||
mapping (address => bool) public authorized;
|
|
||||||
address[] public authorities;
|
|
||||||
|
|
||||||
/// @dev Authorizes an address.
|
|
||||||
/// @param target Address to authorize.
|
|
||||||
function addAuthorizedAddress(address target)
|
|
||||||
external
|
|
||||||
onlyOwner
|
|
||||||
{
|
|
||||||
require(
|
|
||||||
!authorized[target],
|
|
||||||
"TARGET_ALREADY_AUTHORIZED"
|
|
||||||
);
|
|
||||||
|
|
||||||
authorized[target] = true;
|
|
||||||
authorities.push(target);
|
|
||||||
emit AuthorizedAddressAdded(target, msg.sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Removes authorizion of an address.
|
|
||||||
/// @param target Address to remove authorization from.
|
|
||||||
function removeAuthorizedAddress(address target)
|
|
||||||
external
|
|
||||||
onlyOwner
|
|
||||||
{
|
|
||||||
require(
|
|
||||||
authorized[target],
|
|
||||||
"TARGET_NOT_AUTHORIZED"
|
|
||||||
);
|
|
||||||
|
|
||||||
delete authorized[target];
|
|
||||||
for (uint256 i = 0; i < authorities.length; i++) {
|
|
||||||
if (authorities[i] == target) {
|
|
||||||
authorities[i] = authorities[authorities.length - 1];
|
|
||||||
authorities.length -= 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit AuthorizedAddressRemoved(target, msg.sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Removes authorizion of an address.
|
|
||||||
/// @param target Address to remove authorization from.
|
|
||||||
/// @param index Index of target in authorities array.
|
|
||||||
function removeAuthorizedAddressAtIndex(
|
|
||||||
address target,
|
|
||||||
uint256 index
|
|
||||||
)
|
|
||||||
external
|
|
||||||
onlyOwner
|
|
||||||
{
|
|
||||||
require(
|
|
||||||
authorized[target],
|
|
||||||
"TARGET_NOT_AUTHORIZED"
|
|
||||||
);
|
|
||||||
require(
|
|
||||||
index < authorities.length,
|
|
||||||
"INDEX_OUT_OF_BOUNDS"
|
|
||||||
);
|
|
||||||
require(
|
|
||||||
authorities[index] == target,
|
|
||||||
"AUTHORIZED_ADDRESS_MISMATCH"
|
|
||||||
);
|
|
||||||
|
|
||||||
delete authorized[target];
|
|
||||||
authorities[index] = authorities[authorities.length - 1];
|
|
||||||
authorities.length -= 1;
|
|
||||||
emit AuthorizedAddressRemoved(target, msg.sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Gets all authorized addresses.
|
|
||||||
/// @return Array of authorized addresses.
|
|
||||||
function getAuthorizedAddresses()
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (address[] memory)
|
|
||||||
{
|
|
||||||
return authorities;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/interfaces/IOwnable.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract Ownable is
|
|
||||||
IOwnable
|
|
||||||
{
|
|
||||||
address public owner;
|
|
||||||
|
|
||||||
constructor ()
|
|
||||||
public
|
|
||||||
{
|
|
||||||
owner = msg.sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
modifier onlyOwner() {
|
|
||||||
require(
|
|
||||||
msg.sender == owner,
|
|
||||||
"ONLY_CONTRACT_OWNER"
|
|
||||||
);
|
|
||||||
_;
|
|
||||||
}
|
|
||||||
|
|
||||||
function transferOwnership(address newOwner)
|
|
||||||
public
|
|
||||||
onlyOwner
|
|
||||||
{
|
|
||||||
if (newOwner != address(0)) {
|
|
||||||
owner = newOwner;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
|
|
||||||
import "@0x/contracts-erc1155/contracts/src/interfaces/IERC1155.sol";
|
|
||||||
import "../archive/MixinAuthorizable.sol";
|
|
||||||
import "./interfaces/IAssetProxy.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract ERC1155Proxy is
|
|
||||||
MixinAuthorizable,
|
|
||||||
IAssetProxy
|
|
||||||
{
|
|
||||||
using LibBytes for bytes;
|
|
||||||
using LibSafeMath for uint256;
|
|
||||||
|
|
||||||
// Id of this proxy.
|
|
||||||
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC1155Assets(address,uint256[],uint256[],bytes)"));
|
|
||||||
|
|
||||||
/// @dev Transfers batch of ERC1155 assets. Either succeeds or throws.
|
|
||||||
/// @param assetData Byte array encoded with ERC1155 token address, array of ids, array of values, and callback data.
|
|
||||||
/// @param from Address to transfer assets from.
|
|
||||||
/// @param to Address to transfer assets to.
|
|
||||||
/// @param amount Amount that will be multiplied with each element of `assetData.values` to scale the
|
|
||||||
/// values that will be transferred.
|
|
||||||
function transferFrom(
|
|
||||||
bytes calldata assetData,
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
external
|
|
||||||
onlyAuthorized
|
|
||||||
{
|
|
||||||
// Decode params from `assetData`
|
|
||||||
// solhint-disable indent
|
|
||||||
(
|
|
||||||
address erc1155TokenAddress,
|
|
||||||
uint256[] memory ids,
|
|
||||||
uint256[] memory values,
|
|
||||||
bytes memory data
|
|
||||||
) = abi.decode(
|
|
||||||
assetData.sliceDestructive(4, assetData.length),
|
|
||||||
(address, uint256[], uint256[], bytes)
|
|
||||||
);
|
|
||||||
// solhint-enable indent
|
|
||||||
|
|
||||||
// Scale values up by `amount`
|
|
||||||
uint256 length = values.length;
|
|
||||||
uint256[] memory scaledValues = new uint256[](length);
|
|
||||||
for (uint256 i = 0; i != length; i++) {
|
|
||||||
// We write the scaled values to an unused location in memory in order
|
|
||||||
// to avoid copying over `ids` or `data`. This is possible if they are
|
|
||||||
// identical to `values` and the offsets for each are pointing to the
|
|
||||||
// same location in the ABI encoded calldata.
|
|
||||||
scaledValues[i] = values[i].safeMul(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute `safeBatchTransferFrom` call
|
|
||||||
// Either succeeds or throws
|
|
||||||
IERC1155(erc1155TokenAddress).safeBatchTransferFrom(
|
|
||||||
from,
|
|
||||||
to,
|
|
||||||
ids,
|
|
||||||
scaledValues,
|
|
||||||
data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Gets the proxy id associated with the proxy address.
|
|
||||||
/// @return Proxy id.
|
|
||||||
function getProxyId()
|
|
||||||
external
|
|
||||||
pure
|
|
||||||
returns (bytes4)
|
|
||||||
{
|
|
||||||
return PROXY_ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
|
|
||||||
import "@0x/contracts-utils/contracts/src/Authorizable.sol";
|
|
||||||
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
|
|
||||||
import "./interfaces/IAssetProxy.sol";
|
|
||||||
import "./interfaces/IERC20Bridge.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract ERC20BridgeProxy is
|
|
||||||
IAssetProxy,
|
|
||||||
Authorizable
|
|
||||||
{
|
|
||||||
using LibBytes for bytes;
|
|
||||||
using LibSafeMath for uint256;
|
|
||||||
|
|
||||||
// @dev Id of this proxy. Also the result of a successful bridge call.
|
|
||||||
// bytes4(keccak256("ERC20Bridge(address,address,bytes)"))
|
|
||||||
bytes4 constant private PROXY_ID = 0xdc1600f3;
|
|
||||||
|
|
||||||
/// @dev Calls a bridge contract to transfer `amount` of ERC20 from `from`
|
|
||||||
/// to `to`. Asserts that the balance of `to` has increased by `amount`.
|
|
||||||
/// @param assetData Abi-encoded data for this asset proxy encoded as:
|
|
||||||
/// abi.encodeWithSelector(
|
|
||||||
/// bytes4 PROXY_ID,
|
|
||||||
/// address tokenAddress,
|
|
||||||
/// address bridgeAddress,
|
|
||||||
/// bytes bridgeData
|
|
||||||
/// )
|
|
||||||
/// @param from Address to transfer asset from.
|
|
||||||
/// @param to Address to transfer asset to.
|
|
||||||
/// @param amount Amount of asset to transfer.
|
|
||||||
function transferFrom(
|
|
||||||
bytes calldata assetData,
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
external
|
|
||||||
onlyAuthorized
|
|
||||||
{
|
|
||||||
// Extract asset data fields.
|
|
||||||
(
|
|
||||||
address tokenAddress,
|
|
||||||
address bridgeAddress,
|
|
||||||
bytes memory bridgeData
|
|
||||||
) = abi.decode(
|
|
||||||
assetData.sliceDestructive(4, assetData.length),
|
|
||||||
(address, address, bytes)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Remember the balance of `to` before calling the bridge.
|
|
||||||
uint256 balanceBefore = balanceOf(tokenAddress, to);
|
|
||||||
// Call the bridge, who should transfer `amount` of `tokenAddress` to
|
|
||||||
// `to`.
|
|
||||||
bytes4 success = IERC20Bridge(bridgeAddress).bridgeTransferFrom(
|
|
||||||
tokenAddress,
|
|
||||||
from,
|
|
||||||
to,
|
|
||||||
amount,
|
|
||||||
bridgeData
|
|
||||||
);
|
|
||||||
// Bridge must return the proxy ID to indicate success.
|
|
||||||
require(success == PROXY_ID, "BRIDGE_FAILED");
|
|
||||||
// Ensure that the balance of `to` has increased by at least `amount`.
|
|
||||||
require(
|
|
||||||
balanceBefore.safeAdd(amount) <= balanceOf(tokenAddress, to),
|
|
||||||
"BRIDGE_UNDERPAY"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Gets the proxy id associated with this asset proxy.
|
|
||||||
/// @return proxyId The proxy id.
|
|
||||||
function getProxyId()
|
|
||||||
external
|
|
||||||
pure
|
|
||||||
returns (bytes4 proxyId)
|
|
||||||
{
|
|
||||||
return PROXY_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Retrieves the balance of `owner` for this asset.
|
|
||||||
/// @return balance The balance of the ERC20 token being transferred by this
|
|
||||||
/// asset proxy.
|
|
||||||
function balanceOf(bytes calldata assetData, address owner)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (uint256 balance)
|
|
||||||
{
|
|
||||||
(address tokenAddress) = abi.decode(
|
|
||||||
assetData.sliceDestructive(4, assetData.length),
|
|
||||||
(address)
|
|
||||||
);
|
|
||||||
return balanceOf(tokenAddress, owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Retrieves the balance of `owner` given an ERC20 address.
|
|
||||||
/// @return balance The balance of the ERC20 token for `owner`.
|
|
||||||
function balanceOf(address tokenAddress, address owner)
|
|
||||||
private
|
|
||||||
view
|
|
||||||
returns (uint256 balance)
|
|
||||||
{
|
|
||||||
return IERC20Token(tokenAddress).balanceOf(owner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "../archive/MixinAuthorizable.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract ERC20Proxy is
|
|
||||||
MixinAuthorizable
|
|
||||||
{
|
|
||||||
// Id of this proxy.
|
|
||||||
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC20Token(address)"));
|
|
||||||
|
|
||||||
// solhint-disable-next-line payable-fallback
|
|
||||||
function ()
|
|
||||||
external
|
|
||||||
{
|
|
||||||
assembly {
|
|
||||||
// The first 4 bytes of calldata holds the function selector
|
|
||||||
let selector := and(calldataload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000)
|
|
||||||
|
|
||||||
// `transferFrom` will be called with the following parameters:
|
|
||||||
// assetData Encoded byte array.
|
|
||||||
// from Address to transfer asset from.
|
|
||||||
// to Address to transfer asset to.
|
|
||||||
// amount Amount of asset to transfer.
|
|
||||||
// bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4
|
|
||||||
if eq(selector, 0xa85e59e400000000000000000000000000000000000000000000000000000000) {
|
|
||||||
|
|
||||||
// To lookup a value in a mapping, we load from the storage location keccak256(k, p),
|
|
||||||
// where k is the key left padded to 32 bytes and p is the storage slot
|
|
||||||
let start := mload(64)
|
|
||||||
mstore(start, and(caller, 0xffffffffffffffffffffffffffffffffffffffff))
|
|
||||||
mstore(add(start, 32), authorized_slot)
|
|
||||||
|
|
||||||
// Revert if authorized[msg.sender] == false
|
|
||||||
if iszero(sload(keccak256(start, 64))) {
|
|
||||||
// Revert with `Error("SENDER_NOT_AUTHORIZED")`
|
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(64, 0x0000001553454e4445525f4e4f545f415554484f52495a454400000000000000)
|
|
||||||
mstore(96, 0)
|
|
||||||
revert(0, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
// `transferFrom`.
|
|
||||||
// The function is marked `external`, so no abi decodeding is done for
|
|
||||||
// us. Instead, we expect the `calldata` memory to contain the
|
|
||||||
// following:
|
|
||||||
//
|
|
||||||
// | Area | Offset | Length | Contents |
|
|
||||||
// |----------|--------|---------|-------------------------------------|
|
|
||||||
// | Header | 0 | 4 | function selector |
|
|
||||||
// | Params | | 4 * 32 | function parameters: |
|
|
||||||
// | | 4 | | 1. offset to assetData (*) |
|
|
||||||
// | | 36 | | 2. from |
|
|
||||||
// | | 68 | | 3. to |
|
|
||||||
// | | 100 | | 4. amount |
|
|
||||||
// | Data | | | assetData: |
|
|
||||||
// | | 132 | 32 | assetData Length |
|
|
||||||
// | | 164 | ** | assetData Contents |
|
|
||||||
//
|
|
||||||
// (*): offset is computed from start of function parameters, so offset
|
|
||||||
// by an additional 4 bytes in the calldata.
|
|
||||||
//
|
|
||||||
// (**): see table below to compute length of assetData Contents
|
|
||||||
//
|
|
||||||
// WARNING: The ABIv2 specification allows additional padding between
|
|
||||||
// the Params and Data section. This will result in a larger
|
|
||||||
// offset to assetData.
|
|
||||||
|
|
||||||
// Asset data itself is encoded as follows:
|
|
||||||
//
|
|
||||||
// | Area | Offset | Length | Contents |
|
|
||||||
// |----------|--------|---------|-------------------------------------|
|
|
||||||
// | Header | 0 | 4 | function selector |
|
|
||||||
// | Params | | 1 * 32 | function parameters: |
|
|
||||||
// | | 4 | 12 + 20 | 1. token address |
|
|
||||||
|
|
||||||
// We construct calldata for the `token.transferFrom` ABI.
|
|
||||||
// The layout of this calldata is in the table below.
|
|
||||||
//
|
|
||||||
// | Area | Offset | Length | Contents |
|
|
||||||
// |----------|--------|---------|-------------------------------------|
|
|
||||||
// | Header | 0 | 4 | function selector |
|
|
||||||
// | Params | | 3 * 32 | function parameters: |
|
|
||||||
// | | 4 | | 1. from |
|
|
||||||
// | | 36 | | 2. to |
|
|
||||||
// | | 68 | | 3. amount |
|
|
||||||
|
|
||||||
/////// Read token address from calldata ///////
|
|
||||||
// * The token address is stored in `assetData`.
|
|
||||||
//
|
|
||||||
// * The "offset to assetData" is stored at offset 4 in the calldata (table 1).
|
|
||||||
// [assetDataOffsetFromParams = calldataload(4)]
|
|
||||||
//
|
|
||||||
// * Notes that the "offset to assetData" is relative to the "Params" area of calldata;
|
|
||||||
// add 4 bytes to account for the length of the "Header" area (table 1).
|
|
||||||
// [assetDataOffsetFromHeader = assetDataOffsetFromParams + 4]
|
|
||||||
//
|
|
||||||
// * The "token address" is offset 32+4=36 bytes into "assetData" (tables 1 & 2).
|
|
||||||
// [tokenOffset = assetDataOffsetFromHeader + 36 = calldataload(4) + 4 + 36]
|
|
||||||
let token := calldataload(add(calldataload(4), 40))
|
|
||||||
|
|
||||||
/////// Setup Header Area ///////
|
|
||||||
// This area holds the 4-byte `transferFrom` selector.
|
|
||||||
// Any trailing data in transferFromSelector will be
|
|
||||||
// overwritten in the next `mstore` call.
|
|
||||||
mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
|
|
||||||
|
|
||||||
/////// Setup Params Area ///////
|
|
||||||
// We copy the fields `from`, `to` and `amount` in bulk
|
|
||||||
// from our own calldata to the new calldata.
|
|
||||||
calldatacopy(4, 36, 96)
|
|
||||||
|
|
||||||
/////// Call `token.transferFrom` using the calldata ///////
|
|
||||||
let success := call(
|
|
||||||
gas, // forward all gas
|
|
||||||
token, // call address of token contract
|
|
||||||
0, // don't send any ETH
|
|
||||||
0, // pointer to start of input
|
|
||||||
100, // length of input
|
|
||||||
0, // write output over input
|
|
||||||
32 // output size should be 32 bytes
|
|
||||||
)
|
|
||||||
|
|
||||||
/////// Check return data. ///////
|
|
||||||
// If there is no return data, we assume the token incorrectly
|
|
||||||
// does not return a bool. In this case we expect it to revert
|
|
||||||
// on failure, which was handled above.
|
|
||||||
// If the token does return data, we require that it is a single
|
|
||||||
// nonzero 32 bytes value.
|
|
||||||
// So the transfer succeeded if the call succeeded and either
|
|
||||||
// returned nothing, or returned a non-zero 32 byte value.
|
|
||||||
success := and(success, or(
|
|
||||||
iszero(returndatasize),
|
|
||||||
and(
|
|
||||||
eq(returndatasize, 32),
|
|
||||||
gt(mload(0), 0)
|
|
||||||
)
|
|
||||||
))
|
|
||||||
if success {
|
|
||||||
return(0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Revert with `Error("TRANSFER_FAILED")`
|
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)
|
|
||||||
mstore(96, 0)
|
|
||||||
revert(0, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Revert if undefined function is called
|
|
||||||
revert(0, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Gets the proxy id associated with the proxy address.
|
|
||||||
/// @return Proxy id.
|
|
||||||
function getProxyId()
|
|
||||||
external
|
|
||||||
pure
|
|
||||||
returns (bytes4)
|
|
||||||
{
|
|
||||||
return PROXY_ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,171 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "../archive/MixinAuthorizable.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract ERC721Proxy is
|
|
||||||
MixinAuthorizable
|
|
||||||
{
|
|
||||||
// Id of this proxy.
|
|
||||||
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC721Token(address,uint256)"));
|
|
||||||
|
|
||||||
// solhint-disable-next-line payable-fallback
|
|
||||||
function ()
|
|
||||||
external
|
|
||||||
{
|
|
||||||
assembly {
|
|
||||||
// The first 4 bytes of calldata holds the function selector
|
|
||||||
let selector := and(calldataload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000)
|
|
||||||
|
|
||||||
// `transferFrom` will be called with the following parameters:
|
|
||||||
// assetData Encoded byte array.
|
|
||||||
// from Address to transfer asset from.
|
|
||||||
// to Address to transfer asset to.
|
|
||||||
// amount Amount of asset to transfer.
|
|
||||||
// bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4
|
|
||||||
if eq(selector, 0xa85e59e400000000000000000000000000000000000000000000000000000000) {
|
|
||||||
|
|
||||||
// To lookup a value in a mapping, we load from the storage location keccak256(k, p),
|
|
||||||
// where k is the key left padded to 32 bytes and p is the storage slot
|
|
||||||
let start := mload(64)
|
|
||||||
mstore(start, and(caller, 0xffffffffffffffffffffffffffffffffffffffff))
|
|
||||||
mstore(add(start, 32), authorized_slot)
|
|
||||||
|
|
||||||
// Revert if authorized[msg.sender] == false
|
|
||||||
if iszero(sload(keccak256(start, 64))) {
|
|
||||||
// Revert with `Error("SENDER_NOT_AUTHORIZED")`
|
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(64, 0x0000001553454e4445525f4e4f545f415554484f52495a454400000000000000)
|
|
||||||
mstore(96, 0)
|
|
||||||
revert(0, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
// `transferFrom`.
|
|
||||||
// The function is marked `external`, so no abi decodeding is done for
|
|
||||||
// us. Instead, we expect the `calldata` memory to contain the
|
|
||||||
// following:
|
|
||||||
//
|
|
||||||
// | Area | Offset | Length | Contents |
|
|
||||||
// |----------|--------|---------|-------------------------------------|
|
|
||||||
// | Header | 0 | 4 | function selector |
|
|
||||||
// | Params | | 4 * 32 | function parameters: |
|
|
||||||
// | | 4 | | 1. offset to assetData (*) |
|
|
||||||
// | | 36 | | 2. from |
|
|
||||||
// | | 68 | | 3. to |
|
|
||||||
// | | 100 | | 4. amount |
|
|
||||||
// | Data | | | assetData: |
|
|
||||||
// | | 132 | 32 | assetData Length |
|
|
||||||
// | | 164 | ** | assetData Contents |
|
|
||||||
//
|
|
||||||
// (*): offset is computed from start of function parameters, so offset
|
|
||||||
// by an additional 4 bytes in the calldata.
|
|
||||||
//
|
|
||||||
// (**): see table below to compute length of assetData Contents
|
|
||||||
//
|
|
||||||
// WARNING: The ABIv2 specification allows additional padding between
|
|
||||||
// the Params and Data section. This will result in a larger
|
|
||||||
// offset to assetData.
|
|
||||||
|
|
||||||
// Asset data itself is encoded as follows:
|
|
||||||
//
|
|
||||||
// | Area | Offset | Length | Contents |
|
|
||||||
// |----------|--------|---------|-------------------------------------|
|
|
||||||
// | Header | 0 | 4 | function selector |
|
|
||||||
// | Params | | 2 * 32 | function parameters: |
|
|
||||||
// | | 4 | 12 + 20 | 1. token address |
|
|
||||||
// | | 36 | | 2. tokenId |
|
|
||||||
|
|
||||||
// We construct calldata for the `token.transferFrom` ABI.
|
|
||||||
// The layout of this calldata is in the table below.
|
|
||||||
//
|
|
||||||
// | Area | Offset | Length | Contents |
|
|
||||||
// |----------|--------|---------|-------------------------------------|
|
|
||||||
// | Header | 0 | 4 | function selector |
|
|
||||||
// | Params | | 3 * 32 | function parameters: |
|
|
||||||
// | | 4 | | 1. from |
|
|
||||||
// | | 36 | | 2. to |
|
|
||||||
// | | 68 | | 3. tokenId |
|
|
||||||
|
|
||||||
// There exists only 1 of each token.
|
|
||||||
// require(amount == 1, "INVALID_AMOUNT")
|
|
||||||
if sub(calldataload(100), 1) {
|
|
||||||
// Revert with `Error("INVALID_AMOUNT")`
|
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(64, 0x0000000e494e56414c49445f414d4f554e540000000000000000000000000000)
|
|
||||||
mstore(96, 0)
|
|
||||||
revert(0, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
/////// Setup Header Area ///////
|
|
||||||
// This area holds the 4-byte `transferFrom` selector.
|
|
||||||
// Any trailing data in transferFromSelector will be
|
|
||||||
// overwritten in the next `mstore` call.
|
|
||||||
mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
|
|
||||||
|
|
||||||
/////// Setup Params Area ///////
|
|
||||||
// We copy the fields `from` and `to` in bulk
|
|
||||||
// from our own calldata to the new calldata.
|
|
||||||
calldatacopy(4, 36, 64)
|
|
||||||
|
|
||||||
// Copy `tokenId` field from our own calldata to the new calldata.
|
|
||||||
let assetDataOffset := calldataload(4)
|
|
||||||
calldatacopy(68, add(assetDataOffset, 72), 32)
|
|
||||||
|
|
||||||
/////// Call `token.transferFrom` using the calldata ///////
|
|
||||||
let token := calldataload(add(assetDataOffset, 40))
|
|
||||||
let success := call(
|
|
||||||
gas, // forward all gas
|
|
||||||
token, // call address of token contract
|
|
||||||
0, // don't send any ETH
|
|
||||||
0, // pointer to start of input
|
|
||||||
100, // length of input
|
|
||||||
0, // write output to null
|
|
||||||
0 // output size is 0 bytes
|
|
||||||
)
|
|
||||||
if success {
|
|
||||||
return(0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Revert with `Error("TRANSFER_FAILED")`
|
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)
|
|
||||||
mstore(96, 0)
|
|
||||||
revert(0, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Revert if undefined function is called
|
|
||||||
revert(0, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Gets the proxy id associated with the proxy address.
|
|
||||||
/// @return Proxy id.
|
|
||||||
function getProxyId()
|
|
||||||
external
|
|
||||||
pure
|
|
||||||
returns (bytes4)
|
|
||||||
{
|
|
||||||
return PROXY_ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,335 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "../archive/MixinAssetProxyDispatcher.sol";
|
|
||||||
import "../archive/MixinAuthorizable.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MultiAssetProxy is
|
|
||||||
MixinAssetProxyDispatcher,
|
|
||||||
MixinAuthorizable
|
|
||||||
{
|
|
||||||
// Id of this proxy.
|
|
||||||
bytes4 constant internal PROXY_ID = bytes4(keccak256("MultiAsset(uint256[],bytes[])"));
|
|
||||||
|
|
||||||
// solhint-disable-next-line payable-fallback
|
|
||||||
function ()
|
|
||||||
external
|
|
||||||
{
|
|
||||||
// NOTE: The below assembly assumes that clients do some input validation and that the input is properly encoded according to the AbiV2 specification.
|
|
||||||
// It is technically possible for inputs with very large lengths and offsets to cause overflows. However, this would make the calldata prohibitively
|
|
||||||
// expensive and we therefore do not check for overflows in these scenarios.
|
|
||||||
assembly {
|
|
||||||
// The first 4 bytes of calldata holds the function selector
|
|
||||||
let selector := and(calldataload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000)
|
|
||||||
|
|
||||||
// `transferFrom` will be called with the following parameters:
|
|
||||||
// assetData Encoded byte array.
|
|
||||||
// from Address to transfer asset from.
|
|
||||||
// to Address to transfer asset to.
|
|
||||||
// amount Amount of asset to transfer.
|
|
||||||
// bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4
|
|
||||||
if eq(selector, 0xa85e59e400000000000000000000000000000000000000000000000000000000) {
|
|
||||||
|
|
||||||
// To lookup a value in a mapping, we load from the storage location keccak256(k, p),
|
|
||||||
// where k is the key left padded to 32 bytes and p is the storage slot
|
|
||||||
mstore(0, caller)
|
|
||||||
mstore(32, authorized_slot)
|
|
||||||
|
|
||||||
// Revert if authorized[msg.sender] == false
|
|
||||||
if iszero(sload(keccak256(0, 64))) {
|
|
||||||
// Revert with `Error("SENDER_NOT_AUTHORIZED")`
|
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(64, 0x0000001553454e4445525f4e4f545f415554484f52495a454400000000000000)
|
|
||||||
mstore(96, 0)
|
|
||||||
revert(0, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
// `transferFrom`.
|
|
||||||
// The function is marked `external`, so no abi decoding is done for
|
|
||||||
// us. Instead, we expect the `calldata` memory to contain the
|
|
||||||
// following:
|
|
||||||
//
|
|
||||||
// | Area | Offset | Length | Contents |
|
|
||||||
// |----------|--------|---------|-------------------------------------|
|
|
||||||
// | Header | 0 | 4 | function selector |
|
|
||||||
// | Params | | 4 * 32 | function parameters: |
|
|
||||||
// | | 4 | | 1. offset to assetData (*) |
|
|
||||||
// | | 36 | | 2. from |
|
|
||||||
// | | 68 | | 3. to |
|
|
||||||
// | | 100 | | 4. amount |
|
|
||||||
// | Data | | | assetData: |
|
|
||||||
// | | 132 | 32 | assetData Length |
|
|
||||||
// | | 164 | ** | assetData Contents |
|
|
||||||
//
|
|
||||||
// (*): offset is computed from start of function parameters, so offset
|
|
||||||
// by an additional 4 bytes in the calldata.
|
|
||||||
//
|
|
||||||
// (**): see table below to compute length of assetData Contents
|
|
||||||
//
|
|
||||||
// WARNING: The ABIv2 specification allows additional padding between
|
|
||||||
// the Params and Data section. This will result in a larger
|
|
||||||
// offset to assetData.
|
|
||||||
|
|
||||||
// Load offset to `assetData`
|
|
||||||
let assetDataOffset := add(calldataload(4), 4)
|
|
||||||
|
|
||||||
// Load length in bytes of `assetData`
|
|
||||||
let assetDataLength := calldataload(assetDataOffset)
|
|
||||||
|
|
||||||
// Asset data itself is encoded as follows:
|
|
||||||
//
|
|
||||||
// | Area | Offset | Length | Contents |
|
|
||||||
// |----------|-------------|---------|-------------------------------------|
|
|
||||||
// | Header | 0 | 4 | assetProxyId |
|
|
||||||
// | Params | | 2 * 32 | function parameters: |
|
|
||||||
// | | 4 | | 1. offset to amounts (*) |
|
|
||||||
// | | 36 | | 2. offset to nestedAssetData (*) |
|
|
||||||
// | Data | | | amounts: |
|
|
||||||
// | | 68 | 32 | amounts Length |
|
|
||||||
// | | 100 | a | amounts Contents |
|
|
||||||
// | | | | nestedAssetData: |
|
|
||||||
// | | 100 + a | 32 | nestedAssetData Length |
|
|
||||||
// | | 132 + a | b | nestedAssetData Contents (offsets) |
|
|
||||||
// | | 132 + a + b | | nestedAssetData[0, ..., len] |
|
|
||||||
|
|
||||||
// Assert that the length of asset data:
|
|
||||||
// 1. Must be at least 68 bytes (see table above)
|
|
||||||
// 2. Must be a multiple of 32 (excluding the 4-byte selector)
|
|
||||||
if or(lt(assetDataLength, 68), mod(sub(assetDataLength, 4), 32)) {
|
|
||||||
// Revert with `Error("INVALID_ASSET_DATA_LENGTH")`
|
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(64, 0x00000019494e56414c49445f41535345545f444154415f4c454e475448000000)
|
|
||||||
mstore(96, 0)
|
|
||||||
revert(0, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
// End of asset data in calldata
|
|
||||||
// assetDataOffset
|
|
||||||
// + 32 (assetData len)
|
|
||||||
let assetDataEnd := add(assetDataOffset, add(assetDataLength, 32))
|
|
||||||
if gt(assetDataEnd, calldatasize()) {
|
|
||||||
// Revert with `Error("INVALID_ASSET_DATA_END")`
|
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(64, 0x00000016494e56414c49445f41535345545f444154415f454e44000000000000)
|
|
||||||
mstore(96, 0)
|
|
||||||
revert(0, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
// In order to find the offset to `amounts`, we must add:
|
|
||||||
// assetDataOffset
|
|
||||||
// + 32 (assetData len)
|
|
||||||
// + 4 (assetProxyId)
|
|
||||||
let amountsOffset := calldataload(add(assetDataOffset, 36))
|
|
||||||
|
|
||||||
// In order to find the offset to `nestedAssetData`, we must add:
|
|
||||||
// assetDataOffset
|
|
||||||
// + 32 (assetData len)
|
|
||||||
// + 4 (assetProxyId)
|
|
||||||
// + 32 (amounts offset)
|
|
||||||
let nestedAssetDataOffset := calldataload(add(assetDataOffset, 68))
|
|
||||||
|
|
||||||
// In order to find the start of the `amounts` contents, we must add:
|
|
||||||
// assetDataOffset
|
|
||||||
// + 32 (assetData len)
|
|
||||||
// + 4 (assetProxyId)
|
|
||||||
// + amountsOffset
|
|
||||||
// + 32 (amounts len)
|
|
||||||
let amountsContentsStart := add(assetDataOffset, add(amountsOffset, 68))
|
|
||||||
|
|
||||||
// Load number of elements in `amounts`
|
|
||||||
let amountsLen := calldataload(sub(amountsContentsStart, 32))
|
|
||||||
|
|
||||||
// In order to find the start of the `nestedAssetData` contents, we must add:
|
|
||||||
// assetDataOffset
|
|
||||||
// + 32 (assetData len)
|
|
||||||
// + 4 (assetProxyId)
|
|
||||||
// + nestedAssetDataOffset
|
|
||||||
// + 32 (nestedAssetData len)
|
|
||||||
let nestedAssetDataContentsStart := add(assetDataOffset, add(nestedAssetDataOffset, 68))
|
|
||||||
|
|
||||||
// Load number of elements in `nestedAssetData`
|
|
||||||
let nestedAssetDataLen := calldataload(sub(nestedAssetDataContentsStart, 32))
|
|
||||||
|
|
||||||
// Revert if number of elements in `amounts` differs from number of elements in `nestedAssetData`
|
|
||||||
if sub(amountsLen, nestedAssetDataLen) {
|
|
||||||
// Revert with `Error("LENGTH_MISMATCH")`
|
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(64, 0x0000000f4c454e4754485f4d49534d4154434800000000000000000000000000)
|
|
||||||
mstore(96, 0)
|
|
||||||
revert(0, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy `transferFrom` selector, offset to `assetData`, `from`, and `to` from calldata to memory
|
|
||||||
calldatacopy(
|
|
||||||
0, // memory can safely be overwritten from beginning
|
|
||||||
0, // start of calldata
|
|
||||||
100 // length of selector (4) and 3 params (32 * 3)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Overwrite existing offset to `assetData` with our own
|
|
||||||
mstore(4, 128)
|
|
||||||
|
|
||||||
// Load `amount`
|
|
||||||
let amount := calldataload(100)
|
|
||||||
|
|
||||||
// Calculate number of bytes in `amounts` contents
|
|
||||||
let amountsByteLen := mul(amountsLen, 32)
|
|
||||||
|
|
||||||
// Initialize `assetProxyId` and `assetProxy` to 0
|
|
||||||
let assetProxyId := 0
|
|
||||||
let assetProxy := 0
|
|
||||||
|
|
||||||
// Loop through `amounts` and `nestedAssetData`, calling `transferFrom` for each respective element
|
|
||||||
for {let i := 0} lt(i, amountsByteLen) {i := add(i, 32)} {
|
|
||||||
|
|
||||||
// Calculate the total amount
|
|
||||||
let amountsElement := calldataload(add(amountsContentsStart, i))
|
|
||||||
let totalAmount := mul(amountsElement, amount)
|
|
||||||
|
|
||||||
// Revert if `amount` != 0 and multiplication resulted in an overflow
|
|
||||||
if iszero(or(
|
|
||||||
iszero(amount),
|
|
||||||
eq(div(totalAmount, amount), amountsElement)
|
|
||||||
)) {
|
|
||||||
// Revert with `Error("UINT256_OVERFLOW")`
|
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(64, 0x0000001055494e543235365f4f564552464c4f57000000000000000000000000)
|
|
||||||
mstore(96, 0)
|
|
||||||
revert(0, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write `totalAmount` to memory
|
|
||||||
mstore(100, totalAmount)
|
|
||||||
|
|
||||||
// Load offset to `nestedAssetData[i]`
|
|
||||||
let nestedAssetDataElementOffset := calldataload(add(nestedAssetDataContentsStart, i))
|
|
||||||
|
|
||||||
// In order to find the start of the `nestedAssetData[i]` contents, we must add:
|
|
||||||
// assetDataOffset
|
|
||||||
// + 32 (assetData len)
|
|
||||||
// + 4 (assetProxyId)
|
|
||||||
// + nestedAssetDataOffset
|
|
||||||
// + 32 (nestedAssetData len)
|
|
||||||
// + nestedAssetDataElementOffset
|
|
||||||
// + 32 (nestedAssetDataElement len)
|
|
||||||
let nestedAssetDataElementContentsStart := add(
|
|
||||||
assetDataOffset,
|
|
||||||
add(
|
|
||||||
nestedAssetDataOffset,
|
|
||||||
add(nestedAssetDataElementOffset, 100)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Load length of `nestedAssetData[i]`
|
|
||||||
let nestedAssetDataElementLenStart := sub(nestedAssetDataElementContentsStart, 32)
|
|
||||||
let nestedAssetDataElementLen := calldataload(nestedAssetDataElementLenStart)
|
|
||||||
|
|
||||||
// Revert if the `nestedAssetData` does not contain a 4 byte `assetProxyId`
|
|
||||||
if lt(nestedAssetDataElementLen, 4) {
|
|
||||||
// Revert with `Error("LENGTH_GREATER_THAN_3_REQUIRED")`
|
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(64, 0x0000001e4c454e4754485f475245415445525f5448414e5f335f524551554952)
|
|
||||||
mstore(96, 0x4544000000000000000000000000000000000000000000000000000000000000)
|
|
||||||
revert(0, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load AssetProxy id
|
|
||||||
let currentAssetProxyId := and(
|
|
||||||
calldataload(nestedAssetDataElementContentsStart),
|
|
||||||
0xffffffff00000000000000000000000000000000000000000000000000000000
|
|
||||||
)
|
|
||||||
|
|
||||||
// Only load `assetProxy` if `currentAssetProxyId` does not equal `assetProxyId`
|
|
||||||
// We do not need to check if `currentAssetProxyId` is 0 since `assetProxy` is also initialized to 0
|
|
||||||
if sub(currentAssetProxyId, assetProxyId) {
|
|
||||||
// Update `assetProxyId`
|
|
||||||
assetProxyId := currentAssetProxyId
|
|
||||||
// To lookup a value in a mapping, we load from the storage location keccak256(k, p),
|
|
||||||
// where k is the key left padded to 32 bytes and p is the storage slot
|
|
||||||
mstore(132, assetProxyId)
|
|
||||||
mstore(164, assetProxies_slot)
|
|
||||||
assetProxy := sload(keccak256(132, 64))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Revert if AssetProxy with given id does not exist
|
|
||||||
if iszero(assetProxy) {
|
|
||||||
// Revert with `Error("ASSET_PROXY_DOES_NOT_EXIST")`
|
|
||||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
|
||||||
mstore(64, 0x0000001a41535345545f50524f58595f444f45535f4e4f545f45584953540000)
|
|
||||||
mstore(96, 0)
|
|
||||||
revert(0, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy `nestedAssetData[i]` from calldata to memory
|
|
||||||
calldatacopy(
|
|
||||||
132, // memory slot after `amounts[i]`
|
|
||||||
nestedAssetDataElementLenStart, // location of `nestedAssetData[i]` in calldata
|
|
||||||
add(nestedAssetDataElementLen, 32) // `nestedAssetData[i].length` plus 32 byte length
|
|
||||||
)
|
|
||||||
|
|
||||||
// call `assetProxy.transferFrom`
|
|
||||||
let success := call(
|
|
||||||
gas, // forward all gas
|
|
||||||
assetProxy, // call address of asset proxy
|
|
||||||
0, // don't send any ETH
|
|
||||||
0, // pointer to start of input
|
|
||||||
add(164, nestedAssetDataElementLen), // length of input
|
|
||||||
0, // write output over memory that won't be reused
|
|
||||||
0 // don't copy output to memory
|
|
||||||
)
|
|
||||||
|
|
||||||
// Revert with reason given by AssetProxy if `transferFrom` call failed
|
|
||||||
if iszero(success) {
|
|
||||||
returndatacopy(
|
|
||||||
0, // copy to memory at 0
|
|
||||||
0, // copy from return data at 0
|
|
||||||
returndatasize() // copy all return data
|
|
||||||
)
|
|
||||||
revert(0, returndatasize())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return if no `transferFrom` calls reverted
|
|
||||||
return(0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Revert if undefined function is called
|
|
||||||
revert(0, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Gets the proxy id associated with the proxy address.
|
|
||||||
/// @return Proxy id.
|
|
||||||
function getProxyId()
|
|
||||||
external
|
|
||||||
pure
|
|
||||||
returns (bytes4)
|
|
||||||
{
|
|
||||||
return PROXY_ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable no-unused-vars
|
|
||||||
contract StaticCallProxy {
|
|
||||||
|
|
||||||
using LibBytes for bytes;
|
|
||||||
|
|
||||||
// Id of this proxy.
|
|
||||||
bytes4 constant internal PROXY_ID = bytes4(keccak256("StaticCall(address,bytes,bytes32)"));
|
|
||||||
|
|
||||||
/// @dev Makes a staticcall to a target address and verifies that the data returned matches the expected return data.
|
|
||||||
/// @param assetData Byte array encoded with staticCallTarget, staticCallData, and expectedCallResultHash
|
|
||||||
/// @param from This value is ignored.
|
|
||||||
/// @param to This value is ignored.
|
|
||||||
/// @param amount This value is ignored.
|
|
||||||
function transferFrom(
|
|
||||||
bytes calldata assetData,
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
{
|
|
||||||
// Decode params from `assetData`
|
|
||||||
(
|
|
||||||
address staticCallTarget,
|
|
||||||
bytes memory staticCallData,
|
|
||||||
bytes32 expectedReturnDataHash
|
|
||||||
) = abi.decode(
|
|
||||||
assetData.sliceDestructive(4, assetData.length),
|
|
||||||
(address, bytes, bytes32)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Execute staticcall
|
|
||||||
(bool success, bytes memory returnData) = staticCallTarget.staticcall(staticCallData);
|
|
||||||
|
|
||||||
// Revert with returned data if staticcall is unsuccessful
|
|
||||||
if (!success) {
|
|
||||||
assembly {
|
|
||||||
revert(add(returnData, 32), mload(returnData))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Revert if hash of return data is not as expected
|
|
||||||
bytes32 returnDataHash = keccak256(returnData);
|
|
||||||
require(
|
|
||||||
expectedReturnDataHash == returnDataHash,
|
|
||||||
"UNEXPECTED_STATIC_CALL_RESULT"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Gets the proxy id associated with the proxy address.
|
|
||||||
/// @return Proxy id.
|
|
||||||
function getProxyId()
|
|
||||||
external
|
|
||||||
pure
|
|
||||||
returns (bytes4)
|
|
||||||
{
|
|
||||||
return PROXY_ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
|
|
||||||
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
|
|
||||||
import "../interfaces/IERC20Bridge.sol";
|
|
||||||
import "../interfaces/IEth2Dai.sol";
|
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable space-after-comma
|
|
||||||
contract Eth2DaiBridge is
|
|
||||||
IERC20Bridge,
|
|
||||||
IWallet
|
|
||||||
{
|
|
||||||
/* Mainnet addresses */
|
|
||||||
address constant public ETH2DAI_ADDRESS = 0x39755357759cE0d7f32dC8dC45414CCa409AE24e;
|
|
||||||
|
|
||||||
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
|
|
||||||
/// `toTokenAddress` tokens by selling the entirety of the opposing asset
|
|
||||||
/// (DAI or WETH) to the Eth2Dai contract, then transfers the bought
|
|
||||||
/// tokens to `to`.
|
|
||||||
/// @param toTokenAddress The token to give to `to` (either DAI or WETH).
|
|
||||||
/// @param to The recipient of the bought tokens.
|
|
||||||
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
|
|
||||||
/// @param bridgeData The abi-encoeded "from" token address.
|
|
||||||
/// @return success The magic bytes if successful.
|
|
||||||
function bridgeTransferFrom(
|
|
||||||
address toTokenAddress,
|
|
||||||
address /* from */,
|
|
||||||
address to,
|
|
||||||
uint256 amount,
|
|
||||||
bytes calldata bridgeData
|
|
||||||
)
|
|
||||||
external
|
|
||||||
returns (bytes4 success)
|
|
||||||
{
|
|
||||||
// Decode the bridge data to get the `fromTokenAddress`.
|
|
||||||
(address fromTokenAddress) = abi.decode(bridgeData, (address));
|
|
||||||
|
|
||||||
IEth2Dai exchange = _getEth2DaiContract();
|
|
||||||
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
|
|
||||||
LibERC20Token.approve(fromTokenAddress, address(exchange), uint256(-1));
|
|
||||||
|
|
||||||
// Try to sell all of this contract's `fromTokenAddress` token balance.
|
|
||||||
uint256 boughtAmount = _getEth2DaiContract().sellAllAmount(
|
|
||||||
address(fromTokenAddress),
|
|
||||||
IERC20Token(fromTokenAddress).balanceOf(address(this)),
|
|
||||||
toTokenAddress,
|
|
||||||
amount
|
|
||||||
);
|
|
||||||
// Transfer the converted `toToken`s to `to`.
|
|
||||||
LibERC20Token.transfer(toTokenAddress, to, boughtAmount);
|
|
||||||
return BRIDGE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
|
|
||||||
/// and sign for itself in orders. Always succeeds.
|
|
||||||
/// @return magicValue Magic success bytes, always.
|
|
||||||
function isValidSignature(
|
|
||||||
bytes32,
|
|
||||||
bytes calldata
|
|
||||||
)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (bytes4 magicValue)
|
|
||||||
{
|
|
||||||
return LEGACY_WALLET_MAGIC_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Overridable way to get the eth2dai contract.
|
|
||||||
/// @return exchange The Eth2Dai exchange contract.
|
|
||||||
function _getEth2DaiContract()
|
|
||||||
internal
|
|
||||||
view
|
|
||||||
returns (IEth2Dai exchange)
|
|
||||||
{
|
|
||||||
return IEth2Dai(ETH2DAI_ADDRESS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,219 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
|
|
||||||
import "@0x/contracts-erc20/contracts/src/interfaces/IEtherToken.sol";
|
|
||||||
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
|
|
||||||
import "../interfaces/IUniswapExchangeFactory.sol";
|
|
||||||
import "../interfaces/IUniswapExchange.sol";
|
|
||||||
import "../interfaces/IERC20Bridge.sol";
|
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable space-after-comma
|
|
||||||
// solhint-disable not-rely-on-time
|
|
||||||
contract UniswapBridge is
|
|
||||||
IERC20Bridge,
|
|
||||||
IWallet
|
|
||||||
{
|
|
||||||
/* Mainnet addresses */
|
|
||||||
address constant private UNISWAP_EXCHANGE_FACTORY_ADDRESS = 0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95;
|
|
||||||
address constant private WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
|
|
||||||
|
|
||||||
// Struct to hold `bridgeTransferFrom()` local variables in memory and to avoid
|
|
||||||
// stack overflows.
|
|
||||||
struct WithdrawToState {
|
|
||||||
IUniswapExchange exchange;
|
|
||||||
uint256 fromTokenBalance;
|
|
||||||
IEtherToken weth;
|
|
||||||
}
|
|
||||||
|
|
||||||
// solhint-disable no-empty-blocks
|
|
||||||
/// @dev Payable fallback to receive ETH from uniswap.
|
|
||||||
function ()
|
|
||||||
external
|
|
||||||
payable
|
|
||||||
{}
|
|
||||||
|
|
||||||
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
|
|
||||||
/// `toTokenAddress` tokens by selling the entirety of the `fromTokenAddress`
|
|
||||||
/// token encoded in the bridge data.
|
|
||||||
/// @param toTokenAddress The token to buy and transfer to `to`.
|
|
||||||
/// @param to The recipient of the bought tokens.
|
|
||||||
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
|
|
||||||
/// @param bridgeData The abi-encoded "from" token address.
|
|
||||||
/// @return success The magic bytes if successful.
|
|
||||||
function bridgeTransferFrom(
|
|
||||||
address toTokenAddress,
|
|
||||||
address /* from */,
|
|
||||||
address to,
|
|
||||||
uint256 amount,
|
|
||||||
bytes calldata bridgeData
|
|
||||||
)
|
|
||||||
external
|
|
||||||
returns (bytes4 success)
|
|
||||||
{
|
|
||||||
// State memory object to avoid stack overflows.
|
|
||||||
WithdrawToState memory state;
|
|
||||||
// Decode the bridge data to get the `fromTokenAddress`.
|
|
||||||
(address fromTokenAddress) = abi.decode(bridgeData, (address));
|
|
||||||
|
|
||||||
// Just transfer the tokens if they're the same.
|
|
||||||
if (fromTokenAddress == toTokenAddress) {
|
|
||||||
LibERC20Token.transfer(fromTokenAddress, to, amount);
|
|
||||||
return BRIDGE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the exchange for the token pair.
|
|
||||||
state.exchange = _getUniswapExchangeForTokenPair(
|
|
||||||
fromTokenAddress,
|
|
||||||
toTokenAddress
|
|
||||||
);
|
|
||||||
// Get our balance of `fromTokenAddress` token.
|
|
||||||
state.fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this));
|
|
||||||
// Get the weth contract.
|
|
||||||
state.weth = getWethContract();
|
|
||||||
|
|
||||||
// Convert from WETH to a token.
|
|
||||||
if (fromTokenAddress == address(state.weth)) {
|
|
||||||
// Unwrap the WETH.
|
|
||||||
state.weth.withdraw(state.fromTokenBalance);
|
|
||||||
// Buy as much of `toTokenAddress` token with ETH as possible and
|
|
||||||
// transfer it to `to`.
|
|
||||||
state.exchange.ethToTokenTransferInput.value(state.fromTokenBalance)(
|
|
||||||
// Minimum buy amount.
|
|
||||||
amount,
|
|
||||||
// Expires after this block.
|
|
||||||
block.timestamp,
|
|
||||||
// Recipient is `to`.
|
|
||||||
to
|
|
||||||
);
|
|
||||||
|
|
||||||
// Convert from a token to WETH.
|
|
||||||
} else if (toTokenAddress == address(state.weth)) {
|
|
||||||
// Grant the exchange an allowance.
|
|
||||||
_grantExchangeAllowance(state.exchange, fromTokenAddress);
|
|
||||||
// Buy as much ETH with `fromTokenAddress` token as possible.
|
|
||||||
uint256 ethBought = state.exchange.tokenToEthSwapInput(
|
|
||||||
// Sell all tokens we hold.
|
|
||||||
state.fromTokenBalance,
|
|
||||||
// Minimum buy amount.
|
|
||||||
amount,
|
|
||||||
// Expires after this block.
|
|
||||||
block.timestamp
|
|
||||||
);
|
|
||||||
// Wrap the ETH.
|
|
||||||
state.weth.deposit.value(ethBought)();
|
|
||||||
// Transfer the WETH to `to`.
|
|
||||||
IEtherToken(toTokenAddress).transfer(to, ethBought);
|
|
||||||
|
|
||||||
// Convert from one token to another.
|
|
||||||
} else {
|
|
||||||
// Grant the exchange an allowance.
|
|
||||||
_grantExchangeAllowance(state.exchange, fromTokenAddress);
|
|
||||||
// Buy as much `toTokenAddress` token with `fromTokenAddress` token
|
|
||||||
// and transfer it to `to`.
|
|
||||||
state.exchange.tokenToTokenTransferInput(
|
|
||||||
// Sell all tokens we hold.
|
|
||||||
state.fromTokenBalance,
|
|
||||||
// Minimum buy amount.
|
|
||||||
amount,
|
|
||||||
// No minimum intermediate ETH buy amount.
|
|
||||||
0,
|
|
||||||
// Expires after this block.
|
|
||||||
block.timestamp,
|
|
||||||
// Recipient is `to`.
|
|
||||||
to,
|
|
||||||
// Convert to `toTokenAddress`.
|
|
||||||
toTokenAddress
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return BRIDGE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
|
|
||||||
/// and sign for itself in orders. Always succeeds.
|
|
||||||
/// @return magicValue Success bytes, always.
|
|
||||||
function isValidSignature(
|
|
||||||
bytes32,
|
|
||||||
bytes calldata
|
|
||||||
)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (bytes4 magicValue)
|
|
||||||
{
|
|
||||||
return LEGACY_WALLET_MAGIC_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Overridable way to get the weth contract.
|
|
||||||
/// @return token The WETH contract.
|
|
||||||
function getWethContract()
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (IEtherToken token)
|
|
||||||
{
|
|
||||||
return IEtherToken(WETH_ADDRESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Overridable way to get the uniswap exchange factory contract.
|
|
||||||
/// @return factory The exchange factory contract.
|
|
||||||
function getUniswapExchangeFactoryContract()
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (IUniswapExchangeFactory factory)
|
|
||||||
{
|
|
||||||
return IUniswapExchangeFactory(UNISWAP_EXCHANGE_FACTORY_ADDRESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Grants an unlimited allowance to the exchange for its token
|
|
||||||
/// on behalf of this contract.
|
|
||||||
/// @param exchange The Uniswap token exchange.
|
|
||||||
/// @param tokenAddress The token address for the exchange.
|
|
||||||
function _grantExchangeAllowance(IUniswapExchange exchange, address tokenAddress)
|
|
||||||
private
|
|
||||||
{
|
|
||||||
LibERC20Token.approve(tokenAddress, address(exchange), uint256(-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Retrieves the uniswap exchange for a given token pair.
|
|
||||||
/// In the case of a WETH-token exchange, this will be the non-WETH token.
|
|
||||||
/// In th ecase of a token-token exchange, this will be the first token.
|
|
||||||
/// @param fromTokenAddress The address of the token we are converting from.
|
|
||||||
/// @param toTokenAddress The address of the token we are converting to.
|
|
||||||
/// @return exchange The uniswap exchange.
|
|
||||||
function _getUniswapExchangeForTokenPair(
|
|
||||||
address fromTokenAddress,
|
|
||||||
address toTokenAddress
|
|
||||||
)
|
|
||||||
private
|
|
||||||
view
|
|
||||||
returns (IUniswapExchange exchange)
|
|
||||||
{
|
|
||||||
address exchangeTokenAddress = fromTokenAddress;
|
|
||||||
// Whichever isn't WETH is the exchange token.
|
|
||||||
if (fromTokenAddress == address(getWethContract())) {
|
|
||||||
exchangeTokenAddress = toTokenAddress;
|
|
||||||
}
|
|
||||||
exchange = getUniswapExchangeFactoryContract().getExchange(exchangeTokenAddress);
|
|
||||||
require(address(exchange) != address(0), "NO_UNISWAP_EXCHANGE_FOR_TOKEN");
|
|
||||||
return exchange;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// solhint-disable
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
|
|
||||||
// @dev Interface of the asset proxy's assetData.
|
|
||||||
// The asset proxies take an ABI encoded `bytes assetData` as argument.
|
|
||||||
// This argument is ABI encoded as one of the methods of this interface.
|
|
||||||
interface IAssetData {
|
|
||||||
|
|
||||||
/// @dev Function signature for encoding ERC20 assetData.
|
|
||||||
/// @param tokenAddress Address of ERC20Token contract.
|
|
||||||
function ERC20Token(address tokenAddress)
|
|
||||||
external;
|
|
||||||
|
|
||||||
/// @dev Function signature for encoding ERC721 assetData.
|
|
||||||
/// @param tokenAddress Address of ERC721 token contract.
|
|
||||||
/// @param tokenId Id of ERC721 token to be transferred.
|
|
||||||
function ERC721Token(
|
|
||||||
address tokenAddress,
|
|
||||||
uint256 tokenId
|
|
||||||
)
|
|
||||||
external;
|
|
||||||
|
|
||||||
/// @dev Function signature for encoding ERC1155 assetData.
|
|
||||||
/// @param tokenAddress Address of ERC1155 token contract.
|
|
||||||
/// @param tokenIds Array of ids of tokens to be transferred.
|
|
||||||
/// @param values Array of values that correspond to each token id to be transferred.
|
|
||||||
/// Note that each value will be multiplied by the amount being filled in the order before transferring.
|
|
||||||
/// @param callbackData Extra data to be passed to receiver's `onERC1155Received` callback function.
|
|
||||||
function ERC1155Assets(
|
|
||||||
address tokenAddress,
|
|
||||||
uint256[] calldata tokenIds,
|
|
||||||
uint256[] calldata values,
|
|
||||||
bytes calldata callbackData
|
|
||||||
)
|
|
||||||
external;
|
|
||||||
|
|
||||||
/// @dev Function signature for encoding MultiAsset assetData.
|
|
||||||
/// @param values Array of amounts that correspond to each asset to be transferred.
|
|
||||||
/// Note that each value will be multiplied by the amount being filled in the order before transferring.
|
|
||||||
/// @param nestedAssetData Array of assetData fields that will be be dispatched to their correspnding AssetProxy contract.
|
|
||||||
function MultiAsset(
|
|
||||||
uint256[] calldata values,
|
|
||||||
bytes[] calldata nestedAssetData
|
|
||||||
)
|
|
||||||
external;
|
|
||||||
|
|
||||||
/// @dev Function signature for encoding StaticCall assetData.
|
|
||||||
/// @param staticCallTargetAddress Address that will execute the staticcall.
|
|
||||||
/// @param staticCallData Data that will be executed via staticcall on the staticCallTargetAddress.
|
|
||||||
/// @param expectedReturnDataHash Keccak-256 hash of the expected staticcall return data.
|
|
||||||
function StaticCall(
|
|
||||||
address staticCallTargetAddress,
|
|
||||||
bytes calldata staticCallData,
|
|
||||||
bytes32 expectedReturnDataHash
|
|
||||||
)
|
|
||||||
external;
|
|
||||||
|
|
||||||
/// @dev Function signature for encoding ERC20Bridge assetData.
|
|
||||||
/// @param tokenAddress Address of token to transfer.
|
|
||||||
/// @param bridgeAddress Address of the bridge contract.
|
|
||||||
/// @param bridgeData Arbitrary data to be passed to the bridge contract.
|
|
||||||
function ERC20Bridge(
|
|
||||||
address tokenAddress,
|
|
||||||
address bridgeAddress,
|
|
||||||
bytes calldata bridgeData
|
|
||||||
)
|
|
||||||
external;
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
|
|
||||||
contract IAssetProxy {
|
|
||||||
|
|
||||||
/// @dev Transfers assets. Either succeeds or throws.
|
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
|
||||||
/// @param from Address to transfer asset from.
|
|
||||||
/// @param to Address to transfer asset to.
|
|
||||||
/// @param amount Amount of asset to transfer.
|
|
||||||
function transferFrom(
|
|
||||||
bytes calldata assetData,
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
external;
|
|
||||||
|
|
||||||
/// @dev Gets the proxy id associated with the proxy address.
|
|
||||||
/// @return Proxy id.
|
|
||||||
function getProxyId()
|
|
||||||
external
|
|
||||||
pure
|
|
||||||
returns (bytes4);
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
|
|
||||||
contract IAssetProxyDispatcher {
|
|
||||||
|
|
||||||
// Logs registration of new asset proxy
|
|
||||||
event AssetProxyRegistered(
|
|
||||||
bytes4 id, // Id of new registered AssetProxy.
|
|
||||||
address assetProxy // Address of new registered AssetProxy.
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @dev Registers an asset proxy to its asset proxy id.
|
|
||||||
/// Once an asset proxy is registered, it cannot be unregistered.
|
|
||||||
/// @param assetProxy Address of new asset proxy to register.
|
|
||||||
function registerAssetProxy(address assetProxy)
|
|
||||||
external;
|
|
||||||
|
|
||||||
/// @dev Gets an asset proxy.
|
|
||||||
/// @param assetProxyId Id of the asset proxy.
|
|
||||||
/// @return The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered.
|
|
||||||
function getAssetProxy(bytes4 assetProxyId)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (address);
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
|
|
||||||
interface IEth2Dai {
|
|
||||||
|
|
||||||
/// @dev Sell `sellAmount` of `fromToken` token and receive `toToken` token.
|
|
||||||
/// @param fromToken The token being sold.
|
|
||||||
/// @param sellAmount The amount of `fromToken` token being sold.
|
|
||||||
/// @param toToken The token being bought.
|
|
||||||
/// @param minFillAmount Minimum amount of `toToken` token to buy.
|
|
||||||
/// @return fillAmount Amount of `toToken` bought.
|
|
||||||
function sellAllAmount(
|
|
||||||
address fromToken,
|
|
||||||
uint256 sellAmount,
|
|
||||||
address toToken,
|
|
||||||
uint256 minFillAmount
|
|
||||||
)
|
|
||||||
external
|
|
||||||
returns (uint256 fillAmount);
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
|
|
||||||
interface IUniswapExchange {
|
|
||||||
|
|
||||||
/// @dev Buys at least `minTokensBought` tokens with ETH and transfer them
|
|
||||||
/// to `recipient`.
|
|
||||||
/// @param minTokensBought The minimum number of tokens to buy.
|
|
||||||
/// @param deadline Time when this order expires.
|
|
||||||
/// @param recipient Who to transfer the tokens to.
|
|
||||||
/// @return tokensBought Amount of tokens bought.
|
|
||||||
function ethToTokenTransferInput(
|
|
||||||
uint256 minTokensBought,
|
|
||||||
uint256 deadline,
|
|
||||||
address recipient
|
|
||||||
)
|
|
||||||
external
|
|
||||||
payable
|
|
||||||
returns (uint256 tokensBought);
|
|
||||||
|
|
||||||
/// @dev Buys at least `minEthBought` ETH with tokens.
|
|
||||||
/// @param tokensSold Amount of tokens to sell.
|
|
||||||
/// @param minEthBought The minimum amount of ETH to buy.
|
|
||||||
/// @param deadline Time when this order expires.
|
|
||||||
/// @return ethBought Amount of tokens bought.
|
|
||||||
function tokenToEthSwapInput(
|
|
||||||
uint256 tokensSold,
|
|
||||||
uint256 minEthBought,
|
|
||||||
uint256 deadline
|
|
||||||
)
|
|
||||||
external
|
|
||||||
returns (uint256 ethBought);
|
|
||||||
|
|
||||||
/// @dev Buys at least `minTokensBought` tokens with the exchange token
|
|
||||||
/// and transfer them to `recipient`.
|
|
||||||
/// @param minTokensBought The minimum number of tokens to buy.
|
|
||||||
/// @param minEthBought The minimum amount of intermediate ETH to buy.
|
|
||||||
/// @param deadline Time when this order expires.
|
|
||||||
/// @param recipient Who to transfer the tokens to.
|
|
||||||
/// @param toTokenAddress The token being bought.
|
|
||||||
/// @return tokensBought Amount of tokens bought.
|
|
||||||
function tokenToTokenTransferInput(
|
|
||||||
uint256 tokensSold,
|
|
||||||
uint256 minTokensBought,
|
|
||||||
uint256 minEthBought,
|
|
||||||
uint256 deadline,
|
|
||||||
address recipient,
|
|
||||||
address toTokenAddress
|
|
||||||
)
|
|
||||||
external
|
|
||||||
returns (uint256 tokensBought);
|
|
||||||
|
|
||||||
/// @dev Retrieves the token that is associated with this exchange.
|
|
||||||
/// @return tokenAddress The token address.
|
|
||||||
function toTokenAddress()
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (address tokenAddress);
|
|
||||||
}
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "../src/interfaces/IERC20Bridge.sol";
|
|
||||||
|
|
||||||
|
|
||||||
/// @dev Test bridge token
|
|
||||||
contract TestERC20BridgeToken {
|
|
||||||
mapping (address => uint256) private _balances;
|
|
||||||
|
|
||||||
function addBalance(address owner, int256 amount)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
setBalance(owner, uint256(int256(balanceOf(owner)) + amount));
|
|
||||||
}
|
|
||||||
|
|
||||||
function setBalance(address owner, uint256 balance)
|
|
||||||
public
|
|
||||||
{
|
|
||||||
_balances[owner] = balance;
|
|
||||||
}
|
|
||||||
|
|
||||||
function balanceOf(address owner)
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (uint256)
|
|
||||||
{
|
|
||||||
return _balances[owner];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// @dev Test bridge contract.
|
|
||||||
contract TestERC20Bridge is
|
|
||||||
IERC20Bridge
|
|
||||||
{
|
|
||||||
TestERC20BridgeToken public testToken;
|
|
||||||
|
|
||||||
event BridgeWithdrawTo(
|
|
||||||
address tokenAddress,
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount,
|
|
||||||
bytes bridgeData
|
|
||||||
);
|
|
||||||
|
|
||||||
constructor() public {
|
|
||||||
testToken = new TestERC20BridgeToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
function setTestTokenBalance(address owner, uint256 balance)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
testToken.setBalance(owner, balance);
|
|
||||||
}
|
|
||||||
|
|
||||||
function bridgeTransferFrom(
|
|
||||||
address tokenAddress,
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount,
|
|
||||||
bytes calldata bridgeData
|
|
||||||
)
|
|
||||||
external
|
|
||||||
returns (bytes4)
|
|
||||||
{
|
|
||||||
emit BridgeWithdrawTo(
|
|
||||||
tokenAddress,
|
|
||||||
from,
|
|
||||||
to,
|
|
||||||
amount,
|
|
||||||
bridgeData
|
|
||||||
);
|
|
||||||
// Unpack the bridgeData.
|
|
||||||
(
|
|
||||||
int256 transferAmount,
|
|
||||||
bytes memory revertData,
|
|
||||||
bytes memory returnData
|
|
||||||
) = abi.decode(bridgeData, (int256, bytes, bytes));
|
|
||||||
|
|
||||||
// If `revertData` is set, revert.
|
|
||||||
if (revertData.length != 0) {
|
|
||||||
assembly { revert(add(revertData, 0x20), mload(revertData)) }
|
|
||||||
}
|
|
||||||
// Increase `to`'s balance by `transferAmount`.
|
|
||||||
TestERC20BridgeToken(tokenAddress).addBalance(to, transferAmount);
|
|
||||||
// Return `returnData`.
|
|
||||||
assembly { return(add(returnData, 0x20), mload(returnData)) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
|
|
||||||
import "../src/bridges/Eth2DaiBridge.sol";
|
|
||||||
import "../src/interfaces/IEth2Dai.sol";
|
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable no-simple-event-func-name
|
|
||||||
contract TestEvents {
|
|
||||||
|
|
||||||
event TokenTransfer(
|
|
||||||
address token,
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount
|
|
||||||
);
|
|
||||||
|
|
||||||
event TokenApprove(
|
|
||||||
address token,
|
|
||||||
address spender,
|
|
||||||
uint256 allowance
|
|
||||||
);
|
|
||||||
|
|
||||||
function raiseTokenTransfer(
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
emit TokenTransfer(
|
|
||||||
msg.sender,
|
|
||||||
from,
|
|
||||||
to,
|
|
||||||
amount
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function raiseTokenApprove(address spender, uint256 allowance)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
emit TokenApprove(msg.sender, spender, allowance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// @dev A minimalist ERC20 token.
|
|
||||||
contract TestToken {
|
|
||||||
|
|
||||||
mapping (address => uint256) public balances;
|
|
||||||
string private _nextTransferRevertReason;
|
|
||||||
bytes private _nextTransferReturnData;
|
|
||||||
|
|
||||||
/// @dev Just calls `raiseTokenTransfer()` on the caller.
|
|
||||||
function transfer(address to, uint256 amount)
|
|
||||||
external
|
|
||||||
returns (bool)
|
|
||||||
{
|
|
||||||
TestEvents(msg.sender).raiseTokenTransfer(msg.sender, to, amount);
|
|
||||||
if (bytes(_nextTransferRevertReason).length != 0) {
|
|
||||||
revert(_nextTransferRevertReason);
|
|
||||||
}
|
|
||||||
bytes memory returnData = _nextTransferReturnData;
|
|
||||||
assembly { return(add(returnData, 0x20), mload(returnData)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Set the balance for `owner`.
|
|
||||||
function setBalance(address owner, uint256 balance)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
balances[owner] = balance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Set the behavior of the `transfer()` call.
|
|
||||||
function setTransferBehavior(
|
|
||||||
string calldata revertReason,
|
|
||||||
bytes calldata returnData
|
|
||||||
)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
_nextTransferRevertReason = revertReason;
|
|
||||||
_nextTransferReturnData = returnData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Just calls `raiseTokenApprove()` on the caller.
|
|
||||||
function approve(address spender, uint256 allowance)
|
|
||||||
external
|
|
||||||
returns (bool)
|
|
||||||
{
|
|
||||||
TestEvents(msg.sender).raiseTokenApprove(spender, allowance);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Retrieve the balance for `owner`.
|
|
||||||
function balanceOf(address owner)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (uint256)
|
|
||||||
{
|
|
||||||
return balances[owner];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// @dev Eth2DaiBridge overridden to mock tokens and
|
|
||||||
/// implement IEth2Dai.
|
|
||||||
contract TestEth2DaiBridge is
|
|
||||||
TestEvents,
|
|
||||||
IEth2Dai,
|
|
||||||
Eth2DaiBridge
|
|
||||||
{
|
|
||||||
event SellAllAmount(
|
|
||||||
address sellToken,
|
|
||||||
uint256 sellTokenAmount,
|
|
||||||
address buyToken,
|
|
||||||
uint256 minimumFillAmount
|
|
||||||
);
|
|
||||||
|
|
||||||
mapping (address => TestToken) public testTokens;
|
|
||||||
string private _nextRevertReason;
|
|
||||||
uint256 private _nextFillAmount;
|
|
||||||
|
|
||||||
/// @dev Create a token and set this contract's balance.
|
|
||||||
function createToken(uint256 balance)
|
|
||||||
external
|
|
||||||
returns (address tokenAddress)
|
|
||||||
{
|
|
||||||
TestToken token = new TestToken();
|
|
||||||
testTokens[address(token)] = token;
|
|
||||||
token.setBalance(address(this), balance);
|
|
||||||
return address(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Set the behavior for `IEth2Dai.sellAllAmount()`.
|
|
||||||
function setFillBehavior(string calldata revertReason, uint256 fillAmount)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
_nextRevertReason = revertReason;
|
|
||||||
_nextFillAmount = fillAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Set the behavior of a token's `transfer()`.
|
|
||||||
function setTransferBehavior(
|
|
||||||
address tokenAddress,
|
|
||||||
string calldata revertReason,
|
|
||||||
bytes calldata returnData
|
|
||||||
)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
testTokens[tokenAddress].setTransferBehavior(revertReason, returnData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Implementation of `IEth2Dai.sellAllAmount()`
|
|
||||||
function sellAllAmount(
|
|
||||||
address sellTokenAddress,
|
|
||||||
uint256 sellTokenAmount,
|
|
||||||
address buyTokenAddress,
|
|
||||||
uint256 minimumFillAmount
|
|
||||||
)
|
|
||||||
external
|
|
||||||
returns (uint256 fillAmount)
|
|
||||||
{
|
|
||||||
emit SellAllAmount(
|
|
||||||
sellTokenAddress,
|
|
||||||
sellTokenAmount,
|
|
||||||
buyTokenAddress,
|
|
||||||
minimumFillAmount
|
|
||||||
);
|
|
||||||
if (bytes(_nextRevertReason).length != 0) {
|
|
||||||
revert(_nextRevertReason);
|
|
||||||
}
|
|
||||||
return _nextFillAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @dev This contract will double as the Eth2Dai contract.
|
|
||||||
function _getEth2DaiContract()
|
|
||||||
internal
|
|
||||||
view
|
|
||||||
returns (IEth2Dai)
|
|
||||||
{
|
|
||||||
return IEth2Dai(address(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract TestStaticCallTarget {
|
|
||||||
|
|
||||||
using LibBytes for bytes;
|
|
||||||
|
|
||||||
uint256 internal _state;
|
|
||||||
|
|
||||||
function updateState()
|
|
||||||
external
|
|
||||||
{
|
|
||||||
_state++;
|
|
||||||
}
|
|
||||||
|
|
||||||
function assertEvenNumber(uint256 target)
|
|
||||||
external
|
|
||||||
pure
|
|
||||||
{
|
|
||||||
require(
|
|
||||||
target % 2 == 0,
|
|
||||||
"TARGET_NOT_EVEN"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isOddNumber(uint256 target)
|
|
||||||
external
|
|
||||||
pure
|
|
||||||
returns (bool isOdd)
|
|
||||||
{
|
|
||||||
isOdd = target % 2 == 1;
|
|
||||||
return isOdd;
|
|
||||||
}
|
|
||||||
|
|
||||||
function noInputFunction()
|
|
||||||
external
|
|
||||||
pure
|
|
||||||
{
|
|
||||||
assert(msg.data.length == 4 && msg.data.readBytes4(0) == bytes4(keccak256("noInputFunction()")));
|
|
||||||
}
|
|
||||||
|
|
||||||
function dynamicInputFunction(bytes calldata a)
|
|
||||||
external
|
|
||||||
pure
|
|
||||||
{
|
|
||||||
bytes memory abiEncodedData = abi.encodeWithSignature("dynamicInputFunction(bytes)", a);
|
|
||||||
assert(msg.data.equals(abiEncodedData));
|
|
||||||
}
|
|
||||||
|
|
||||||
function returnComplexType(uint256 a, uint256 b)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (bytes memory result)
|
|
||||||
{
|
|
||||||
result = abi.encodePacked(
|
|
||||||
address(this),
|
|
||||||
a,
|
|
||||||
b
|
|
||||||
);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,432 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
|
|
||||||
import "../src/bridges/UniswapBridge.sol";
|
|
||||||
import "../src/interfaces/IUniswapExchangeFactory.sol";
|
|
||||||
import "../src/interfaces/IUniswapExchange.sol";
|
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable no-simple-event-func-name
|
|
||||||
contract TestEventsRaiser {
|
|
||||||
|
|
||||||
event TokenTransfer(
|
|
||||||
address token,
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount
|
|
||||||
);
|
|
||||||
|
|
||||||
event TokenApprove(
|
|
||||||
address spender,
|
|
||||||
uint256 allowance
|
|
||||||
);
|
|
||||||
|
|
||||||
event WethDeposit(
|
|
||||||
uint256 amount
|
|
||||||
);
|
|
||||||
|
|
||||||
event WethWithdraw(
|
|
||||||
uint256 amount
|
|
||||||
);
|
|
||||||
|
|
||||||
event EthToTokenTransferInput(
|
|
||||||
address exchange,
|
|
||||||
uint256 minTokensBought,
|
|
||||||
uint256 deadline,
|
|
||||||
address recipient
|
|
||||||
);
|
|
||||||
|
|
||||||
event TokenToEthSwapInput(
|
|
||||||
address exchange,
|
|
||||||
uint256 tokensSold,
|
|
||||||
uint256 minEthBought,
|
|
||||||
uint256 deadline
|
|
||||||
);
|
|
||||||
|
|
||||||
event TokenToTokenTransferInput(
|
|
||||||
address exchange,
|
|
||||||
uint256 tokensSold,
|
|
||||||
uint256 minTokensBought,
|
|
||||||
uint256 minEthBought,
|
|
||||||
uint256 deadline,
|
|
||||||
address recipient,
|
|
||||||
address toTokenAddress
|
|
||||||
);
|
|
||||||
|
|
||||||
function raiseEthToTokenTransferInput(
|
|
||||||
uint256 minTokensBought,
|
|
||||||
uint256 deadline,
|
|
||||||
address recipient
|
|
||||||
)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
emit EthToTokenTransferInput(
|
|
||||||
msg.sender,
|
|
||||||
minTokensBought,
|
|
||||||
deadline,
|
|
||||||
recipient
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function raiseTokenToEthSwapInput(
|
|
||||||
uint256 tokensSold,
|
|
||||||
uint256 minEthBought,
|
|
||||||
uint256 deadline
|
|
||||||
)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
emit TokenToEthSwapInput(
|
|
||||||
msg.sender,
|
|
||||||
tokensSold,
|
|
||||||
minEthBought,
|
|
||||||
deadline
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function raiseTokenToTokenTransferInput(
|
|
||||||
uint256 tokensSold,
|
|
||||||
uint256 minTokensBought,
|
|
||||||
uint256 minEthBought,
|
|
||||||
uint256 deadline,
|
|
||||||
address recipient,
|
|
||||||
address toTokenAddress
|
|
||||||
)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
emit TokenToTokenTransferInput(
|
|
||||||
msg.sender,
|
|
||||||
tokensSold,
|
|
||||||
minTokensBought,
|
|
||||||
minEthBought,
|
|
||||||
deadline,
|
|
||||||
recipient,
|
|
||||||
toTokenAddress
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function raiseTokenTransfer(
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
emit TokenTransfer(
|
|
||||||
msg.sender,
|
|
||||||
from,
|
|
||||||
to,
|
|
||||||
amount
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function raiseTokenApprove(address spender, uint256 allowance)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
emit TokenApprove(spender, allowance);
|
|
||||||
}
|
|
||||||
|
|
||||||
function raiseWethDeposit(uint256 amount)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
emit WethDeposit(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
function raiseWethWithdraw(uint256 amount)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
emit WethWithdraw(amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// @dev A minimalist ERC20/WETH token.
|
|
||||||
contract TestToken {
|
|
||||||
|
|
||||||
using LibSafeMath for uint256;
|
|
||||||
|
|
||||||
mapping (address => uint256) public balances;
|
|
||||||
string private _nextRevertReason;
|
|
||||||
|
|
||||||
/// @dev Set the balance for `owner`.
|
|
||||||
function setBalance(address owner)
|
|
||||||
external
|
|
||||||
payable
|
|
||||||
{
|
|
||||||
balances[owner] = msg.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Set the revert reason for `transfer()`,
|
|
||||||
/// `deposit()`, and `withdraw()`.
|
|
||||||
function setRevertReason(string calldata reason)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
_nextRevertReason = reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Just calls `raiseTokenTransfer()` on the caller.
|
|
||||||
function transfer(address to, uint256 amount)
|
|
||||||
external
|
|
||||||
returns (bool)
|
|
||||||
{
|
|
||||||
_revertIfReasonExists();
|
|
||||||
TestEventsRaiser(msg.sender).raiseTokenTransfer(msg.sender, to, amount);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Just calls `raiseTokenApprove()` on the caller.
|
|
||||||
function approve(address spender, uint256 allowance)
|
|
||||||
external
|
|
||||||
returns (bool)
|
|
||||||
{
|
|
||||||
TestEventsRaiser(msg.sender).raiseTokenApprove(spender, allowance);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev `IWETH.deposit()` that increases balances and calls
|
|
||||||
/// `raiseWethDeposit()` on the caller.
|
|
||||||
function deposit()
|
|
||||||
external
|
|
||||||
payable
|
|
||||||
{
|
|
||||||
_revertIfReasonExists();
|
|
||||||
balances[msg.sender] += balances[msg.sender].safeAdd(msg.value);
|
|
||||||
TestEventsRaiser(msg.sender).raiseWethDeposit(msg.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev `IWETH.withdraw()` that just reduces balances and calls
|
|
||||||
/// `raiseWethWithdraw()` on the caller.
|
|
||||||
function withdraw(uint256 amount)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
_revertIfReasonExists();
|
|
||||||
balances[msg.sender] = balances[msg.sender].safeSub(amount);
|
|
||||||
msg.sender.transfer(amount);
|
|
||||||
TestEventsRaiser(msg.sender).raiseWethWithdraw(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Retrieve the balance for `owner`.
|
|
||||||
function balanceOf(address owner)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (uint256)
|
|
||||||
{
|
|
||||||
return balances[owner];
|
|
||||||
}
|
|
||||||
|
|
||||||
function _revertIfReasonExists()
|
|
||||||
private
|
|
||||||
view
|
|
||||||
{
|
|
||||||
if (bytes(_nextRevertReason).length != 0) {
|
|
||||||
revert(_nextRevertReason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
contract TestExchange is
|
|
||||||
IUniswapExchange
|
|
||||||
{
|
|
||||||
address public tokenAddress;
|
|
||||||
string private _nextRevertReason;
|
|
||||||
|
|
||||||
constructor(address _tokenAddress) public {
|
|
||||||
tokenAddress = _tokenAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setFillBehavior(
|
|
||||||
string calldata revertReason
|
|
||||||
)
|
|
||||||
external
|
|
||||||
payable
|
|
||||||
{
|
|
||||||
_nextRevertReason = revertReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ethToTokenTransferInput(
|
|
||||||
uint256 minTokensBought,
|
|
||||||
uint256 deadline,
|
|
||||||
address recipient
|
|
||||||
)
|
|
||||||
external
|
|
||||||
payable
|
|
||||||
returns (uint256 tokensBought)
|
|
||||||
{
|
|
||||||
TestEventsRaiser(msg.sender).raiseEthToTokenTransferInput(
|
|
||||||
minTokensBought,
|
|
||||||
deadline,
|
|
||||||
recipient
|
|
||||||
);
|
|
||||||
_revertIfReasonExists();
|
|
||||||
return address(this).balance;
|
|
||||||
}
|
|
||||||
|
|
||||||
function tokenToEthSwapInput(
|
|
||||||
uint256 tokensSold,
|
|
||||||
uint256 minEthBought,
|
|
||||||
uint256 deadline
|
|
||||||
)
|
|
||||||
external
|
|
||||||
returns (uint256 ethBought)
|
|
||||||
{
|
|
||||||
TestEventsRaiser(msg.sender).raiseTokenToEthSwapInput(
|
|
||||||
tokensSold,
|
|
||||||
minEthBought,
|
|
||||||
deadline
|
|
||||||
);
|
|
||||||
_revertIfReasonExists();
|
|
||||||
uint256 fillAmount = address(this).balance;
|
|
||||||
msg.sender.transfer(fillAmount);
|
|
||||||
return fillAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
function tokenToTokenTransferInput(
|
|
||||||
uint256 tokensSold,
|
|
||||||
uint256 minTokensBought,
|
|
||||||
uint256 minEthBought,
|
|
||||||
uint256 deadline,
|
|
||||||
address recipient,
|
|
||||||
address toTokenAddress
|
|
||||||
)
|
|
||||||
external
|
|
||||||
returns (uint256 tokensBought)
|
|
||||||
{
|
|
||||||
TestEventsRaiser(msg.sender).raiseTokenToTokenTransferInput(
|
|
||||||
tokensSold,
|
|
||||||
minTokensBought,
|
|
||||||
minEthBought,
|
|
||||||
deadline,
|
|
||||||
recipient,
|
|
||||||
toTokenAddress
|
|
||||||
);
|
|
||||||
_revertIfReasonExists();
|
|
||||||
return address(this).balance;
|
|
||||||
}
|
|
||||||
|
|
||||||
function toTokenAddress()
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (address _tokenAddress)
|
|
||||||
{
|
|
||||||
return tokenAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _revertIfReasonExists()
|
|
||||||
private
|
|
||||||
view
|
|
||||||
{
|
|
||||||
if (bytes(_nextRevertReason).length != 0) {
|
|
||||||
revert(_nextRevertReason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// @dev UniswapBridge overridden to mock tokens and implement IUniswapExchangeFactory.
|
|
||||||
contract TestUniswapBridge is
|
|
||||||
IUniswapExchangeFactory,
|
|
||||||
TestEventsRaiser,
|
|
||||||
UniswapBridge
|
|
||||||
{
|
|
||||||
TestToken public wethToken;
|
|
||||||
// Token address to TestToken instance.
|
|
||||||
mapping (address => TestToken) private _testTokens;
|
|
||||||
// Token address to TestExchange instance.
|
|
||||||
mapping (address => TestExchange) private _testExchanges;
|
|
||||||
|
|
||||||
constructor() public {
|
|
||||||
wethToken = new TestToken();
|
|
||||||
_testTokens[address(wethToken)] = wethToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Sets the balance of this contract for an existing token.
|
|
||||||
/// The wei attached will be the balance.
|
|
||||||
function setTokenBalance(address tokenAddress)
|
|
||||||
external
|
|
||||||
payable
|
|
||||||
{
|
|
||||||
TestToken token = _testTokens[tokenAddress];
|
|
||||||
token.deposit.value(msg.value)();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Sets the revert reason for an existing token.
|
|
||||||
function setTokenRevertReason(address tokenAddress, string calldata revertReason)
|
|
||||||
external
|
|
||||||
{
|
|
||||||
TestToken token = _testTokens[tokenAddress];
|
|
||||||
token.setRevertReason(revertReason);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Create a token and exchange (if they don't exist) for a new token
|
|
||||||
/// and sets the exchange revert and fill behavior. The wei attached
|
|
||||||
/// will be the fill amount for the exchange.
|
|
||||||
/// @param tokenAddress The token address. If zero, one will be created.
|
|
||||||
/// @param revertReason The revert reason for exchange operations.
|
|
||||||
function createTokenAndExchange(
|
|
||||||
address tokenAddress,
|
|
||||||
string calldata revertReason
|
|
||||||
)
|
|
||||||
external
|
|
||||||
payable
|
|
||||||
returns (TestToken token, TestExchange exchange)
|
|
||||||
{
|
|
||||||
token = TestToken(tokenAddress);
|
|
||||||
if (tokenAddress == address(0)) {
|
|
||||||
token = new TestToken();
|
|
||||||
}
|
|
||||||
_testTokens[address(token)] = token;
|
|
||||||
exchange = _testExchanges[address(token)];
|
|
||||||
if (address(exchange) == address(0)) {
|
|
||||||
_testExchanges[address(token)] = exchange = new TestExchange(address(token));
|
|
||||||
}
|
|
||||||
exchange.setFillBehavior.value(msg.value)(revertReason);
|
|
||||||
return (token, exchange);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev `IUniswapExchangeFactory.getExchange`
|
|
||||||
function getExchange(address tokenAddress)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (IUniswapExchange)
|
|
||||||
{
|
|
||||||
return IUniswapExchange(_testExchanges[tokenAddress]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @dev Use `wethToken`.
|
|
||||||
function getWethContract()
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (IEtherToken)
|
|
||||||
{
|
|
||||||
return IEtherToken(address(wethToken));
|
|
||||||
}
|
|
||||||
|
|
||||||
// @dev This contract will double as the Uniswap contract.
|
|
||||||
function getUniswapExchangeFactoryContract()
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (IUniswapExchangeFactory)
|
|
||||||
{
|
|
||||||
return IUniswapExchangeFactory(address(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@0x/contracts-asset-proxy",
|
|
||||||
"version": "2.3.0-beta.3",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6.12"
|
|
||||||
},
|
|
||||||
"description": "Smart contract components of 0x protocol",
|
|
||||||
"main": "lib/src/index.js",
|
|
||||||
"directories": {
|
|
||||||
"test": "test"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"build": "yarn pre_build && tsc -b",
|
|
||||||
"build:ci": "yarn build",
|
|
||||||
"pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy",
|
|
||||||
"test": "yarn run_mocha",
|
|
||||||
"rebuild_and_test": "run-s build test",
|
|
||||||
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
|
|
||||||
"test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html",
|
|
||||||
"test:trace": "SOLIDITY_REVERT_TRACE=true run-s build run_mocha",
|
|
||||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit",
|
|
||||||
"compile": "sol-compiler",
|
|
||||||
"watch": "sol-compiler -w",
|
|
||||||
"clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers",
|
|
||||||
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers",
|
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
|
||||||
"coverage:report:text": "istanbul report text",
|
|
||||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
|
||||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
|
||||||
"coverage:report:lcov": "istanbul report lcov",
|
|
||||||
"test:circleci": "yarn test",
|
|
||||||
"contracts:gen": "contracts-gen generate",
|
|
||||||
"contracts:copy": "contracts-gen copy",
|
|
||||||
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol",
|
|
||||||
"compile:truffle": "truffle compile",
|
|
||||||
"docs:md": "ts-doc-gen --sourceDir='$PROJECT_FILES' --output=$MD_FILE_DIR --fileExtension=mdx --tsconfig=./typedoc-tsconfig.json",
|
|
||||||
"docs:json": "typedoc --excludePrivate --excludeExternals --excludeProtected --ignoreCompilerErrors --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"publicInterfaceContracts": "ERC1155Proxy,ERC20Proxy,ERC721Proxy,MultiAssetProxy,StaticCallProxy,ERC20BridgeProxy,Eth2DaiBridge,IAssetData,IAssetProxy,UniswapBridge,TestStaticCallTarget",
|
|
||||||
"abis": "./test/generated-artifacts/@(ERC1155Proxy|ERC20BridgeProxy|ERC20Proxy|ERC721Proxy|Eth2DaiBridge|IAssetData|IAssetProxy|IAssetProxyDispatcher|IAuthorizable|IERC20Bridge|IEth2Dai|IUniswapExchange|IUniswapExchangeFactory|MixinAssetProxyDispatcher|MixinAuthorizable|MultiAssetProxy|Ownable|StaticCallProxy|TestERC20Bridge|TestEth2DaiBridge|TestStaticCallTarget|TestUniswapBridge|UniswapBridge).json",
|
|
||||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/0xProject/0x-monorepo.git"
|
|
||||||
},
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/0xProject/0x-monorepo/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
|
|
||||||
"devDependencies": {
|
|
||||||
"@0x/abi-gen": "^4.4.0-beta.3",
|
|
||||||
"@0x/contracts-gen": "^1.1.0-beta.3",
|
|
||||||
"@0x/contracts-test-utils": "^3.2.0-beta.3",
|
|
||||||
"@0x/contracts-utils": "^3.3.0-beta.3",
|
|
||||||
"@0x/dev-utils": "^2.4.0-beta.3",
|
|
||||||
"@0x/sol-compiler": "^3.2.0-beta.3",
|
|
||||||
"@0x/ts-doc-gen": "^0.0.22",
|
|
||||||
"@0x/tslint-config": "^3.1.0-beta.2",
|
|
||||||
"@0x/types": "^2.5.0-beta.2",
|
|
||||||
"@types/lodash": "4.14.104",
|
|
||||||
"@types/mocha": "^5.2.7",
|
|
||||||
"@types/node": "*",
|
|
||||||
"chai": "^4.0.1",
|
|
||||||
"chai-as-promised": "^7.1.0",
|
|
||||||
"chai-bignumber": "^3.0.0",
|
|
||||||
"dirty-chai": "^2.0.1",
|
|
||||||
"ethereumjs-util": "^5.1.1",
|
|
||||||
"make-promises-safe": "^1.1.0",
|
|
||||||
"mocha": "^6.2.0",
|
|
||||||
"npm-run-all": "^4.1.2",
|
|
||||||
"shx": "^0.2.2",
|
|
||||||
"solhint": "^1.4.1",
|
|
||||||
"truffle": "^5.0.32",
|
|
||||||
"tslint": "5.11.0",
|
|
||||||
"typedoc": "^0.15.0",
|
|
||||||
"typescript": "3.0.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@0x/base-contract": "^5.5.0-beta.3",
|
|
||||||
"@0x/contracts-dev-utils": "^0.1.0-beta.3",
|
|
||||||
"@0x/contracts-erc1155": "^1.2.0-beta.3",
|
|
||||||
"@0x/contracts-erc20": "^2.3.0-beta.3",
|
|
||||||
"@0x/contracts-erc721": "^2.2.0-beta.3",
|
|
||||||
"@0x/order-utils": "^8.5.0-beta.3",
|
|
||||||
"@0x/typescript-typings": "^4.4.0-beta.2",
|
|
||||||
"@0x/utils": "^4.6.0-beta.2",
|
|
||||||
"@0x/web3-wrapper": "^6.1.0-beta.2",
|
|
||||||
"ethereum-types": "^2.2.0-beta.2",
|
|
||||||
"lodash": "^4.17.11"
|
|
||||||
},
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
import { ContractArtifact } from 'ethereum-types';
|
|
||||||
|
|
||||||
import * as ERC1155Proxy from '../generated-artifacts/ERC1155Proxy.json';
|
|
||||||
import * as ERC20BridgeProxy from '../generated-artifacts/ERC20BridgeProxy.json';
|
|
||||||
import * as ERC20Proxy from '../generated-artifacts/ERC20Proxy.json';
|
|
||||||
import * as ERC721Proxy from '../generated-artifacts/ERC721Proxy.json';
|
|
||||||
import * as Eth2DaiBridge from '../generated-artifacts/Eth2DaiBridge.json';
|
|
||||||
import * as IAssetData from '../generated-artifacts/IAssetData.json';
|
|
||||||
import * as IAssetProxy from '../generated-artifacts/IAssetProxy.json';
|
|
||||||
import * as MultiAssetProxy from '../generated-artifacts/MultiAssetProxy.json';
|
|
||||||
import * as StaticCallProxy from '../generated-artifacts/StaticCallProxy.json';
|
|
||||||
import * as TestStaticCallTarget from '../generated-artifacts/TestStaticCallTarget.json';
|
|
||||||
import * as UniswapBridge from '../generated-artifacts/UniswapBridge.json';
|
|
||||||
export const artifacts = {
|
|
||||||
ERC1155Proxy: ERC1155Proxy as ContractArtifact,
|
|
||||||
ERC20Proxy: ERC20Proxy as ContractArtifact,
|
|
||||||
ERC721Proxy: ERC721Proxy as ContractArtifact,
|
|
||||||
MultiAssetProxy: MultiAssetProxy as ContractArtifact,
|
|
||||||
StaticCallProxy: StaticCallProxy as ContractArtifact,
|
|
||||||
ERC20BridgeProxy: ERC20BridgeProxy as ContractArtifact,
|
|
||||||
Eth2DaiBridge: Eth2DaiBridge as ContractArtifact,
|
|
||||||
IAssetData: IAssetData as ContractArtifact,
|
|
||||||
IAssetProxy: IAssetProxy as ContractArtifact,
|
|
||||||
UniswapBridge: UniswapBridge as ContractArtifact,
|
|
||||||
TestStaticCallTarget: TestStaticCallTarget as ContractArtifact,
|
|
||||||
};
|
|
||||||
@@ -1,411 +0,0 @@
|
|||||||
import { DevUtilsContract } from '@0x/contracts-dev-utils';
|
|
||||||
import { artifacts as erc1155Artifacts, ERC1155MintableContract, Erc1155Wrapper } from '@0x/contracts-erc1155';
|
|
||||||
import {
|
|
||||||
constants,
|
|
||||||
ERC1155FungibleHoldingsByOwner,
|
|
||||||
ERC1155HoldingsByOwner,
|
|
||||||
ERC1155NonFungibleHoldingsByOwner,
|
|
||||||
LogDecoder,
|
|
||||||
txDefaults,
|
|
||||||
} from '@0x/contracts-test-utils';
|
|
||||||
import { BigNumber } from '@0x/utils';
|
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
|
||||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
|
|
||||||
import { ERC1155ProxyContract, IAssetProxyContract } from './wrappers';
|
|
||||||
|
|
||||||
export class ERC1155ProxyWrapper {
|
|
||||||
private readonly _tokenOwnerAddresses: string[];
|
|
||||||
private readonly _fungibleTokenIds: string[];
|
|
||||||
private readonly _nonFungibleTokenIds: string[];
|
|
||||||
private readonly _nfts: Array<{ id: BigNumber; tokenId: BigNumber }>;
|
|
||||||
private readonly _contractOwnerAddress: string;
|
|
||||||
private readonly _web3Wrapper: Web3Wrapper;
|
|
||||||
private readonly _provider: Provider;
|
|
||||||
private readonly _logDecoder: LogDecoder;
|
|
||||||
private readonly _dummyTokenWrappers: Erc1155Wrapper[];
|
|
||||||
private readonly _assetProxyInterface: IAssetProxyContract;
|
|
||||||
private readonly _devUtils: DevUtilsContract;
|
|
||||||
private _proxyContract?: ERC1155ProxyContract;
|
|
||||||
private _proxyIdIfExists?: string;
|
|
||||||
private _initialTokenIdsByOwner: ERC1155HoldingsByOwner = { fungible: {}, nonFungible: {} };
|
|
||||||
|
|
||||||
constructor(provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
|
|
||||||
this._web3Wrapper = new Web3Wrapper(provider);
|
|
||||||
this._provider = provider;
|
|
||||||
const allArtifacts = _.merge(artifacts, erc1155Artifacts);
|
|
||||||
this._logDecoder = new LogDecoder(this._web3Wrapper, allArtifacts);
|
|
||||||
this._dummyTokenWrappers = [];
|
|
||||||
this._assetProxyInterface = new IAssetProxyContract(constants.NULL_ADDRESS, provider);
|
|
||||||
this._devUtils = new DevUtilsContract(constants.NULL_ADDRESS, provider);
|
|
||||||
this._tokenOwnerAddresses = tokenOwnerAddresses;
|
|
||||||
this._contractOwnerAddress = contractOwnerAddress;
|
|
||||||
this._fungibleTokenIds = [];
|
|
||||||
this._nonFungibleTokenIds = [];
|
|
||||||
this._nfts = [];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @dev Deploys dummy ERC1155 contracts
|
|
||||||
* @return An array of ERC1155 wrappers; one for each deployed contract.
|
|
||||||
*/
|
|
||||||
public async deployDummyContractsAsync(): Promise<Erc1155Wrapper[]> {
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
for (const i of _.times(constants.NUM_DUMMY_ERC1155_CONTRACTS_TO_DEPLOY)) {
|
|
||||||
const erc1155Contract = await ERC1155MintableContract.deployFrom0xArtifactAsync(
|
|
||||||
erc1155Artifacts.ERC1155Mintable,
|
|
||||||
this._provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
const erc1155Wrapper = new Erc1155Wrapper(erc1155Contract, this._provider, this._contractOwnerAddress);
|
|
||||||
this._dummyTokenWrappers.push(erc1155Wrapper);
|
|
||||||
}
|
|
||||||
return this._dummyTokenWrappers;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @dev Deploys the ERC1155 proxy
|
|
||||||
* @return Deployed ERC1155 proxy contract instance
|
|
||||||
*/
|
|
||||||
public async deployProxyAsync(): Promise<ERC1155ProxyContract> {
|
|
||||||
this._proxyContract = await ERC1155ProxyContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.ERC1155Proxy,
|
|
||||||
this._provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync();
|
|
||||||
return this._proxyContract;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @dev Gets the ERC1155 proxy id
|
|
||||||
*/
|
|
||||||
public getProxyId(): string {
|
|
||||||
this._validateProxyContractExistsOrThrow();
|
|
||||||
return this._proxyIdIfExists as string;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @dev generates abi-encoded tx data for transferring erc1155 fungible/non-fungible tokens.
|
|
||||||
* @param from source address
|
|
||||||
* @param to destination address
|
|
||||||
* @param contractAddress address of erc155 contract
|
|
||||||
* @param tokensToTransfer array of erc1155 tokens to transfer
|
|
||||||
* @param valuesToTransfer array of corresponding values for each erc1155 token to transfer
|
|
||||||
* @param valueMultiplier each value in `valuesToTransfer` is multiplied by this
|
|
||||||
* @param receiverCallbackData callback data if `to` is a contract
|
|
||||||
* @param authorizedSender sender of `transferFrom` transaction
|
|
||||||
* @param extraData extra data to append to `transferFrom` transaction. Optional.
|
|
||||||
* @return abi encoded tx data.
|
|
||||||
*/
|
|
||||||
public async getTransferFromAbiEncodedTxDataAsync(
|
|
||||||
from: string,
|
|
||||||
to: string,
|
|
||||||
contractAddress: string,
|
|
||||||
tokensToTransfer: BigNumber[],
|
|
||||||
valuesToTransfer: BigNumber[],
|
|
||||||
valueMultiplier: BigNumber,
|
|
||||||
receiverCallbackData: string,
|
|
||||||
authorizedSender: string,
|
|
||||||
assetData_?: string,
|
|
||||||
): Promise<string> {
|
|
||||||
this._validateProxyContractExistsOrThrow();
|
|
||||||
const assetData =
|
|
||||||
assetData_ === undefined
|
|
||||||
? await this._devUtils
|
|
||||||
.encodeERC1155AssetData(contractAddress, tokensToTransfer, valuesToTransfer, receiverCallbackData)
|
|
||||||
.callAsync()
|
|
||||||
: assetData_;
|
|
||||||
const data = this._assetProxyInterface
|
|
||||||
.transferFrom(assetData, from, to, valueMultiplier)
|
|
||||||
.getABIEncodedTransactionData();
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @dev transfers erc1155 fungible/non-fungible tokens.
|
|
||||||
* @param txData: abi-encoded tx data
|
|
||||||
* @param authorizedSender sender of `transferFrom` transaction
|
|
||||||
*/
|
|
||||||
public async transferFromRawAsync(
|
|
||||||
txData: string,
|
|
||||||
authorizedSender: string,
|
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
|
||||||
const txHash = await this._web3Wrapper.sendTransactionAsync({
|
|
||||||
to: (this._proxyContract as ERC1155ProxyContract).address,
|
|
||||||
data: txData,
|
|
||||||
from: authorizedSender,
|
|
||||||
gas: 300000,
|
|
||||||
});
|
|
||||||
const txReceipt = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
|
||||||
return txReceipt;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @dev transfers erc1155 fungible/non-fungible tokens.
|
|
||||||
* @param from source address
|
|
||||||
* @param to destination address
|
|
||||||
* @param contractAddress address of erc155 contract
|
|
||||||
* @param tokensToTransfer array of erc1155 tokens to transfer
|
|
||||||
* @param valuesToTransfer array of corresponding values for each erc1155 token to transfer
|
|
||||||
* @param valueMultiplier each value in `valuesToTransfer` is multiplied by this
|
|
||||||
* @param receiverCallbackData callback data if `to` is a contract
|
|
||||||
* @param authorizedSender sender of `transferFrom` transaction
|
|
||||||
* @param extraData extra data to append to `transferFrom` transaction. Optional.
|
|
||||||
* @return tranasction hash.
|
|
||||||
*/
|
|
||||||
public async transferFromAsync(
|
|
||||||
from: string,
|
|
||||||
to: string,
|
|
||||||
contractAddress: string,
|
|
||||||
tokensToTransfer: BigNumber[],
|
|
||||||
valuesToTransfer: BigNumber[],
|
|
||||||
valueMultiplier: BigNumber,
|
|
||||||
receiverCallbackData: string,
|
|
||||||
authorizedSender: string,
|
|
||||||
assetData_?: string,
|
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
|
||||||
this._validateProxyContractExistsOrThrow();
|
|
||||||
const assetData =
|
|
||||||
assetData_ === undefined
|
|
||||||
? await this._devUtils
|
|
||||||
.encodeERC1155AssetData(contractAddress, tokensToTransfer, valuesToTransfer, receiverCallbackData)
|
|
||||||
.callAsync()
|
|
||||||
: assetData_;
|
|
||||||
const data = this._assetProxyInterface
|
|
||||||
.transferFrom(assetData, from, to, valueMultiplier)
|
|
||||||
.getABIEncodedTransactionData();
|
|
||||||
const txHash = await this._web3Wrapper.sendTransactionAsync({
|
|
||||||
to: (this._proxyContract as ERC1155ProxyContract).address,
|
|
||||||
data,
|
|
||||||
from: authorizedSender,
|
|
||||||
gas: 300000,
|
|
||||||
});
|
|
||||||
const txReceipt = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
|
||||||
return txReceipt;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @dev For each deployed ERC1155 contract, this function mints a set of fungible/non-fungible
|
|
||||||
* tokens for each token owner address (`_tokenOwnerAddresses`).
|
|
||||||
* @return Balances of each token owner, across all ERC1155 contracts and tokens.
|
|
||||||
*/
|
|
||||||
public async setBalancesAndAllowancesAsync(): Promise<ERC1155HoldingsByOwner> {
|
|
||||||
this._validateDummyTokenContractsExistOrThrow();
|
|
||||||
this._validateProxyContractExistsOrThrow();
|
|
||||||
this._initialTokenIdsByOwner = {
|
|
||||||
fungible: {},
|
|
||||||
nonFungible: {},
|
|
||||||
};
|
|
||||||
const fungibleHoldingsByOwner: ERC1155FungibleHoldingsByOwner = {};
|
|
||||||
const nonFungibleHoldingsByOwner: ERC1155NonFungibleHoldingsByOwner = {};
|
|
||||||
// Set balances accordingly
|
|
||||||
for (const dummyWrapper of this._dummyTokenWrappers) {
|
|
||||||
const dummyAddress = dummyWrapper.getContract().address;
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
for (const i of _.times(constants.NUM_ERC1155_FUNGIBLE_TOKENS_MINT)) {
|
|
||||||
// Create a fungible token
|
|
||||||
const tokenId = await dummyWrapper.mintFungibleTokensAsync(
|
|
||||||
this._tokenOwnerAddresses,
|
|
||||||
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
|
|
||||||
);
|
|
||||||
const tokenIdAsString = tokenId.toString();
|
|
||||||
this._fungibleTokenIds.push(tokenIdAsString);
|
|
||||||
// Mint tokens for each owner for this token
|
|
||||||
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
if (fungibleHoldingsByOwner[tokenOwnerAddress] === undefined) {
|
|
||||||
fungibleHoldingsByOwner[tokenOwnerAddress] = {};
|
|
||||||
}
|
|
||||||
if (fungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress] === undefined) {
|
|
||||||
fungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress] = {};
|
|
||||||
}
|
|
||||||
fungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress][tokenIdAsString] =
|
|
||||||
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE;
|
|
||||||
await dummyWrapper.setApprovalForAllAsync(
|
|
||||||
tokenOwnerAddress,
|
|
||||||
(this._proxyContract as ERC1155ProxyContract).address,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Non-fungible tokens
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
for (const j of _.times(constants.NUM_ERC1155_NONFUNGIBLE_TOKENS_MINT)) {
|
|
||||||
const [tokenId, nftIds] = await dummyWrapper.mintNonFungibleTokensAsync(this._tokenOwnerAddresses);
|
|
||||||
const tokenIdAsString = tokenId.toString();
|
|
||||||
this._nonFungibleTokenIds.push(tokenIdAsString);
|
|
||||||
_.each(this._tokenOwnerAddresses, async (tokenOwnerAddress: string, i: number) => {
|
|
||||||
if (nonFungibleHoldingsByOwner[tokenOwnerAddress] === undefined) {
|
|
||||||
nonFungibleHoldingsByOwner[tokenOwnerAddress] = {};
|
|
||||||
}
|
|
||||||
if (nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress] === undefined) {
|
|
||||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress] = {};
|
|
||||||
}
|
|
||||||
if (nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress][tokenIdAsString] === undefined) {
|
|
||||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress][tokenIdAsString] = [];
|
|
||||||
}
|
|
||||||
this._nfts.push({ id: nftIds[i], tokenId });
|
|
||||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress][tokenIdAsString].push(nftIds[i]);
|
|
||||||
await dummyWrapper.setApprovalForAllAsync(
|
|
||||||
tokenOwnerAddress,
|
|
||||||
(this._proxyContract as ERC1155ProxyContract).address,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._initialTokenIdsByOwner = {
|
|
||||||
fungible: fungibleHoldingsByOwner,
|
|
||||||
nonFungible: nonFungibleHoldingsByOwner,
|
|
||||||
};
|
|
||||||
return this._initialTokenIdsByOwner;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @dev For each deployed ERC1155 contract, this function quieries the set of fungible/non-fungible
|
|
||||||
* tokens for each token owner address (`_tokenOwnerAddresses`).
|
|
||||||
* @return Balances of each token owner, across all ERC1155 contracts and tokens.
|
|
||||||
*/
|
|
||||||
public async getBalancesAsync(): Promise<ERC1155HoldingsByOwner> {
|
|
||||||
this._validateDummyTokenContractsExistOrThrow();
|
|
||||||
this._validateBalancesAndAllowancesSetOrThrow();
|
|
||||||
const tokenHoldingsByOwner: ERC1155FungibleHoldingsByOwner = {};
|
|
||||||
const nonFungibleHoldingsByOwner: ERC1155NonFungibleHoldingsByOwner = {};
|
|
||||||
for (const dummyTokenWrapper of this._dummyTokenWrappers) {
|
|
||||||
const tokenContract = dummyTokenWrapper.getContract();
|
|
||||||
const tokenAddress = tokenContract.address;
|
|
||||||
// Construct batch balance call
|
|
||||||
const tokenOwners: string[] = [];
|
|
||||||
const tokenIds: BigNumber[] = [];
|
|
||||||
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
|
||||||
for (const tokenId of this._fungibleTokenIds) {
|
|
||||||
tokenOwners.push(tokenOwnerAddress);
|
|
||||||
tokenIds.push(new BigNumber(tokenId));
|
|
||||||
}
|
|
||||||
for (const nft of this._nfts) {
|
|
||||||
tokenOwners.push(tokenOwnerAddress);
|
|
||||||
tokenIds.push(nft.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const balances = await dummyTokenWrapper.getBalancesAsync(tokenOwners, tokenIds);
|
|
||||||
// Parse out balances into fungible / non-fungible token holdings
|
|
||||||
let i = 0;
|
|
||||||
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
|
||||||
// Fungible tokens
|
|
||||||
for (const tokenId of this._fungibleTokenIds) {
|
|
||||||
if (tokenHoldingsByOwner[tokenOwnerAddress] === undefined) {
|
|
||||||
tokenHoldingsByOwner[tokenOwnerAddress] = {};
|
|
||||||
}
|
|
||||||
if (tokenHoldingsByOwner[tokenOwnerAddress][tokenAddress] === undefined) {
|
|
||||||
tokenHoldingsByOwner[tokenOwnerAddress][tokenAddress] = {};
|
|
||||||
}
|
|
||||||
tokenHoldingsByOwner[tokenOwnerAddress][tokenAddress][tokenId] = balances[i++];
|
|
||||||
}
|
|
||||||
// Non-fungible tokens
|
|
||||||
for (const nft of this._nfts) {
|
|
||||||
if (nonFungibleHoldingsByOwner[tokenOwnerAddress] === undefined) {
|
|
||||||
nonFungibleHoldingsByOwner[tokenOwnerAddress] = {};
|
|
||||||
}
|
|
||||||
if (nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress] === undefined) {
|
|
||||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress] = {};
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress][nft.tokenId.toString()] ===
|
|
||||||
undefined
|
|
||||||
) {
|
|
||||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress][nft.tokenId.toString()] = [];
|
|
||||||
}
|
|
||||||
const isOwner = balances[i++];
|
|
||||||
if (isOwner.isEqualTo(1)) {
|
|
||||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress][nft.tokenId.toString()].push(
|
|
||||||
nft.id,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const holdingsByOwner = {
|
|
||||||
fungible: tokenHoldingsByOwner,
|
|
||||||
nonFungible: nonFungibleHoldingsByOwner,
|
|
||||||
};
|
|
||||||
return holdingsByOwner;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @dev Set the approval for the proxy on behalf of `userAddress` .
|
|
||||||
* @param userAddress owner of ERC1155 tokens.
|
|
||||||
* @param contractAddress address of ERC1155 contract.
|
|
||||||
* @param isApproved Whether to approve the proxy for all or not.
|
|
||||||
*/
|
|
||||||
public async setProxyAllowanceForAllAsync(
|
|
||||||
userAddress: string,
|
|
||||||
contractAddress: string,
|
|
||||||
isApproved: boolean,
|
|
||||||
): Promise<void> {
|
|
||||||
this._validateProxyContractExistsOrThrow();
|
|
||||||
const tokenWrapper = this.getContractWrapper(contractAddress);
|
|
||||||
const operator = (this._proxyContract as ERC1155ProxyContract).address;
|
|
||||||
await tokenWrapper.setApprovalForAllAsync(userAddress, operator, isApproved);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @dev Checks if proxy is approved to transfer tokens on behalf of `userAddress`.
|
|
||||||
* @param userAddress owner of ERC1155 tokens.
|
|
||||||
* @param contractAddress address of ERC1155 contract.
|
|
||||||
* @return True iff the proxy is approved for all. False otherwise.
|
|
||||||
*/
|
|
||||||
public async isProxyApprovedForAllAsync(userAddress: string, contractAddress: string): Promise<boolean> {
|
|
||||||
this._validateProxyContractExistsOrThrow();
|
|
||||||
const tokenContract = this._getContractFromAddress(contractAddress);
|
|
||||||
const operator = (this._proxyContract as ERC1155ProxyContract).address;
|
|
||||||
const didApproveAll = await tokenContract.isApprovedForAll(userAddress, operator).callAsync();
|
|
||||||
return didApproveAll;
|
|
||||||
}
|
|
||||||
public getFungibleTokenIds(): BigNumber[] {
|
|
||||||
const fungibleTokenIds = _.map(this._fungibleTokenIds, (tokenIdAsString: string) => {
|
|
||||||
return new BigNumber(tokenIdAsString);
|
|
||||||
});
|
|
||||||
return fungibleTokenIds;
|
|
||||||
}
|
|
||||||
public getNonFungibleTokenIds(): BigNumber[] {
|
|
||||||
const nonFungibleTokenIds = _.map(this._nonFungibleTokenIds, (tokenIdAsString: string) => {
|
|
||||||
return new BigNumber(tokenIdAsString);
|
|
||||||
});
|
|
||||||
return nonFungibleTokenIds;
|
|
||||||
}
|
|
||||||
public getTokenOwnerAddresses(): string[] {
|
|
||||||
return this._tokenOwnerAddresses;
|
|
||||||
}
|
|
||||||
public getContractWrapper(contractAddress: string): Erc1155Wrapper {
|
|
||||||
const tokenWrapper = _.find(this._dummyTokenWrappers, (wrapper: Erc1155Wrapper) => {
|
|
||||||
return wrapper.getContract().address === contractAddress;
|
|
||||||
});
|
|
||||||
if (tokenWrapper === undefined) {
|
|
||||||
throw new Error(`Contract: ${contractAddress} was not deployed through ERC1155ProxyWrapper`);
|
|
||||||
}
|
|
||||||
return tokenWrapper;
|
|
||||||
}
|
|
||||||
private _getContractFromAddress(tokenAddress: string): ERC1155MintableContract {
|
|
||||||
const tokenContractIfExists = _.find(this._dummyTokenWrappers, c => c.getContract().address === tokenAddress);
|
|
||||||
if (tokenContractIfExists === undefined) {
|
|
||||||
throw new Error(`Token: ${tokenAddress} was not deployed through ERC1155ProxyWrapper`);
|
|
||||||
}
|
|
||||||
return tokenContractIfExists.getContract();
|
|
||||||
}
|
|
||||||
private _validateDummyTokenContractsExistOrThrow(): void {
|
|
||||||
if (this._dummyTokenWrappers === undefined) {
|
|
||||||
throw new Error('Dummy ERC1155 tokens not yet deployed, please call "deployDummyTokensAsync"');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private _validateProxyContractExistsOrThrow(): void {
|
|
||||||
if (this._proxyContract === undefined) {
|
|
||||||
throw new Error('ERC1155 proxy contract not yet deployed, please call "deployProxyAsync"');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private _validateBalancesAndAllowancesSetOrThrow(): void {
|
|
||||||
if (
|
|
||||||
_.keys(this._initialTokenIdsByOwner.fungible).length === 0 ||
|
|
||||||
_.keys(this._initialTokenIdsByOwner.nonFungible).length === 0
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
'Dummy ERC1155 balances and allowances not yet set, please call "setBalancesAndAllowancesAsync"',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
import { DevUtilsContract } from '@0x/contracts-dev-utils';
|
|
||||||
import { artifacts as erc20Artifacts, DummyERC20TokenContract } from '@0x/contracts-erc20';
|
|
||||||
import { constants, ERC20BalancesByOwner, txDefaults } from '@0x/contracts-test-utils';
|
|
||||||
import { BigNumber } from '@0x/utils';
|
|
||||||
import { ZeroExProvider } from 'ethereum-types';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
|
|
||||||
import { ERC20ProxyContract } from './wrappers';
|
|
||||||
|
|
||||||
export class ERC20Wrapper {
|
|
||||||
private readonly _tokenOwnerAddresses: string[];
|
|
||||||
private readonly _contractOwnerAddress: string;
|
|
||||||
private readonly _provider: ZeroExProvider;
|
|
||||||
private readonly _dummyTokenContracts: DummyERC20TokenContract[];
|
|
||||||
private readonly _devUtils: DevUtilsContract;
|
|
||||||
private _proxyContract?: ERC20ProxyContract;
|
|
||||||
private _proxyIdIfExists?: string;
|
|
||||||
/**
|
|
||||||
* Instanitates an ERC20Wrapper
|
|
||||||
* @param provider Web3 provider to use for all JSON RPC requests
|
|
||||||
* @param tokenOwnerAddresses Addresses that we want to endow as owners for dummy ERC20 tokens
|
|
||||||
* @param contractOwnerAddress Desired owner of the contract
|
|
||||||
* Instance of ERC20Wrapper
|
|
||||||
*/
|
|
||||||
constructor(provider: ZeroExProvider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
|
|
||||||
this._dummyTokenContracts = [];
|
|
||||||
this._provider = provider;
|
|
||||||
this._tokenOwnerAddresses = tokenOwnerAddresses;
|
|
||||||
this._contractOwnerAddress = contractOwnerAddress;
|
|
||||||
this._devUtils = new DevUtilsContract(constants.NULL_ADDRESS, provider);
|
|
||||||
}
|
|
||||||
public async deployDummyTokensAsync(
|
|
||||||
numberToDeploy: number,
|
|
||||||
decimals: BigNumber,
|
|
||||||
): Promise<DummyERC20TokenContract[]> {
|
|
||||||
for (let i = 0; i < numberToDeploy; i++) {
|
|
||||||
this._dummyTokenContracts.push(
|
|
||||||
await DummyERC20TokenContract.deployFrom0xArtifactAsync(
|
|
||||||
erc20Artifacts.DummyERC20Token,
|
|
||||||
this._provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
constants.DUMMY_TOKEN_NAME,
|
|
||||||
constants.DUMMY_TOKEN_SYMBOL,
|
|
||||||
decimals,
|
|
||||||
constants.DUMMY_TOKEN_TOTAL_SUPPLY,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return this._dummyTokenContracts;
|
|
||||||
}
|
|
||||||
public async deployProxyAsync(): Promise<ERC20ProxyContract> {
|
|
||||||
this._proxyContract = await ERC20ProxyContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.ERC20Proxy,
|
|
||||||
this._provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync();
|
|
||||||
return this._proxyContract;
|
|
||||||
}
|
|
||||||
public getProxyId(): string {
|
|
||||||
this._validateProxyContractExistsOrThrow();
|
|
||||||
return this._proxyIdIfExists as string;
|
|
||||||
}
|
|
||||||
public async setBalancesAndAllowancesAsync(): Promise<void> {
|
|
||||||
this._validateDummyTokenContractsExistOrThrow();
|
|
||||||
this._validateProxyContractExistsOrThrow();
|
|
||||||
for (const dummyTokenContract of this._dummyTokenContracts) {
|
|
||||||
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
|
||||||
await dummyTokenContract
|
|
||||||
.setBalance(tokenOwnerAddress, constants.INITIAL_ERC20_BALANCE)
|
|
||||||
.awaitTransactionSuccessAsync({ from: this._contractOwnerAddress });
|
|
||||||
await dummyTokenContract
|
|
||||||
.approve((this._proxyContract as ERC20ProxyContract).address, constants.INITIAL_ERC20_ALLOWANCE)
|
|
||||||
.awaitTransactionSuccessAsync({ from: tokenOwnerAddress });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public async getBalanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
|
|
||||||
const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData);
|
|
||||||
const balance = new BigNumber(await tokenContract.balanceOf(userAddress).callAsync());
|
|
||||||
return balance;
|
|
||||||
}
|
|
||||||
public async setBalanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> {
|
|
||||||
const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData);
|
|
||||||
await tokenContract
|
|
||||||
.setBalance(userAddress, amount)
|
|
||||||
.awaitTransactionSuccessAsync(
|
|
||||||
{ from: this._contractOwnerAddress },
|
|
||||||
{ pollingIntervalMs: constants.AWAIT_TRANSACTION_MINED_MS },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
|
|
||||||
const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData);
|
|
||||||
const proxyAddress = (this._proxyContract as ERC20ProxyContract).address;
|
|
||||||
const allowance = new BigNumber(await tokenContract.allowance(userAddress, proxyAddress).callAsync());
|
|
||||||
return allowance;
|
|
||||||
}
|
|
||||||
public async setAllowanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> {
|
|
||||||
const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData);
|
|
||||||
const proxyAddress = (this._proxyContract as ERC20ProxyContract).address;
|
|
||||||
await tokenContract.approve(proxyAddress, amount).awaitTransactionSuccessAsync({ from: userAddress });
|
|
||||||
}
|
|
||||||
public async getBalancesAsync(): Promise<ERC20BalancesByOwner> {
|
|
||||||
this._validateDummyTokenContractsExistOrThrow();
|
|
||||||
const balancesByOwner: ERC20BalancesByOwner = {};
|
|
||||||
const balances: BigNumber[] = [];
|
|
||||||
const balanceInfo: Array<{ tokenOwnerAddress: string; tokenAddress: string }> = [];
|
|
||||||
for (const dummyTokenContract of this._dummyTokenContracts) {
|
|
||||||
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
|
||||||
balances.push(await dummyTokenContract.balanceOf(tokenOwnerAddress).callAsync());
|
|
||||||
balanceInfo.push({
|
|
||||||
tokenOwnerAddress,
|
|
||||||
tokenAddress: dummyTokenContract.address,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_.forEach(balances, (balance, balanceIndex) => {
|
|
||||||
const tokenAddress = balanceInfo[balanceIndex].tokenAddress;
|
|
||||||
const tokenOwnerAddress = balanceInfo[balanceIndex].tokenOwnerAddress;
|
|
||||||
if (balancesByOwner[tokenOwnerAddress] === undefined) {
|
|
||||||
balancesByOwner[tokenOwnerAddress] = {};
|
|
||||||
}
|
|
||||||
const wrappedBalance = new BigNumber(balance);
|
|
||||||
balancesByOwner[tokenOwnerAddress][tokenAddress] = wrappedBalance;
|
|
||||||
});
|
|
||||||
return balancesByOwner;
|
|
||||||
}
|
|
||||||
public addDummyTokenContract(dummy: DummyERC20TokenContract): void {
|
|
||||||
if (this._dummyTokenContracts !== undefined) {
|
|
||||||
this._dummyTokenContracts.push(dummy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public addTokenOwnerAddress(address: string): void {
|
|
||||||
this._tokenOwnerAddresses.push(address);
|
|
||||||
}
|
|
||||||
public getTokenOwnerAddresses(): string[] {
|
|
||||||
return this._tokenOwnerAddresses;
|
|
||||||
}
|
|
||||||
public getTokenAddresses(): string[] {
|
|
||||||
const tokenAddresses = _.map(this._dummyTokenContracts, dummyTokenContract => dummyTokenContract.address);
|
|
||||||
return tokenAddresses;
|
|
||||||
}
|
|
||||||
private async _getTokenContractFromAssetDataAsync(assetData: string): Promise<DummyERC20TokenContract> {
|
|
||||||
const [proxyId, tokenAddress] = await this._devUtils.decodeERC20AssetData(assetData).callAsync(); // tslint:disable-line:no-unused-variable
|
|
||||||
const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress);
|
|
||||||
if (tokenContractIfExists === undefined) {
|
|
||||||
throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`);
|
|
||||||
}
|
|
||||||
return tokenContractIfExists;
|
|
||||||
}
|
|
||||||
private _validateDummyTokenContractsExistOrThrow(): void {
|
|
||||||
if (this._dummyTokenContracts === undefined) {
|
|
||||||
throw new Error('Dummy ERC20 tokens not yet deployed, please call "deployDummyTokensAsync"');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private _validateProxyContractExistsOrThrow(): void {
|
|
||||||
if (this._proxyContract === undefined) {
|
|
||||||
throw new Error('ERC20 proxy contract not yet deployed, please call "deployProxyAsync"');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,220 +0,0 @@
|
|||||||
import { artifacts as erc721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721';
|
|
||||||
import { constants, ERC721TokenIdsByOwner, txDefaults } from '@0x/contracts-test-utils';
|
|
||||||
import { generatePseudoRandomSalt } from '@0x/order-utils';
|
|
||||||
import { BigNumber } from '@0x/utils';
|
|
||||||
import { ZeroExProvider } from 'ethereum-types';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
|
|
||||||
import { ERC721ProxyContract } from './wrappers';
|
|
||||||
|
|
||||||
export class ERC721Wrapper {
|
|
||||||
private readonly _tokenOwnerAddresses: string[];
|
|
||||||
private readonly _contractOwnerAddress: string;
|
|
||||||
private readonly _provider: ZeroExProvider;
|
|
||||||
private readonly _dummyTokenContracts: DummyERC721TokenContract[];
|
|
||||||
private _proxyContract?: ERC721ProxyContract;
|
|
||||||
private _proxyIdIfExists?: string;
|
|
||||||
private _initialTokenIdsByOwner: ERC721TokenIdsByOwner = {};
|
|
||||||
constructor(provider: ZeroExProvider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
|
|
||||||
this._provider = provider;
|
|
||||||
this._dummyTokenContracts = [];
|
|
||||||
this._tokenOwnerAddresses = tokenOwnerAddresses;
|
|
||||||
this._contractOwnerAddress = contractOwnerAddress;
|
|
||||||
}
|
|
||||||
public async deployDummyTokensAsync(): Promise<DummyERC721TokenContract[]> {
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
for (const i of _.times(constants.NUM_DUMMY_ERC721_TO_DEPLOY)) {
|
|
||||||
this._dummyTokenContracts.push(
|
|
||||||
await DummyERC721TokenContract.deployFrom0xArtifactAsync(
|
|
||||||
erc721Artifacts.DummyERC721Token,
|
|
||||||
this._provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
constants.DUMMY_TOKEN_NAME,
|
|
||||||
constants.DUMMY_TOKEN_SYMBOL,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return this._dummyTokenContracts;
|
|
||||||
}
|
|
||||||
public async deployProxyAsync(): Promise<ERC721ProxyContract> {
|
|
||||||
this._proxyContract = await ERC721ProxyContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.ERC721Proxy,
|
|
||||||
this._provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync();
|
|
||||||
return this._proxyContract;
|
|
||||||
}
|
|
||||||
public getProxyId(): string {
|
|
||||||
this._validateProxyContractExistsOrThrow();
|
|
||||||
return this._proxyIdIfExists as string;
|
|
||||||
}
|
|
||||||
public async setBalancesAndAllowancesAsync(): Promise<void> {
|
|
||||||
this._validateDummyTokenContractsExistOrThrow();
|
|
||||||
this._validateProxyContractExistsOrThrow();
|
|
||||||
this._initialTokenIdsByOwner = {};
|
|
||||||
for (const dummyTokenContract of this._dummyTokenContracts) {
|
|
||||||
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
for (const i of _.times(constants.NUM_ERC721_TOKENS_TO_MINT)) {
|
|
||||||
const tokenId = generatePseudoRandomSalt();
|
|
||||||
await this.mintAsync(dummyTokenContract.address, tokenId, tokenOwnerAddress);
|
|
||||||
if (this._initialTokenIdsByOwner[tokenOwnerAddress] === undefined) {
|
|
||||||
this._initialTokenIdsByOwner[tokenOwnerAddress] = {
|
|
||||||
[dummyTokenContract.address]: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address] === undefined) {
|
|
||||||
this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address] = [];
|
|
||||||
}
|
|
||||||
this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address].push(tokenId);
|
|
||||||
|
|
||||||
await this.approveProxyForAllAsync(dummyTokenContract.address, tokenOwnerAddress, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public async doesTokenExistAsync(tokenAddress: string, tokenId: BigNumber): Promise<boolean> {
|
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
|
||||||
const owner = await tokenContract.ownerOf(tokenId).callAsync();
|
|
||||||
const doesExist = owner !== constants.NULL_ADDRESS;
|
|
||||||
return doesExist;
|
|
||||||
}
|
|
||||||
public async approveProxyAsync(tokenAddress: string, tokenId: BigNumber): Promise<void> {
|
|
||||||
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
|
|
||||||
await this.approveAsync(proxyAddress, tokenAddress, tokenId);
|
|
||||||
}
|
|
||||||
public async approveProxyForAllAsync(
|
|
||||||
tokenAddress: string,
|
|
||||||
ownerAddress: string,
|
|
||||||
isApproved: boolean,
|
|
||||||
): Promise<void> {
|
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
|
||||||
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
|
|
||||||
await tokenContract.setApprovalForAll(proxyAddress, isApproved).awaitTransactionSuccessAsync({
|
|
||||||
from: ownerAddress,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
public async approveAsync(to: string, tokenAddress: string, tokenId: BigNumber): Promise<void> {
|
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
|
||||||
const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId);
|
|
||||||
await tokenContract.approve(to, tokenId).awaitTransactionSuccessAsync({ from: tokenOwner });
|
|
||||||
}
|
|
||||||
public async transferFromAsync(
|
|
||||||
tokenAddress: string,
|
|
||||||
tokenId: BigNumber,
|
|
||||||
currentOwner: string,
|
|
||||||
userAddress: string,
|
|
||||||
): Promise<void> {
|
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
|
||||||
await tokenContract.transferFrom(currentOwner, userAddress, tokenId).awaitTransactionSuccessAsync({
|
|
||||||
from: currentOwner,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
public async mintAsync(tokenAddress: string, tokenId: BigNumber, userAddress: string): Promise<void> {
|
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
|
||||||
await tokenContract.mint(userAddress, tokenId).awaitTransactionSuccessAsync({
|
|
||||||
from: this._contractOwnerAddress,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
public async burnAsync(tokenAddress: string, tokenId: BigNumber, owner: string): Promise<void> {
|
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
|
||||||
await tokenContract.burn(owner, tokenId).awaitTransactionSuccessAsync({ from: this._contractOwnerAddress });
|
|
||||||
}
|
|
||||||
public async ownerOfAsync(tokenAddress: string, tokenId: BigNumber): Promise<string> {
|
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
|
||||||
const owner = await tokenContract.ownerOf(tokenId).callAsync();
|
|
||||||
return owner;
|
|
||||||
}
|
|
||||||
public async isOwnerAsync(userAddress: string, tokenAddress: string, tokenId: BigNumber): Promise<boolean> {
|
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
|
||||||
const tokenOwner = await tokenContract.ownerOf(tokenId).callAsync();
|
|
||||||
const isOwner = tokenOwner === userAddress;
|
|
||||||
return isOwner;
|
|
||||||
}
|
|
||||||
public async isProxyApprovedForAllAsync(userAddress: string, tokenAddress: string): Promise<boolean> {
|
|
||||||
this._validateProxyContractExistsOrThrow();
|
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
|
||||||
const operator = (this._proxyContract as ERC721ProxyContract).address;
|
|
||||||
const didApproveAll = await tokenContract.isApprovedForAll(userAddress, operator).callAsync();
|
|
||||||
return didApproveAll;
|
|
||||||
}
|
|
||||||
public async isProxyApprovedAsync(tokenAddress: string, tokenId: BigNumber): Promise<boolean> {
|
|
||||||
this._validateProxyContractExistsOrThrow();
|
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
|
||||||
const approvedAddress = await tokenContract.getApproved(tokenId).callAsync();
|
|
||||||
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
|
|
||||||
const isProxyAnApprovedOperator = approvedAddress === proxyAddress;
|
|
||||||
return isProxyAnApprovedOperator;
|
|
||||||
}
|
|
||||||
public async getBalancesAsync(): Promise<ERC721TokenIdsByOwner> {
|
|
||||||
this._validateDummyTokenContractsExistOrThrow();
|
|
||||||
this._validateBalancesAndAllowancesSetOrThrow();
|
|
||||||
const tokenIdsByOwner: ERC721TokenIdsByOwner = {};
|
|
||||||
const tokenOwnerAddresses: string[] = [];
|
|
||||||
const tokenInfo: Array<{ tokenId: BigNumber; tokenAddress: string }> = [];
|
|
||||||
for (const dummyTokenContract of this._dummyTokenContracts) {
|
|
||||||
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
|
||||||
const initialTokenOwnerIds = this._initialTokenIdsByOwner[tokenOwnerAddress][
|
|
||||||
dummyTokenContract.address
|
|
||||||
];
|
|
||||||
for (const tokenId of initialTokenOwnerIds) {
|
|
||||||
tokenOwnerAddresses.push(await dummyTokenContract.ownerOf(tokenId).callAsync());
|
|
||||||
tokenInfo.push({
|
|
||||||
tokenId,
|
|
||||||
tokenAddress: dummyTokenContract.address,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_.forEach(tokenOwnerAddresses, (tokenOwnerAddress, ownerIndex) => {
|
|
||||||
const tokenAddress = tokenInfo[ownerIndex].tokenAddress;
|
|
||||||
const tokenId = tokenInfo[ownerIndex].tokenId;
|
|
||||||
if (tokenIdsByOwner[tokenOwnerAddress] === undefined) {
|
|
||||||
tokenIdsByOwner[tokenOwnerAddress] = {
|
|
||||||
[tokenAddress]: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (tokenIdsByOwner[tokenOwnerAddress][tokenAddress] === undefined) {
|
|
||||||
tokenIdsByOwner[tokenOwnerAddress][tokenAddress] = [];
|
|
||||||
}
|
|
||||||
tokenIdsByOwner[tokenOwnerAddress][tokenAddress].push(tokenId);
|
|
||||||
});
|
|
||||||
return tokenIdsByOwner;
|
|
||||||
}
|
|
||||||
public getTokenOwnerAddresses(): string[] {
|
|
||||||
return this._tokenOwnerAddresses;
|
|
||||||
}
|
|
||||||
public getTokenAddresses(): string[] {
|
|
||||||
const tokenAddresses = _.map(this._dummyTokenContracts, dummyTokenContract => dummyTokenContract.address);
|
|
||||||
return tokenAddresses;
|
|
||||||
}
|
|
||||||
private _getTokenContractFromAssetData(tokenAddress: string): DummyERC721TokenContract {
|
|
||||||
const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress);
|
|
||||||
if (tokenContractIfExists === undefined) {
|
|
||||||
throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`);
|
|
||||||
}
|
|
||||||
return tokenContractIfExists;
|
|
||||||
}
|
|
||||||
private _validateDummyTokenContractsExistOrThrow(): void {
|
|
||||||
if (this._dummyTokenContracts === undefined) {
|
|
||||||
throw new Error('Dummy ERC721 tokens not yet deployed, please call "deployDummyTokensAsync"');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private _validateProxyContractExistsOrThrow(): void {
|
|
||||||
if (this._proxyContract === undefined) {
|
|
||||||
throw new Error('ERC721 proxy contract not yet deployed, please call "deployProxyAsync"');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private _validateBalancesAndAllowancesSetOrThrow(): void {
|
|
||||||
if (_.keys(this._initialTokenIdsByOwner).length === 0) {
|
|
||||||
throw new Error(
|
|
||||||
'Dummy ERC721 balances and allowances not yet set, please call "setBalancesAndAllowancesAsync"',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
export { artifacts } from './artifacts';
|
|
||||||
export {
|
|
||||||
ERC1155ProxyContract,
|
|
||||||
ERC20BridgeProxyContract,
|
|
||||||
ERC20ProxyContract,
|
|
||||||
ERC721ProxyContract,
|
|
||||||
Eth2DaiBridgeContract,
|
|
||||||
IAssetDataContract,
|
|
||||||
IAssetProxyContract,
|
|
||||||
MultiAssetProxyContract,
|
|
||||||
StaticCallProxyContract,
|
|
||||||
TestStaticCallTargetContract,
|
|
||||||
UniswapBridgeContract,
|
|
||||||
} from './wrappers';
|
|
||||||
|
|
||||||
export { ERC20Wrapper } from './erc20_wrapper';
|
|
||||||
export { ERC721Wrapper } from './erc721_wrapper';
|
|
||||||
export { ERC1155ProxyWrapper } from './erc1155_proxy_wrapper';
|
|
||||||
export { Erc1155Wrapper, ERC1155MintableContract } from '@0x/contracts-erc1155';
|
|
||||||
export { DummyERC20TokenContract } from '@0x/contracts-erc20';
|
|
||||||
export { DummyERC721TokenContract } from '@0x/contracts-erc721';
|
|
||||||
export {
|
|
||||||
ERC1155HoldingsByOwner,
|
|
||||||
ERC20BalancesByOwner,
|
|
||||||
ERC721TokenIdsByOwner,
|
|
||||||
ERC1155FungibleHoldingsByOwner,
|
|
||||||
ERC1155NonFungibleHoldingsByOwner,
|
|
||||||
} from '@0x/contracts-test-utils';
|
|
||||||
export {
|
|
||||||
TransactionReceiptWithDecodedLogs,
|
|
||||||
Provider,
|
|
||||||
ZeroExProvider,
|
|
||||||
JSONRPCRequestPayload,
|
|
||||||
JSONRPCErrorCallback,
|
|
||||||
TransactionReceiptStatus,
|
|
||||||
JSONRPCResponsePayload,
|
|
||||||
JSONRPCResponseError,
|
|
||||||
ContractArtifact,
|
|
||||||
ContractChains,
|
|
||||||
CompilerOpts,
|
|
||||||
StandardContractOutput,
|
|
||||||
CompilerSettings,
|
|
||||||
ContractChainData,
|
|
||||||
ContractAbi,
|
|
||||||
DevdocOutput,
|
|
||||||
EvmOutput,
|
|
||||||
CompilerSettingsMetadata,
|
|
||||||
OptimizerSettings,
|
|
||||||
OutputField,
|
|
||||||
ParamDescription,
|
|
||||||
EvmBytecodeOutput,
|
|
||||||
AbiDefinition,
|
|
||||||
FunctionAbi,
|
|
||||||
EventAbi,
|
|
||||||
RevertErrorAbi,
|
|
||||||
EventParameter,
|
|
||||||
DataItem,
|
|
||||||
MethodAbi,
|
|
||||||
ConstructorAbi,
|
|
||||||
FallbackAbi,
|
|
||||||
ConstructorStateMutability,
|
|
||||||
TupleDataItem,
|
|
||||||
StateMutability,
|
|
||||||
} from 'ethereum-types';
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
export * from '../generated-wrappers/erc1155_proxy';
|
|
||||||
export * from '../generated-wrappers/erc20_bridge_proxy';
|
|
||||||
export * from '../generated-wrappers/erc20_proxy';
|
|
||||||
export * from '../generated-wrappers/erc721_proxy';
|
|
||||||
export * from '../generated-wrappers/eth2_dai_bridge';
|
|
||||||
export * from '../generated-wrappers/i_asset_data';
|
|
||||||
export * from '../generated-wrappers/i_asset_proxy';
|
|
||||||
export * from '../generated-wrappers/multi_asset_proxy';
|
|
||||||
export * from '../generated-wrappers/static_call_proxy';
|
|
||||||
export * from '../generated-wrappers/test_static_call_target';
|
|
||||||
export * from '../generated-wrappers/uniswap_bridge';
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
import { ContractArtifact } from 'ethereum-types';
|
|
||||||
|
|
||||||
import * as ERC1155Proxy from '../test/generated-artifacts/ERC1155Proxy.json';
|
|
||||||
import * as ERC20BridgeProxy from '../test/generated-artifacts/ERC20BridgeProxy.json';
|
|
||||||
import * as ERC20Proxy from '../test/generated-artifacts/ERC20Proxy.json';
|
|
||||||
import * as ERC721Proxy from '../test/generated-artifacts/ERC721Proxy.json';
|
|
||||||
import * as Eth2DaiBridge from '../test/generated-artifacts/Eth2DaiBridge.json';
|
|
||||||
import * as IAssetData from '../test/generated-artifacts/IAssetData.json';
|
|
||||||
import * as IAssetProxy from '../test/generated-artifacts/IAssetProxy.json';
|
|
||||||
import * as IAssetProxyDispatcher from '../test/generated-artifacts/IAssetProxyDispatcher.json';
|
|
||||||
import * as IAuthorizable from '../test/generated-artifacts/IAuthorizable.json';
|
|
||||||
import * as IERC20Bridge from '../test/generated-artifacts/IERC20Bridge.json';
|
|
||||||
import * as IEth2Dai from '../test/generated-artifacts/IEth2Dai.json';
|
|
||||||
import * as IUniswapExchange from '../test/generated-artifacts/IUniswapExchange.json';
|
|
||||||
import * as IUniswapExchangeFactory from '../test/generated-artifacts/IUniswapExchangeFactory.json';
|
|
||||||
import * as MixinAssetProxyDispatcher from '../test/generated-artifacts/MixinAssetProxyDispatcher.json';
|
|
||||||
import * as MixinAuthorizable from '../test/generated-artifacts/MixinAuthorizable.json';
|
|
||||||
import * as MultiAssetProxy from '../test/generated-artifacts/MultiAssetProxy.json';
|
|
||||||
import * as Ownable from '../test/generated-artifacts/Ownable.json';
|
|
||||||
import * as StaticCallProxy from '../test/generated-artifacts/StaticCallProxy.json';
|
|
||||||
import * as TestERC20Bridge from '../test/generated-artifacts/TestERC20Bridge.json';
|
|
||||||
import * as TestEth2DaiBridge from '../test/generated-artifacts/TestEth2DaiBridge.json';
|
|
||||||
import * as TestStaticCallTarget from '../test/generated-artifacts/TestStaticCallTarget.json';
|
|
||||||
import * as TestUniswapBridge from '../test/generated-artifacts/TestUniswapBridge.json';
|
|
||||||
import * as UniswapBridge from '../test/generated-artifacts/UniswapBridge.json';
|
|
||||||
export const artifacts = {
|
|
||||||
MixinAssetProxyDispatcher: MixinAssetProxyDispatcher as ContractArtifact,
|
|
||||||
MixinAuthorizable: MixinAuthorizable as ContractArtifact,
|
|
||||||
Ownable: Ownable as ContractArtifact,
|
|
||||||
ERC1155Proxy: ERC1155Proxy as ContractArtifact,
|
|
||||||
ERC20BridgeProxy: ERC20BridgeProxy as ContractArtifact,
|
|
||||||
ERC20Proxy: ERC20Proxy as ContractArtifact,
|
|
||||||
ERC721Proxy: ERC721Proxy as ContractArtifact,
|
|
||||||
MultiAssetProxy: MultiAssetProxy as ContractArtifact,
|
|
||||||
StaticCallProxy: StaticCallProxy as ContractArtifact,
|
|
||||||
Eth2DaiBridge: Eth2DaiBridge as ContractArtifact,
|
|
||||||
UniswapBridge: UniswapBridge as ContractArtifact,
|
|
||||||
IAssetData: IAssetData as ContractArtifact,
|
|
||||||
IAssetProxy: IAssetProxy as ContractArtifact,
|
|
||||||
IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact,
|
|
||||||
IAuthorizable: IAuthorizable as ContractArtifact,
|
|
||||||
IERC20Bridge: IERC20Bridge as ContractArtifact,
|
|
||||||
IEth2Dai: IEth2Dai as ContractArtifact,
|
|
||||||
IUniswapExchange: IUniswapExchange as ContractArtifact,
|
|
||||||
IUniswapExchangeFactory: IUniswapExchangeFactory as ContractArtifact,
|
|
||||||
TestERC20Bridge: TestERC20Bridge as ContractArtifact,
|
|
||||||
TestEth2DaiBridge: TestEth2DaiBridge as ContractArtifact,
|
|
||||||
TestStaticCallTarget: TestStaticCallTarget as ContractArtifact,
|
|
||||||
TestUniswapBridge: TestUniswapBridge as ContractArtifact,
|
|
||||||
};
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
import { chaiSetup, expectTransactionFailedAsync, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
|
|
||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
|
||||||
import { RevertReason } from '@0x/types';
|
|
||||||
import { BigNumber } from '@0x/utils';
|
|
||||||
import * as chai from 'chai';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
|
|
||||||
import { MixinAuthorizableContract } from './wrappers';
|
|
||||||
|
|
||||||
chaiSetup.configure();
|
|
||||||
const expect = chai.expect;
|
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
|
||||||
|
|
||||||
describe('Authorizable', () => {
|
|
||||||
let owner: string;
|
|
||||||
let notOwner: string;
|
|
||||||
let address: string;
|
|
||||||
let authorizable: MixinAuthorizableContract;
|
|
||||||
|
|
||||||
before(async () => {
|
|
||||||
await blockchainLifecycle.startAsync();
|
|
||||||
});
|
|
||||||
|
|
||||||
after(async () => {
|
|
||||||
await blockchainLifecycle.revertAsync();
|
|
||||||
});
|
|
||||||
|
|
||||||
before(async () => {
|
|
||||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
|
||||||
[owner, address, notOwner] = _.slice(accounts, 0, 3);
|
|
||||||
authorizable = await MixinAuthorizableContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.MixinAuthorizable,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await blockchainLifecycle.startAsync();
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await blockchainLifecycle.revertAsync();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('addAuthorizedAddress', () => {
|
|
||||||
it('should revert if not called by owner', async () => {
|
|
||||||
await expectTransactionFailedAsync(
|
|
||||||
authorizable.addAuthorizedAddress(notOwner).sendTransactionAsync({ from: notOwner }),
|
|
||||||
RevertReason.OnlyContractOwner,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should allow owner to add an authorized address', async () => {
|
|
||||||
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
|
|
||||||
const isAuthorized = await authorizable.authorized(address).callAsync();
|
|
||||||
expect(isAuthorized).to.be.true();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should revert if owner attempts to authorize a duplicate address', async () => {
|
|
||||||
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
|
|
||||||
return expectTransactionFailedAsync(
|
|
||||||
authorizable.addAuthorizedAddress(address).sendTransactionAsync({ from: owner }),
|
|
||||||
RevertReason.TargetAlreadyAuthorized,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('removeAuthorizedAddress', () => {
|
|
||||||
it('should revert if not called by owner', async () => {
|
|
||||||
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
|
|
||||||
await expectTransactionFailedAsync(
|
|
||||||
authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ from: notOwner }),
|
|
||||||
RevertReason.OnlyContractOwner,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should allow owner to remove an authorized address', async () => {
|
|
||||||
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
|
|
||||||
await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
|
|
||||||
const isAuthorized = await authorizable.authorized(address).callAsync();
|
|
||||||
expect(isAuthorized).to.be.false();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should revert if owner attempts to remove an address that is not authorized', async () => {
|
|
||||||
return expectTransactionFailedAsync(
|
|
||||||
authorizable.removeAuthorizedAddress(address).sendTransactionAsync({
|
|
||||||
from: owner,
|
|
||||||
}),
|
|
||||||
RevertReason.TargetNotAuthorized,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('removeAuthorizedAddressAtIndex', () => {
|
|
||||||
it('should revert if not called by owner', async () => {
|
|
||||||
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
|
|
||||||
const index = new BigNumber(0);
|
|
||||||
await expectTransactionFailedAsync(
|
|
||||||
authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({
|
|
||||||
from: notOwner,
|
|
||||||
}),
|
|
||||||
RevertReason.OnlyContractOwner,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should revert if index is >= authorities.length', async () => {
|
|
||||||
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
|
|
||||||
const index = new BigNumber(1);
|
|
||||||
return expectTransactionFailedAsync(
|
|
||||||
authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({
|
|
||||||
from: owner,
|
|
||||||
}),
|
|
||||||
RevertReason.IndexOutOfBounds,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should revert if owner attempts to remove an address that is not authorized', async () => {
|
|
||||||
const index = new BigNumber(0);
|
|
||||||
return expectTransactionFailedAsync(
|
|
||||||
authorizable.removeAuthorizedAddressAtIndex(address, index).sendTransactionAsync({
|
|
||||||
from: owner,
|
|
||||||
}),
|
|
||||||
RevertReason.TargetNotAuthorized,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should revert if address at index does not match target', async () => {
|
|
||||||
const address1 = address;
|
|
||||||
const address2 = notOwner;
|
|
||||||
await authorizable.addAuthorizedAddress(address1).awaitTransactionSuccessAsync({ from: owner });
|
|
||||||
await authorizable.addAuthorizedAddress(address2).awaitTransactionSuccessAsync({ from: owner });
|
|
||||||
const address1Index = new BigNumber(0);
|
|
||||||
return expectTransactionFailedAsync(
|
|
||||||
authorizable.removeAuthorizedAddressAtIndex(address2, address1Index).sendTransactionAsync({
|
|
||||||
from: owner,
|
|
||||||
}),
|
|
||||||
RevertReason.AuthorizedAddressMismatch,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should allow owner to remove an authorized address', async () => {
|
|
||||||
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
|
|
||||||
const index = new BigNumber(0);
|
|
||||||
await authorizable.removeAuthorizedAddressAtIndex(address, index).awaitTransactionSuccessAsync({
|
|
||||||
from: owner,
|
|
||||||
});
|
|
||||||
const isAuthorized = await authorizable.authorized(address).callAsync();
|
|
||||||
expect(isAuthorized).to.be.false();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getAuthorizedAddresses', () => {
|
|
||||||
it('should return all authorized addresses', async () => {
|
|
||||||
const initial = await authorizable.getAuthorizedAddresses().callAsync();
|
|
||||||
expect(initial).to.have.length(0);
|
|
||||||
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
|
|
||||||
const afterAdd = await authorizable.getAuthorizedAddresses().callAsync();
|
|
||||||
expect(afterAdd).to.have.length(1);
|
|
||||||
expect(afterAdd).to.include(address);
|
|
||||||
await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
|
|
||||||
const afterRemove = await authorizable.getAuthorizedAddresses().callAsync();
|
|
||||||
expect(afterRemove).to.have.length(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,290 +0,0 @@
|
|||||||
import {
|
|
||||||
blockchainTests,
|
|
||||||
constants,
|
|
||||||
expect,
|
|
||||||
getRandomInteger,
|
|
||||||
hexLeftPad,
|
|
||||||
hexRightPad,
|
|
||||||
hexSlice,
|
|
||||||
Numberish,
|
|
||||||
randomAddress,
|
|
||||||
} from '@0x/contracts-test-utils';
|
|
||||||
import { AuthorizableRevertErrors } from '@0x/contracts-utils';
|
|
||||||
import { AssetProxyId } from '@0x/types';
|
|
||||||
import { AbiEncoder, BigNumber, StringRevertError } from '@0x/utils';
|
|
||||||
import { DecodedLogs } from 'ethereum-types';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
|
|
||||||
import { ERC20BridgeProxyContract, TestERC20BridgeContract } from './wrappers';
|
|
||||||
|
|
||||||
blockchainTests.resets('ERC20BridgeProxy unit tests', env => {
|
|
||||||
const PROXY_ID = AssetProxyId.ERC20Bridge;
|
|
||||||
const BRIDGE_SUCCESS_RETURN_DATA = hexRightPad(PROXY_ID);
|
|
||||||
let owner: string;
|
|
||||||
let badCaller: string;
|
|
||||||
let assetProxy: ERC20BridgeProxyContract;
|
|
||||||
let bridgeContract: TestERC20BridgeContract;
|
|
||||||
let testTokenAddress: string;
|
|
||||||
|
|
||||||
before(async () => {
|
|
||||||
[owner, badCaller] = await env.getAccountAddressesAsync();
|
|
||||||
assetProxy = await ERC20BridgeProxyContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.ERC20BridgeProxy,
|
|
||||||
env.provider,
|
|
||||||
env.txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
bridgeContract = await TestERC20BridgeContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.TestERC20Bridge,
|
|
||||||
env.provider,
|
|
||||||
env.txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
testTokenAddress = await bridgeContract.testToken().callAsync();
|
|
||||||
await assetProxy.addAuthorizedAddress(owner).awaitTransactionSuccessAsync();
|
|
||||||
});
|
|
||||||
|
|
||||||
interface AssetDataOpts {
|
|
||||||
tokenAddress: string;
|
|
||||||
bridgeAddress: string;
|
|
||||||
bridgeData: BridgeDataOpts;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BridgeDataOpts {
|
|
||||||
transferAmount: Numberish;
|
|
||||||
revertError?: string;
|
|
||||||
returnData: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createAssetData(opts?: Partial<AssetDataOpts>): AssetDataOpts {
|
|
||||||
return _.merge(
|
|
||||||
{
|
|
||||||
tokenAddress: testTokenAddress,
|
|
||||||
bridgeAddress: bridgeContract.address,
|
|
||||||
bridgeData: createBridgeData(),
|
|
||||||
},
|
|
||||||
opts,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createBridgeData(opts?: Partial<BridgeDataOpts>): BridgeDataOpts {
|
|
||||||
return _.merge(
|
|
||||||
{
|
|
||||||
transferAmount: constants.ZERO_AMOUNT,
|
|
||||||
returnData: BRIDGE_SUCCESS_RETURN_DATA,
|
|
||||||
},
|
|
||||||
opts,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function encodeAssetData(opts: AssetDataOpts): string {
|
|
||||||
const encoder = AbiEncoder.createMethod('ERC20BridgeProxy', [
|
|
||||||
{ name: 'tokenAddress', type: 'address' },
|
|
||||||
{ name: 'bridgeAddress', type: 'address' },
|
|
||||||
{ name: 'bridgeData', type: 'bytes' },
|
|
||||||
]);
|
|
||||||
return encoder.encode([opts.tokenAddress, opts.bridgeAddress, encodeBridgeData(opts.bridgeData)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function encodeBridgeData(opts: BridgeDataOpts): string {
|
|
||||||
const encoder = AbiEncoder.create([
|
|
||||||
{ name: 'transferAmount', type: 'int256' },
|
|
||||||
{ name: 'revertData', type: 'bytes' },
|
|
||||||
{ name: 'returnData', type: 'bytes' },
|
|
||||||
]);
|
|
||||||
const revertErrorBytes =
|
|
||||||
opts.revertError !== undefined ? new StringRevertError(opts.revertError).encode() : '0x';
|
|
||||||
return encoder.encode([new BigNumber(opts.transferAmount), revertErrorBytes, opts.returnData]);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function setTestTokenBalanceAsync(_owner: string, balance: Numberish): Promise<void> {
|
|
||||||
await bridgeContract.setTestTokenBalance(_owner, new BigNumber(balance)).awaitTransactionSuccessAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('transferFrom()', () => {
|
|
||||||
interface TransferFromOpts {
|
|
||||||
assetData: AssetDataOpts;
|
|
||||||
from: string;
|
|
||||||
to: string;
|
|
||||||
amount: Numberish;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createTransferFromOpts(opts?: Partial<TransferFromOpts>): TransferFromOpts {
|
|
||||||
const transferAmount = _.get(opts, ['amount'], getRandomInteger(1, 100e18)) as BigNumber;
|
|
||||||
return _.merge(
|
|
||||||
{
|
|
||||||
assetData: createAssetData({
|
|
||||||
bridgeData: createBridgeData({
|
|
||||||
transferAmount,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
from: randomAddress(),
|
|
||||||
to: randomAddress(),
|
|
||||||
amount: transferAmount,
|
|
||||||
},
|
|
||||||
opts,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function transferFromAsync(opts?: Partial<TransferFromOpts>, caller?: string): Promise<DecodedLogs> {
|
|
||||||
const _opts = createTransferFromOpts(opts);
|
|
||||||
const { logs } = await assetProxy
|
|
||||||
.transferFrom(encodeAssetData(_opts.assetData), _opts.from, _opts.to, new BigNumber(_opts.amount))
|
|
||||||
.awaitTransactionSuccessAsync({ from: caller });
|
|
||||||
return (logs as any) as DecodedLogs;
|
|
||||||
}
|
|
||||||
|
|
||||||
it('succeeds if the bridge succeeds and balance increases by `amount`', async () => {
|
|
||||||
const tx = transferFromAsync();
|
|
||||||
return expect(tx).to.be.fulfilled('');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('succeeds if balance increases more than `amount`', async () => {
|
|
||||||
const amount = getRandomInteger(1, 100e18);
|
|
||||||
const tx = transferFromAsync({
|
|
||||||
amount,
|
|
||||||
assetData: createAssetData({
|
|
||||||
bridgeData: createBridgeData({
|
|
||||||
transferAmount: amount.plus(1),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
return expect(tx).to.be.fulfilled('');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('passes the correct arguments to the bridge contract', async () => {
|
|
||||||
const opts = createTransferFromOpts();
|
|
||||||
const logs = await transferFromAsync(opts);
|
|
||||||
expect(logs.length).to.eq(1);
|
|
||||||
const args = logs[0].args;
|
|
||||||
expect(args.tokenAddress).to.eq(opts.assetData.tokenAddress);
|
|
||||||
expect(args.from).to.eq(opts.from);
|
|
||||||
expect(args.to).to.eq(opts.to);
|
|
||||||
expect(args.amount).to.bignumber.eq(opts.amount);
|
|
||||||
expect(args.bridgeData).to.eq(encodeBridgeData(opts.assetData.bridgeData));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if not called by an authorized address', async () => {
|
|
||||||
const tx = transferFromAsync({}, badCaller);
|
|
||||||
return expect(tx).to.revertWith(new AuthorizableRevertErrors.SenderNotAuthorizedError(badCaller));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if asset data is truncated', async () => {
|
|
||||||
const opts = createTransferFromOpts();
|
|
||||||
const truncatedAssetData = hexSlice(encodeAssetData(opts.assetData), 0, -1);
|
|
||||||
const tx = assetProxy
|
|
||||||
.transferFrom(truncatedAssetData, opts.from, opts.to, new BigNumber(opts.amount))
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
return expect(tx).to.be.rejected();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if bridge returns nothing', async () => {
|
|
||||||
const tx = transferFromAsync({
|
|
||||||
assetData: createAssetData({
|
|
||||||
bridgeData: createBridgeData({
|
|
||||||
returnData: '0x',
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
// This will actually revert when the AP tries to decode the return
|
|
||||||
// value.
|
|
||||||
return expect(tx).to.be.rejected();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if bridge returns true', async () => {
|
|
||||||
const tx = transferFromAsync({
|
|
||||||
assetData: createAssetData({
|
|
||||||
bridgeData: createBridgeData({
|
|
||||||
returnData: hexLeftPad('0x1'),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
// This will actually revert when the AP tries to decode the return
|
|
||||||
// value.
|
|
||||||
return expect(tx).to.be.rejected();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if bridge returns 0x1', async () => {
|
|
||||||
const tx = transferFromAsync({
|
|
||||||
assetData: createAssetData({
|
|
||||||
bridgeData: createBridgeData({
|
|
||||||
returnData: hexRightPad('0x1'),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
return expect(tx).to.revertWith('BRIDGE_FAILED');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if bridge is an EOA', async () => {
|
|
||||||
const tx = transferFromAsync({
|
|
||||||
assetData: createAssetData({
|
|
||||||
bridgeAddress: randomAddress(),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
// This will actually revert when the AP tries to decode the return
|
|
||||||
// value.
|
|
||||||
return expect(tx).to.be.rejected();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if bridge reverts', async () => {
|
|
||||||
const revertError = 'FOOBAR';
|
|
||||||
const tx = transferFromAsync({
|
|
||||||
assetData: createAssetData({
|
|
||||||
bridgeData: createBridgeData({
|
|
||||||
revertError,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
return expect(tx).to.revertWith(revertError);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if balance of `to` increases by less than `amount`', async () => {
|
|
||||||
const amount = getRandomInteger(1, 100e18);
|
|
||||||
const tx = transferFromAsync({
|
|
||||||
amount,
|
|
||||||
assetData: createAssetData({
|
|
||||||
bridgeData: createBridgeData({
|
|
||||||
transferAmount: amount.minus(1),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
return expect(tx).to.revertWith('BRIDGE_UNDERPAY');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if balance of `to` decreases', async () => {
|
|
||||||
const toAddress = randomAddress();
|
|
||||||
await setTestTokenBalanceAsync(toAddress, 1e18);
|
|
||||||
const tx = transferFromAsync({
|
|
||||||
to: toAddress,
|
|
||||||
assetData: createAssetData({
|
|
||||||
bridgeData: createBridgeData({
|
|
||||||
transferAmount: -1,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
return expect(tx).to.revertWith('BRIDGE_UNDERPAY');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('balanceOf()', () => {
|
|
||||||
it('retrieves the balance of the encoded token', async () => {
|
|
||||||
const _owner = randomAddress();
|
|
||||||
const balance = getRandomInteger(1, 100e18);
|
|
||||||
await bridgeContract.setTestTokenBalance(_owner, balance).awaitTransactionSuccessAsync();
|
|
||||||
const assetData = createAssetData({
|
|
||||||
tokenAddress: testTokenAddress,
|
|
||||||
});
|
|
||||||
const actualBalance = await assetProxy.balanceOf(encodeAssetData(assetData), _owner).callAsync();
|
|
||||||
expect(actualBalance).to.bignumber.eq(balance);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getProxyId()', () => {
|
|
||||||
it('returns the correct proxy ID', async () => {
|
|
||||||
const proxyId = await assetProxy.getProxyId().callAsync();
|
|
||||||
expect(proxyId).to.eq(PROXY_ID);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
import {
|
|
||||||
blockchainTests,
|
|
||||||
constants,
|
|
||||||
expect,
|
|
||||||
filterLogsToArguments,
|
|
||||||
getRandomInteger,
|
|
||||||
hexLeftPad,
|
|
||||||
hexRandom,
|
|
||||||
Numberish,
|
|
||||||
randomAddress,
|
|
||||||
} from '@0x/contracts-test-utils';
|
|
||||||
import { AssetProxyId } from '@0x/types';
|
|
||||||
import { BigNumber, RawRevertError } from '@0x/utils';
|
|
||||||
import { DecodedLogs } from 'ethereum-types';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
|
|
||||||
import {
|
|
||||||
TestEth2DaiBridgeContract,
|
|
||||||
TestEth2DaiBridgeEvents,
|
|
||||||
TestEth2DaiBridgeSellAllAmountEventArgs,
|
|
||||||
TestEth2DaiBridgeTokenApproveEventArgs,
|
|
||||||
TestEth2DaiBridgeTokenTransferEventArgs,
|
|
||||||
} from './wrappers';
|
|
||||||
|
|
||||||
blockchainTests.resets('Eth2DaiBridge unit tests', env => {
|
|
||||||
let testContract: TestEth2DaiBridgeContract;
|
|
||||||
|
|
||||||
before(async () => {
|
|
||||||
testContract = await TestEth2DaiBridgeContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.TestEth2DaiBridge,
|
|
||||||
env.provider,
|
|
||||||
env.txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('isValidSignature()', () => {
|
|
||||||
it('returns success bytes', async () => {
|
|
||||||
const LEGACY_WALLET_MAGIC_VALUE = '0xb0671381';
|
|
||||||
const result = await testContract.isValidSignature(hexRandom(), hexRandom(_.random(0, 32))).callAsync();
|
|
||||||
expect(result).to.eq(LEGACY_WALLET_MAGIC_VALUE);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('bridgeTransferFrom()', () => {
|
|
||||||
interface WithdrawToOpts {
|
|
||||||
toTokenAddress?: string;
|
|
||||||
fromTokenAddress?: string;
|
|
||||||
toAddress: string;
|
|
||||||
amount: Numberish;
|
|
||||||
fromTokenBalance: Numberish;
|
|
||||||
revertReason: string;
|
|
||||||
fillAmount: Numberish;
|
|
||||||
toTokentransferRevertReason: string;
|
|
||||||
toTokenTransferReturnData: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface WithdrawToResult {
|
|
||||||
opts: WithdrawToOpts;
|
|
||||||
result: string;
|
|
||||||
logs: DecodedLogs;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createWithdrawToOpts(opts?: Partial<WithdrawToOpts>): WithdrawToOpts {
|
|
||||||
return {
|
|
||||||
toAddress: randomAddress(),
|
|
||||||
amount: getRandomInteger(1, 100e18),
|
|
||||||
revertReason: '',
|
|
||||||
fillAmount: getRandomInteger(1, 100e18),
|
|
||||||
fromTokenBalance: getRandomInteger(1, 100e18),
|
|
||||||
toTokentransferRevertReason: '',
|
|
||||||
toTokenTransferReturnData: hexLeftPad(1),
|
|
||||||
...opts,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function withdrawToAsync(opts?: Partial<WithdrawToOpts>): Promise<WithdrawToResult> {
|
|
||||||
const _opts = createWithdrawToOpts(opts);
|
|
||||||
// Set the fill behavior.
|
|
||||||
await testContract
|
|
||||||
.setFillBehavior(_opts.revertReason, new BigNumber(_opts.fillAmount))
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
// Create tokens and balances.
|
|
||||||
if (_opts.fromTokenAddress === undefined) {
|
|
||||||
const createTokenFn = testContract.createToken(new BigNumber(_opts.fromTokenBalance));
|
|
||||||
_opts.fromTokenAddress = await createTokenFn.callAsync();
|
|
||||||
await createTokenFn.awaitTransactionSuccessAsync();
|
|
||||||
}
|
|
||||||
if (_opts.toTokenAddress === undefined) {
|
|
||||||
const createTokenFn = testContract.createToken(constants.ZERO_AMOUNT);
|
|
||||||
_opts.toTokenAddress = await createTokenFn.callAsync();
|
|
||||||
await createTokenFn.awaitTransactionSuccessAsync();
|
|
||||||
}
|
|
||||||
// Set the transfer behavior of `toTokenAddress`.
|
|
||||||
await testContract
|
|
||||||
.setTransferBehavior(
|
|
||||||
_opts.toTokenAddress,
|
|
||||||
_opts.toTokentransferRevertReason,
|
|
||||||
_opts.toTokenTransferReturnData,
|
|
||||||
)
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
// Call bridgeTransferFrom().
|
|
||||||
const bridgeTransferFromFn = testContract.bridgeTransferFrom(
|
|
||||||
// "to" token address
|
|
||||||
_opts.toTokenAddress,
|
|
||||||
// Random from address.
|
|
||||||
randomAddress(),
|
|
||||||
// To address.
|
|
||||||
_opts.toAddress,
|
|
||||||
new BigNumber(_opts.amount),
|
|
||||||
// ABI-encode the "from" token address as the bridge data.
|
|
||||||
hexLeftPad(_opts.fromTokenAddress as string),
|
|
||||||
);
|
|
||||||
const result = await bridgeTransferFromFn.callAsync();
|
|
||||||
const { logs } = await bridgeTransferFromFn.awaitTransactionSuccessAsync();
|
|
||||||
return {
|
|
||||||
opts: _opts,
|
|
||||||
result,
|
|
||||||
logs: (logs as any) as DecodedLogs,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
it('returns magic bytes on success', async () => {
|
|
||||||
const BRIDGE_SUCCESS_RETURN_DATA = AssetProxyId.ERC20Bridge;
|
|
||||||
const { result } = await withdrawToAsync();
|
|
||||||
expect(result).to.eq(BRIDGE_SUCCESS_RETURN_DATA);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calls `Eth2Dai.sellAllAmount()`', async () => {
|
|
||||||
const { opts, logs } = await withdrawToAsync();
|
|
||||||
const transfers = filterLogsToArguments<TestEth2DaiBridgeSellAllAmountEventArgs>(
|
|
||||||
logs,
|
|
||||||
TestEth2DaiBridgeEvents.SellAllAmount,
|
|
||||||
);
|
|
||||||
expect(transfers.length).to.eq(1);
|
|
||||||
expect(transfers[0].sellToken).to.eq(opts.fromTokenAddress);
|
|
||||||
expect(transfers[0].buyToken).to.eq(opts.toTokenAddress);
|
|
||||||
expect(transfers[0].sellTokenAmount).to.bignumber.eq(opts.fromTokenBalance);
|
|
||||||
expect(transfers[0].minimumFillAmount).to.bignumber.eq(opts.amount);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets an unlimited allowance on the `fromTokenAddress` token', async () => {
|
|
||||||
const { opts, logs } = await withdrawToAsync();
|
|
||||||
const approvals = filterLogsToArguments<TestEth2DaiBridgeTokenApproveEventArgs>(
|
|
||||||
logs,
|
|
||||||
TestEth2DaiBridgeEvents.TokenApprove,
|
|
||||||
);
|
|
||||||
expect(approvals.length).to.eq(1);
|
|
||||||
expect(approvals[0].token).to.eq(opts.fromTokenAddress);
|
|
||||||
expect(approvals[0].spender).to.eq(testContract.address);
|
|
||||||
expect(approvals[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('transfers filled amount to `to`', async () => {
|
|
||||||
const { opts, logs } = await withdrawToAsync();
|
|
||||||
const transfers = filterLogsToArguments<TestEth2DaiBridgeTokenTransferEventArgs>(
|
|
||||||
logs,
|
|
||||||
TestEth2DaiBridgeEvents.TokenTransfer,
|
|
||||||
);
|
|
||||||
expect(transfers.length).to.eq(1);
|
|
||||||
expect(transfers[0].token).to.eq(opts.toTokenAddress);
|
|
||||||
expect(transfers[0].from).to.eq(testContract.address);
|
|
||||||
expect(transfers[0].to).to.eq(opts.toAddress);
|
|
||||||
expect(transfers[0].amount).to.bignumber.eq(opts.fillAmount);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if `Eth2Dai.sellAllAmount()` reverts', async () => {
|
|
||||||
const opts = createWithdrawToOpts({ revertReason: 'FOOBAR' });
|
|
||||||
const tx = withdrawToAsync(opts);
|
|
||||||
return expect(tx).to.revertWith(opts.revertReason);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if `toTokenAddress.transfer()` reverts', async () => {
|
|
||||||
const opts = createWithdrawToOpts({ toTokentransferRevertReason: 'FOOBAR' });
|
|
||||||
const tx = withdrawToAsync(opts);
|
|
||||||
return expect(tx).to.revertWith(opts.toTokentransferRevertReason);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if `toTokenAddress.transfer()` returns false', async () => {
|
|
||||||
const opts = createWithdrawToOpts({ toTokenTransferReturnData: hexLeftPad(0) });
|
|
||||||
const tx = withdrawToAsync(opts);
|
|
||||||
return expect(tx).to.revertWith(new RawRevertError(hexLeftPad(0)));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('succeeds if `toTokenAddress.transfer()` returns true', async () => {
|
|
||||||
await withdrawToAsync({ toTokenTransferReturnData: hexLeftPad(1) });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
|
||||||
import { providerUtils } from '@0x/utils';
|
|
||||||
|
|
||||||
before('start web3 provider', () => {
|
|
||||||
providerUtils.startProviderEngine(provider);
|
|
||||||
});
|
|
||||||
after('generate coverage report', async () => {
|
|
||||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
|
||||||
const coverageSubprovider = coverage.getCoverageSubproviderSingleton();
|
|
||||||
await coverageSubprovider.writeCoverageAsync();
|
|
||||||
}
|
|
||||||
if (env.parseBoolean(EnvVars.SolidityProfiler)) {
|
|
||||||
const profilerSubprovider = profiler.getProfilerSubproviderSingleton();
|
|
||||||
await profilerSubprovider.writeProfilerOutputAsync();
|
|
||||||
}
|
|
||||||
provider.stop();
|
|
||||||
});
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,243 +0,0 @@
|
|||||||
import { DevUtilsContract } from '@0x/contracts-dev-utils';
|
|
||||||
import {
|
|
||||||
chaiSetup,
|
|
||||||
constants,
|
|
||||||
expectTransactionFailedAsync,
|
|
||||||
expectTransactionFailedWithoutReasonAsync,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
web3Wrapper,
|
|
||||||
} from '@0x/contracts-test-utils';
|
|
||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
|
||||||
import { AssetProxyId, RevertReason } from '@0x/types';
|
|
||||||
import { AbiEncoder, BigNumber } from '@0x/utils';
|
|
||||||
import * as chai from 'chai';
|
|
||||||
import * as ethUtil from 'ethereumjs-util';
|
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
|
|
||||||
import { IAssetProxyContract, StaticCallProxyContract, TestStaticCallTargetContract } from './wrappers';
|
|
||||||
|
|
||||||
chaiSetup.configure();
|
|
||||||
const expect = chai.expect;
|
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
|
||||||
|
|
||||||
describe('StaticCallProxy', () => {
|
|
||||||
const amount = constants.ZERO_AMOUNT;
|
|
||||||
let fromAddress: string;
|
|
||||||
let toAddress: string;
|
|
||||||
|
|
||||||
let devUtils: DevUtilsContract;
|
|
||||||
let staticCallProxy: IAssetProxyContract;
|
|
||||||
let staticCallTarget: TestStaticCallTargetContract;
|
|
||||||
|
|
||||||
before(async () => {
|
|
||||||
await blockchainLifecycle.startAsync();
|
|
||||||
});
|
|
||||||
after(async () => {
|
|
||||||
await blockchainLifecycle.revertAsync();
|
|
||||||
});
|
|
||||||
before(async () => {
|
|
||||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
|
||||||
[fromAddress, toAddress] = accounts.slice(0, 2);
|
|
||||||
const staticCallProxyWithoutTransferFrom = await StaticCallProxyContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.StaticCallProxy,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
devUtils = new DevUtilsContract(constants.NULL_ADDRESS, provider);
|
|
||||||
staticCallProxy = new IAssetProxyContract(
|
|
||||||
staticCallProxyWithoutTransferFrom.address,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
{},
|
|
||||||
StaticCallProxyContract.deployedBytecode,
|
|
||||||
);
|
|
||||||
staticCallTarget = await TestStaticCallTargetContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.TestStaticCallTarget,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
beforeEach(async () => {
|
|
||||||
await blockchainLifecycle.startAsync();
|
|
||||||
});
|
|
||||||
afterEach(async () => {
|
|
||||||
await blockchainLifecycle.revertAsync();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('general', () => {
|
|
||||||
it('should revert if undefined function is called', async () => {
|
|
||||||
const undefinedSelector = '0x01020304';
|
|
||||||
await expectTransactionFailedWithoutReasonAsync(
|
|
||||||
web3Wrapper.sendTransactionAsync({
|
|
||||||
from: fromAddress,
|
|
||||||
to: staticCallProxy.address,
|
|
||||||
value: constants.ZERO_AMOUNT,
|
|
||||||
data: undefinedSelector,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('should have an id of 0xc339d10a', async () => {
|
|
||||||
const proxyId = await staticCallProxy.getProxyId().callAsync();
|
|
||||||
const expectedProxyId = AssetProxyId.StaticCall;
|
|
||||||
expect(proxyId).to.equal(expectedProxyId);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('transferFrom', () => {
|
|
||||||
it('should revert if assetData lies outside the bounds of calldata', async () => {
|
|
||||||
const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData();
|
|
||||||
const expectedResultHash = constants.KECCAK256_NULL;
|
|
||||||
const assetData = await devUtils
|
|
||||||
.encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash)
|
|
||||||
.callAsync();
|
|
||||||
const txData = staticCallProxy
|
|
||||||
.transferFrom(assetData, fromAddress, toAddress, amount)
|
|
||||||
.getABIEncodedTransactionData();
|
|
||||||
const offsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000080';
|
|
||||||
const txDataEndBuffer = ethUtil.toBuffer((txData.length - 2) / 2 - 4);
|
|
||||||
const paddedTxDataEndBuffer = ethUtil.setLengthLeft(txDataEndBuffer, 32);
|
|
||||||
const invalidOffsetToAssetData = ethUtil.bufferToHex(paddedTxDataEndBuffer).slice(2);
|
|
||||||
const newAssetData = '0000000000000000000000000000000000000000000000000000000000000304';
|
|
||||||
const badTxData = `${txData.replace(offsetToAssetData, invalidOffsetToAssetData)}${newAssetData}`;
|
|
||||||
await expectTransactionFailedWithoutReasonAsync(
|
|
||||||
web3Wrapper.sendTransactionAsync({
|
|
||||||
to: staticCallProxy.address,
|
|
||||||
from: fromAddress,
|
|
||||||
data: badTxData,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('should revert if the length of assetData is less than 100 bytes', async () => {
|
|
||||||
const staticCallData = constants.NULL_BYTES;
|
|
||||||
const expectedResultHash = constants.KECCAK256_NULL;
|
|
||||||
const assetData = (await devUtils
|
|
||||||
.encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash)
|
|
||||||
.callAsync()).slice(0, -128);
|
|
||||||
const assetDataByteLen = (assetData.length - 2) / 2;
|
|
||||||
expect((assetDataByteLen - 4) % 32).to.equal(0);
|
|
||||||
await expectTransactionFailedWithoutReasonAsync(
|
|
||||||
staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('should revert if the offset to `staticCallData` points to outside of assetData', async () => {
|
|
||||||
const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData();
|
|
||||||
const expectedResultHash = constants.KECCAK256_NULL;
|
|
||||||
const assetData = await devUtils
|
|
||||||
.encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash)
|
|
||||||
.callAsync();
|
|
||||||
const offsetToStaticCallData = '0000000000000000000000000000000000000000000000000000000000000060';
|
|
||||||
const assetDataEndBuffer = ethUtil.toBuffer((assetData.length - 2) / 2 - 4);
|
|
||||||
const paddedAssetDataEndBuffer = ethUtil.setLengthLeft(assetDataEndBuffer, 32);
|
|
||||||
const invalidOffsetToStaticCallData = ethUtil.bufferToHex(paddedAssetDataEndBuffer).slice(2);
|
|
||||||
const newStaticCallData = '0000000000000000000000000000000000000000000000000000000000000304';
|
|
||||||
const badAssetData = `${assetData.replace(
|
|
||||||
offsetToStaticCallData,
|
|
||||||
invalidOffsetToStaticCallData,
|
|
||||||
)}${newStaticCallData}`;
|
|
||||||
await expectTransactionFailedWithoutReasonAsync(
|
|
||||||
staticCallProxy.transferFrom(badAssetData, fromAddress, toAddress, amount).sendTransactionAsync(),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('should revert if the callTarget attempts to write to state', async () => {
|
|
||||||
const staticCallData = staticCallTarget.updateState().getABIEncodedTransactionData();
|
|
||||||
const expectedResultHash = constants.KECCAK256_NULL;
|
|
||||||
const assetData = await devUtils
|
|
||||||
.encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash)
|
|
||||||
.callAsync();
|
|
||||||
await expectTransactionFailedWithoutReasonAsync(
|
|
||||||
staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('should revert with data provided by the callTarget if the staticcall reverts', async () => {
|
|
||||||
const staticCallData = staticCallTarget.assertEvenNumber(new BigNumber(1)).getABIEncodedTransactionData();
|
|
||||||
const expectedResultHash = constants.KECCAK256_NULL;
|
|
||||||
const assetData = await devUtils
|
|
||||||
.encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash)
|
|
||||||
.callAsync();
|
|
||||||
await expectTransactionFailedAsync(
|
|
||||||
staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(),
|
|
||||||
RevertReason.TargetNotEven,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('should revert if the hash of the output is different than expected expected', async () => {
|
|
||||||
const staticCallData = staticCallTarget.isOddNumber(new BigNumber(0)).getABIEncodedTransactionData();
|
|
||||||
const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001');
|
|
||||||
const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer));
|
|
||||||
const assetData = await devUtils
|
|
||||||
.encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash)
|
|
||||||
.callAsync();
|
|
||||||
await expectTransactionFailedAsync(
|
|
||||||
staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(),
|
|
||||||
RevertReason.UnexpectedStaticCallResult,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('should be successful if a function call with no inputs and no outputs is successful', async () => {
|
|
||||||
const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData();
|
|
||||||
const expectedResultHash = constants.KECCAK256_NULL;
|
|
||||||
const assetData = await devUtils
|
|
||||||
.encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash)
|
|
||||||
.callAsync();
|
|
||||||
await staticCallProxy
|
|
||||||
.transferFrom(assetData, fromAddress, toAddress, amount)
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
});
|
|
||||||
it('should be successful if the staticCallTarget is not a contract and no return value is expected', async () => {
|
|
||||||
const staticCallData = '0x0102030405060708';
|
|
||||||
const expectedResultHash = constants.KECCAK256_NULL;
|
|
||||||
const assetData = await devUtils
|
|
||||||
.encodeStaticCallAssetData(toAddress, staticCallData, expectedResultHash)
|
|
||||||
.callAsync();
|
|
||||||
await staticCallProxy
|
|
||||||
.transferFrom(assetData, fromAddress, toAddress, amount)
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
});
|
|
||||||
it('should be successful if a function call with one static input returns the correct value', async () => {
|
|
||||||
const staticCallData = staticCallTarget.isOddNumber(new BigNumber(1)).getABIEncodedTransactionData();
|
|
||||||
const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001');
|
|
||||||
const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer));
|
|
||||||
const assetData = await devUtils
|
|
||||||
.encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash)
|
|
||||||
.callAsync();
|
|
||||||
await staticCallProxy
|
|
||||||
.transferFrom(assetData, fromAddress, toAddress, amount)
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
});
|
|
||||||
it('should be successful if a function with one dynamic input is successful', async () => {
|
|
||||||
const dynamicInput = '0x0102030405060708';
|
|
||||||
const staticCallData = staticCallTarget.dynamicInputFunction(dynamicInput).getABIEncodedTransactionData();
|
|
||||||
const expectedResultHash = constants.KECCAK256_NULL;
|
|
||||||
const assetData = await devUtils
|
|
||||||
.encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash)
|
|
||||||
.callAsync();
|
|
||||||
await staticCallProxy
|
|
||||||
.transferFrom(assetData, fromAddress, toAddress, amount)
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
});
|
|
||||||
it('should be successful if a function call returns a complex type', async () => {
|
|
||||||
const a = new BigNumber(1);
|
|
||||||
const b = new BigNumber(2);
|
|
||||||
const staticCallData = staticCallTarget.returnComplexType(a, b).getABIEncodedTransactionData();
|
|
||||||
const abiEncoder = new AbiEncoder.DynamicBytes({
|
|
||||||
name: '',
|
|
||||||
type: 'bytes',
|
|
||||||
});
|
|
||||||
const aHex = '0000000000000000000000000000000000000000000000000000000000000001';
|
|
||||||
const bHex = '0000000000000000000000000000000000000000000000000000000000000002';
|
|
||||||
const expectedResults = `${staticCallTarget.address}${aHex}${bHex}`;
|
|
||||||
const offset = '0000000000000000000000000000000000000000000000000000000000000020';
|
|
||||||
const encodedExpectedResultWithOffset = `0x${offset}${abiEncoder.encode(expectedResults).slice(2)}`;
|
|
||||||
const expectedResultHash = ethUtil.bufferToHex(
|
|
||||||
ethUtil.sha3(ethUtil.toBuffer(encodedExpectedResultWithOffset)),
|
|
||||||
);
|
|
||||||
const assetData = await devUtils
|
|
||||||
.encodeStaticCallAssetData(staticCallTarget.address, staticCallData, expectedResultHash)
|
|
||||||
.callAsync();
|
|
||||||
await staticCallProxy
|
|
||||||
.transferFrom(assetData, fromAddress, toAddress, amount)
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,370 +0,0 @@
|
|||||||
import {
|
|
||||||
blockchainTests,
|
|
||||||
constants,
|
|
||||||
expect,
|
|
||||||
filterLogs,
|
|
||||||
filterLogsToArguments,
|
|
||||||
getRandomInteger,
|
|
||||||
hexLeftPad,
|
|
||||||
hexRandom,
|
|
||||||
Numberish,
|
|
||||||
randomAddress,
|
|
||||||
} from '@0x/contracts-test-utils';
|
|
||||||
import { AssetProxyId } from '@0x/types';
|
|
||||||
import { BigNumber } from '@0x/utils';
|
|
||||||
import { DecodedLogs } from 'ethereum-types';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
|
|
||||||
import {
|
|
||||||
TestUniswapBridgeContract,
|
|
||||||
TestUniswapBridgeEthToTokenTransferInputEventArgs as EthToTokenTransferInputArgs,
|
|
||||||
TestUniswapBridgeEvents as ContractEvents,
|
|
||||||
TestUniswapBridgeTokenApproveEventArgs as TokenApproveArgs,
|
|
||||||
TestUniswapBridgeTokenToEthSwapInputEventArgs as TokenToEthSwapInputArgs,
|
|
||||||
TestUniswapBridgeTokenToTokenTransferInputEventArgs as TokenToTokenTransferInputArgs,
|
|
||||||
TestUniswapBridgeTokenTransferEventArgs as TokenTransferArgs,
|
|
||||||
TestUniswapBridgeWethDepositEventArgs as WethDepositArgs,
|
|
||||||
TestUniswapBridgeWethWithdrawEventArgs as WethWithdrawArgs,
|
|
||||||
} from './wrappers';
|
|
||||||
|
|
||||||
blockchainTests.resets('UniswapBridge unit tests', env => {
|
|
||||||
let testContract: TestUniswapBridgeContract;
|
|
||||||
let wethTokenAddress: string;
|
|
||||||
|
|
||||||
before(async () => {
|
|
||||||
testContract = await TestUniswapBridgeContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.TestUniswapBridge,
|
|
||||||
env.provider,
|
|
||||||
env.txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
wethTokenAddress = await testContract.wethToken().callAsync();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('isValidSignature()', () => {
|
|
||||||
it('returns success bytes', async () => {
|
|
||||||
const LEGACY_WALLET_MAGIC_VALUE = '0xb0671381';
|
|
||||||
const result = await testContract.isValidSignature(hexRandom(), hexRandom(_.random(0, 32))).callAsync();
|
|
||||||
expect(result).to.eq(LEGACY_WALLET_MAGIC_VALUE);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('bridgeTransferFrom()', () => {
|
|
||||||
interface WithdrawToOpts {
|
|
||||||
fromTokenAddress: string;
|
|
||||||
toTokenAddress: string;
|
|
||||||
fromTokenBalance: Numberish;
|
|
||||||
toAddress: string;
|
|
||||||
amount: Numberish;
|
|
||||||
exchangeRevertReason: string;
|
|
||||||
exchangeFillAmount: Numberish;
|
|
||||||
toTokenRevertReason: string;
|
|
||||||
fromTokenRevertReason: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createWithdrawToOpts(opts?: Partial<WithdrawToOpts>): WithdrawToOpts {
|
|
||||||
return {
|
|
||||||
fromTokenAddress: constants.NULL_ADDRESS,
|
|
||||||
toTokenAddress: constants.NULL_ADDRESS,
|
|
||||||
fromTokenBalance: getRandomInteger(1, 1e18),
|
|
||||||
toAddress: randomAddress(),
|
|
||||||
amount: getRandomInteger(1, 1e18),
|
|
||||||
exchangeRevertReason: '',
|
|
||||||
exchangeFillAmount: getRandomInteger(1, 1e18),
|
|
||||||
toTokenRevertReason: '',
|
|
||||||
fromTokenRevertReason: '',
|
|
||||||
...opts,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface WithdrawToResult {
|
|
||||||
opts: WithdrawToOpts;
|
|
||||||
result: string;
|
|
||||||
logs: DecodedLogs;
|
|
||||||
blockTime: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function withdrawToAsync(opts?: Partial<WithdrawToOpts>): Promise<WithdrawToResult> {
|
|
||||||
const _opts = createWithdrawToOpts(opts);
|
|
||||||
const callData = { value: new BigNumber(_opts.exchangeFillAmount) };
|
|
||||||
// Create the "from" token and exchange.
|
|
||||||
const createFromTokenFn = testContract.createTokenAndExchange(
|
|
||||||
_opts.fromTokenAddress,
|
|
||||||
_opts.exchangeRevertReason,
|
|
||||||
);
|
|
||||||
[_opts.fromTokenAddress] = await createFromTokenFn.callAsync(callData);
|
|
||||||
await createFromTokenFn.awaitTransactionSuccessAsync(callData);
|
|
||||||
|
|
||||||
// Create the "to" token and exchange.
|
|
||||||
const createToTokenFn = testContract.createTokenAndExchange(
|
|
||||||
_opts.toTokenAddress,
|
|
||||||
_opts.exchangeRevertReason,
|
|
||||||
);
|
|
||||||
[_opts.toTokenAddress] = await createToTokenFn.callAsync(callData);
|
|
||||||
await createToTokenFn.awaitTransactionSuccessAsync(callData);
|
|
||||||
|
|
||||||
await testContract
|
|
||||||
.setTokenRevertReason(_opts.toTokenAddress, _opts.toTokenRevertReason)
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
await testContract
|
|
||||||
.setTokenRevertReason(_opts.fromTokenAddress, _opts.fromTokenRevertReason)
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
// Set the token balance for the token we're converting from.
|
|
||||||
await testContract.setTokenBalance(_opts.fromTokenAddress).awaitTransactionSuccessAsync({
|
|
||||||
value: new BigNumber(_opts.fromTokenBalance),
|
|
||||||
});
|
|
||||||
// Call bridgeTransferFrom().
|
|
||||||
const bridgeTransferFromFn = testContract.bridgeTransferFrom(
|
|
||||||
// The "to" token address.
|
|
||||||
_opts.toTokenAddress,
|
|
||||||
// The "from" address.
|
|
||||||
randomAddress(),
|
|
||||||
// The "to" address.
|
|
||||||
_opts.toAddress,
|
|
||||||
// The amount to transfer to "to"
|
|
||||||
new BigNumber(_opts.amount),
|
|
||||||
// ABI-encoded "from" token address.
|
|
||||||
hexLeftPad(_opts.fromTokenAddress),
|
|
||||||
);
|
|
||||||
const result = await bridgeTransferFromFn.callAsync();
|
|
||||||
const receipt = await bridgeTransferFromFn.awaitTransactionSuccessAsync();
|
|
||||||
return {
|
|
||||||
opts: _opts,
|
|
||||||
result,
|
|
||||||
logs: (receipt.logs as any) as DecodedLogs,
|
|
||||||
blockTime: await env.web3Wrapper.getBlockTimestampAsync(receipt.blockNumber),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getExchangeForTokenAsync(tokenAddress: string): Promise<string> {
|
|
||||||
return testContract.getExchange(tokenAddress).callAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
it('returns magic bytes on success', async () => {
|
|
||||||
const { result } = await withdrawToAsync();
|
|
||||||
expect(result).to.eq(AssetProxyId.ERC20Bridge);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('just transfers tokens to `to` if the same tokens are in play', async () => {
|
|
||||||
const createTokenFn = await testContract.createTokenAndExchange(constants.NULL_ADDRESS, '');
|
|
||||||
const [tokenAddress] = await createTokenFn.callAsync();
|
|
||||||
await createTokenFn.awaitTransactionSuccessAsync();
|
|
||||||
const { opts, result, logs } = await withdrawToAsync({
|
|
||||||
fromTokenAddress: tokenAddress,
|
|
||||||
toTokenAddress: tokenAddress,
|
|
||||||
});
|
|
||||||
expect(result).to.eq(AssetProxyId.ERC20Bridge);
|
|
||||||
const transfers = filterLogsToArguments<TokenTransferArgs>(logs, ContractEvents.TokenTransfer);
|
|
||||||
expect(transfers.length).to.eq(1);
|
|
||||||
expect(transfers[0].token).to.eq(tokenAddress);
|
|
||||||
expect(transfers[0].from).to.eq(testContract.address);
|
|
||||||
expect(transfers[0].to).to.eq(opts.toAddress);
|
|
||||||
expect(transfers[0].amount).to.bignumber.eq(opts.amount);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('token -> token', () => {
|
|
||||||
it('calls `IUniswapExchange.tokenToTokenTransferInput()', async () => {
|
|
||||||
const { opts, logs, blockTime } = await withdrawToAsync();
|
|
||||||
const exchangeAddress = await getExchangeForTokenAsync(opts.fromTokenAddress);
|
|
||||||
const calls = filterLogsToArguments<TokenToTokenTransferInputArgs>(
|
|
||||||
logs,
|
|
||||||
ContractEvents.TokenToTokenTransferInput,
|
|
||||||
);
|
|
||||||
expect(calls.length).to.eq(1);
|
|
||||||
expect(calls[0].exchange).to.eq(exchangeAddress);
|
|
||||||
expect(calls[0].tokensSold).to.bignumber.eq(opts.fromTokenBalance);
|
|
||||||
expect(calls[0].minTokensBought).to.bignumber.eq(opts.amount);
|
|
||||||
expect(calls[0].minEthBought).to.bignumber.eq(0);
|
|
||||||
expect(calls[0].deadline).to.bignumber.eq(blockTime);
|
|
||||||
expect(calls[0].recipient).to.eq(opts.toAddress);
|
|
||||||
expect(calls[0].toTokenAddress).to.eq(opts.toTokenAddress);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets allowance for "from" token', async () => {
|
|
||||||
const { opts, logs } = await withdrawToAsync();
|
|
||||||
const approvals = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
|
|
||||||
const exchangeAddress = await getExchangeForTokenAsync(opts.fromTokenAddress);
|
|
||||||
expect(approvals.length).to.eq(1);
|
|
||||||
expect(approvals[0].spender).to.eq(exchangeAddress);
|
|
||||||
expect(approvals[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets allowance for "from" token on subsequent calls', async () => {
|
|
||||||
const { opts } = await withdrawToAsync();
|
|
||||||
const { logs } = await withdrawToAsync(opts);
|
|
||||||
const approvals = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
|
|
||||||
const exchangeAddress = await getExchangeForTokenAsync(opts.fromTokenAddress);
|
|
||||||
expect(approvals.length).to.eq(1);
|
|
||||||
expect(approvals[0].spender).to.eq(exchangeAddress);
|
|
||||||
expect(approvals[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if "from" token does not exist', async () => {
|
|
||||||
const tx = testContract
|
|
||||||
.bridgeTransferFrom(
|
|
||||||
randomAddress(),
|
|
||||||
randomAddress(),
|
|
||||||
randomAddress(),
|
|
||||||
getRandomInteger(1, 1e18),
|
|
||||||
hexLeftPad(randomAddress()),
|
|
||||||
)
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
return expect(tx).to.eventually.be.rejectedWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if the exchange fails', async () => {
|
|
||||||
const revertReason = 'FOOBAR';
|
|
||||||
const tx = withdrawToAsync({
|
|
||||||
exchangeRevertReason: revertReason,
|
|
||||||
});
|
|
||||||
return expect(tx).to.eventually.be.rejectedWith(revertReason);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('token -> ETH', () => {
|
|
||||||
it('calls `IUniswapExchange.tokenToEthSwapInput()`, `WETH.deposit()`, then `transfer()`', async () => {
|
|
||||||
const { opts, logs, blockTime } = await withdrawToAsync({
|
|
||||||
toTokenAddress: wethTokenAddress,
|
|
||||||
});
|
|
||||||
const exchangeAddress = await getExchangeForTokenAsync(opts.fromTokenAddress);
|
|
||||||
let calls: any = filterLogs<TokenToEthSwapInputArgs>(logs, ContractEvents.TokenToEthSwapInput);
|
|
||||||
expect(calls.length).to.eq(1);
|
|
||||||
expect(calls[0].args.exchange).to.eq(exchangeAddress);
|
|
||||||
expect(calls[0].args.tokensSold).to.bignumber.eq(opts.fromTokenBalance);
|
|
||||||
expect(calls[0].args.minEthBought).to.bignumber.eq(opts.amount);
|
|
||||||
expect(calls[0].args.deadline).to.bignumber.eq(blockTime);
|
|
||||||
calls = filterLogs<WethDepositArgs>(
|
|
||||||
logs.slice(calls[0].logIndex as number),
|
|
||||||
ContractEvents.WethDeposit,
|
|
||||||
);
|
|
||||||
expect(calls.length).to.eq(1);
|
|
||||||
expect(calls[0].args.amount).to.bignumber.eq(opts.exchangeFillAmount);
|
|
||||||
calls = filterLogs<TokenTransferArgs>(
|
|
||||||
logs.slice(calls[0].logIndex as number),
|
|
||||||
ContractEvents.TokenTransfer,
|
|
||||||
);
|
|
||||||
expect(calls.length).to.eq(1);
|
|
||||||
expect(calls[0].args.token).to.eq(opts.toTokenAddress);
|
|
||||||
expect(calls[0].args.from).to.eq(testContract.address);
|
|
||||||
expect(calls[0].args.to).to.eq(opts.toAddress);
|
|
||||||
expect(calls[0].args.amount).to.bignumber.eq(opts.exchangeFillAmount);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets allowance for "from" token', async () => {
|
|
||||||
const { opts, logs } = await withdrawToAsync({
|
|
||||||
toTokenAddress: wethTokenAddress,
|
|
||||||
});
|
|
||||||
const transfers = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
|
|
||||||
const exchangeAddress = await getExchangeForTokenAsync(opts.fromTokenAddress);
|
|
||||||
expect(transfers.length).to.eq(1);
|
|
||||||
expect(transfers[0].spender).to.eq(exchangeAddress);
|
|
||||||
expect(transfers[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets allowance for "from" token on subsequent calls', async () => {
|
|
||||||
const { opts } = await withdrawToAsync({
|
|
||||||
toTokenAddress: wethTokenAddress,
|
|
||||||
});
|
|
||||||
const { logs } = await withdrawToAsync(opts);
|
|
||||||
const approvals = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
|
|
||||||
const exchangeAddress = await getExchangeForTokenAsync(opts.fromTokenAddress);
|
|
||||||
expect(approvals.length).to.eq(1);
|
|
||||||
expect(approvals[0].spender).to.eq(exchangeAddress);
|
|
||||||
expect(approvals[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if "from" token does not exist', async () => {
|
|
||||||
const tx = testContract
|
|
||||||
.bridgeTransferFrom(
|
|
||||||
randomAddress(),
|
|
||||||
randomAddress(),
|
|
||||||
randomAddress(),
|
|
||||||
getRandomInteger(1, 1e18),
|
|
||||||
hexLeftPad(wethTokenAddress),
|
|
||||||
)
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
return expect(tx).to.eventually.be.rejectedWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if `WETH.deposit()` fails', async () => {
|
|
||||||
const revertReason = 'FOOBAR';
|
|
||||||
const tx = withdrawToAsync({
|
|
||||||
toTokenAddress: wethTokenAddress,
|
|
||||||
toTokenRevertReason: revertReason,
|
|
||||||
});
|
|
||||||
return expect(tx).to.eventually.be.rejectedWith(revertReason);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if the exchange fails', async () => {
|
|
||||||
const revertReason = 'FOOBAR';
|
|
||||||
const tx = withdrawToAsync({
|
|
||||||
toTokenAddress: wethTokenAddress,
|
|
||||||
exchangeRevertReason: revertReason,
|
|
||||||
});
|
|
||||||
return expect(tx).to.eventually.be.rejectedWith(revertReason);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('ETH -> token', () => {
|
|
||||||
it('calls `WETH.withdraw()`, then `IUniswapExchange.ethToTokenTransferInput()`', async () => {
|
|
||||||
const { opts, logs, blockTime } = await withdrawToAsync({
|
|
||||||
fromTokenAddress: wethTokenAddress,
|
|
||||||
});
|
|
||||||
const exchangeAddress = await getExchangeForTokenAsync(opts.toTokenAddress);
|
|
||||||
let calls: any = filterLogs<WethWithdrawArgs>(logs, ContractEvents.WethWithdraw);
|
|
||||||
expect(calls.length).to.eq(1);
|
|
||||||
expect(calls[0].args.amount).to.bignumber.eq(opts.fromTokenBalance);
|
|
||||||
calls = filterLogs<EthToTokenTransferInputArgs>(
|
|
||||||
logs.slice(calls[0].logIndex as number),
|
|
||||||
ContractEvents.EthToTokenTransferInput,
|
|
||||||
);
|
|
||||||
expect(calls.length).to.eq(1);
|
|
||||||
expect(calls[0].args.exchange).to.eq(exchangeAddress);
|
|
||||||
expect(calls[0].args.minTokensBought).to.bignumber.eq(opts.amount);
|
|
||||||
expect(calls[0].args.deadline).to.bignumber.eq(blockTime);
|
|
||||||
expect(calls[0].args.recipient).to.eq(opts.toAddress);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not set any allowance', async () => {
|
|
||||||
const { logs } = await withdrawToAsync({
|
|
||||||
fromTokenAddress: wethTokenAddress,
|
|
||||||
});
|
|
||||||
const approvals = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
|
|
||||||
expect(approvals).to.be.empty('');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if "to" token does not exist', async () => {
|
|
||||||
const tx = testContract
|
|
||||||
.bridgeTransferFrom(
|
|
||||||
wethTokenAddress,
|
|
||||||
randomAddress(),
|
|
||||||
randomAddress(),
|
|
||||||
getRandomInteger(1, 1e18),
|
|
||||||
hexLeftPad(randomAddress()),
|
|
||||||
)
|
|
||||||
.awaitTransactionSuccessAsync();
|
|
||||||
return expect(tx).to.eventually.be.rejectedWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if the `WETH.withdraw()` fails', async () => {
|
|
||||||
const revertReason = 'FOOBAR';
|
|
||||||
const tx = withdrawToAsync({
|
|
||||||
fromTokenAddress: wethTokenAddress,
|
|
||||||
fromTokenRevertReason: revertReason,
|
|
||||||
});
|
|
||||||
return expect(tx).to.eventually.be.rejectedWith(revertReason);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails if the exchange fails', async () => {
|
|
||||||
const revertReason = 'FOOBAR';
|
|
||||||
const tx = withdrawToAsync({
|
|
||||||
fromTokenAddress: wethTokenAddress,
|
|
||||||
exchangeRevertReason: revertReason,
|
|
||||||
});
|
|
||||||
return expect(tx).to.eventually.be.rejectedWith(revertReason);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
export * from '../test/generated-wrappers/erc1155_proxy';
|
|
||||||
export * from '../test/generated-wrappers/erc20_bridge_proxy';
|
|
||||||
export * from '../test/generated-wrappers/erc20_proxy';
|
|
||||||
export * from '../test/generated-wrappers/erc721_proxy';
|
|
||||||
export * from '../test/generated-wrappers/eth2_dai_bridge';
|
|
||||||
export * from '../test/generated-wrappers/i_asset_data';
|
|
||||||
export * from '../test/generated-wrappers/i_asset_proxy';
|
|
||||||
export * from '../test/generated-wrappers/i_asset_proxy_dispatcher';
|
|
||||||
export * from '../test/generated-wrappers/i_authorizable';
|
|
||||||
export * from '../test/generated-wrappers/i_erc20_bridge';
|
|
||||||
export * from '../test/generated-wrappers/i_eth2_dai';
|
|
||||||
export * from '../test/generated-wrappers/i_uniswap_exchange';
|
|
||||||
export * from '../test/generated-wrappers/i_uniswap_exchange_factory';
|
|
||||||
export * from '../test/generated-wrappers/mixin_asset_proxy_dispatcher';
|
|
||||||
export * from '../test/generated-wrappers/mixin_authorizable';
|
|
||||||
export * from '../test/generated-wrappers/multi_asset_proxy';
|
|
||||||
export * from '../test/generated-wrappers/ownable';
|
|
||||||
export * from '../test/generated-wrappers/static_call_proxy';
|
|
||||||
export * from '../test/generated-wrappers/test_erc20_bridge';
|
|
||||||
export * from '../test/generated-wrappers/test_eth2_dai_bridge';
|
|
||||||
export * from '../test/generated-wrappers/test_static_call_target';
|
|
||||||
export * from '../test/generated-wrappers/test_uniswap_bridge';
|
|
||||||
export * from '../test/generated-wrappers/uniswap_bridge';
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
/**
|
|
||||||
* Use this file to configure your truffle project. It's seeded with some
|
|
||||||
* common settings for different networks and features like migrations,
|
|
||||||
* compilation and testing. Uncomment the ones you need or modify
|
|
||||||
* them to suit your project as necessary.
|
|
||||||
*
|
|
||||||
* More information about configuration can be found at:
|
|
||||||
*
|
|
||||||
* truffleframework.com/docs/advanced/configuration
|
|
||||||
*
|
|
||||||
* To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider)
|
|
||||||
* to sign your transactions before they're sent to a remote public node. Infura accounts
|
|
||||||
* are available for free at: infura.io/register.
|
|
||||||
*
|
|
||||||
* You'll also need a mnemonic - the twelve word phrase the wallet uses to generate
|
|
||||||
* public/private key pairs. If you're publishing your code to GitHub make sure you load this
|
|
||||||
* phrase from a file you've .gitignored so it doesn't accidentally become public.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
// const HDWalletProvider = require('truffle-hdwallet-provider');
|
|
||||||
// const infuraKey = "fj4jll3k.....";
|
|
||||||
//
|
|
||||||
// const fs = require('fs');
|
|
||||||
// const mnemonic = fs.readFileSync(".secret").toString().trim();
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
/**
|
|
||||||
* Networks define how you connect to your ethereum client and let you set the
|
|
||||||
* defaults web3 uses to send transactions. If you don't specify one truffle
|
|
||||||
* will spin up a development blockchain for you on port 9545 when you
|
|
||||||
* run `develop` or `test`. You can ask a truffle command to use a specific
|
|
||||||
* network from the command line, e.g
|
|
||||||
*
|
|
||||||
* $ truffle test --network <network-name>
|
|
||||||
*/
|
|
||||||
|
|
||||||
networks: {
|
|
||||||
// Useful for testing. The `development` name is special - truffle uses it by default
|
|
||||||
// if it's defined here and no other network is specified at the command line.
|
|
||||||
// You should run a client (like ganache-cli, geth or parity) in a separate terminal
|
|
||||||
// tab if you use this network and you must also set the `host`, `port` and `network_id`
|
|
||||||
// options below to some value.
|
|
||||||
//
|
|
||||||
// development: {
|
|
||||||
// host: "127.0.0.1", // Localhost (default: none)
|
|
||||||
// port: 8545, // Standard Ethereum port (default: none)
|
|
||||||
// network_id: "*", // Any network (default: none)
|
|
||||||
// },
|
|
||||||
// Another network with more advanced options...
|
|
||||||
// advanced: {
|
|
||||||
// port: 8777, // Custom port
|
|
||||||
// network_id: 1342, // Custom network
|
|
||||||
// gas: 8500000, // Gas sent with each transaction (default: ~6700000)
|
|
||||||
// gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei)
|
|
||||||
// from: <address>, // Account to send txs from (default: accounts[0])
|
|
||||||
// websockets: true // Enable EventEmitter interface for web3 (default: false)
|
|
||||||
// },
|
|
||||||
// Useful for deploying to a public network.
|
|
||||||
// NB: It's important to wrap the provider as a function.
|
|
||||||
// ropsten: {
|
|
||||||
// provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`),
|
|
||||||
// network_id: 3, // Ropsten's id
|
|
||||||
// gas: 5500000, // Ropsten has a lower block limit than mainnet
|
|
||||||
// confirmations: 2, // # of confs to wait between deployments. (default: 0)
|
|
||||||
// timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
|
|
||||||
// skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
|
|
||||||
// },
|
|
||||||
// Useful for private networks
|
|
||||||
// private: {
|
|
||||||
// provider: () => new HDWalletProvider(mnemonic, `https://network.io`),
|
|
||||||
// network_id: 2111, // This network is yours, in the cloud.
|
|
||||||
// production: true // Treats this network as if it was a public net. (default: false)
|
|
||||||
// }
|
|
||||||
},
|
|
||||||
|
|
||||||
// Set default mocha options here, use special reporters etc.
|
|
||||||
mocha: {
|
|
||||||
// timeout: 100000
|
|
||||||
},
|
|
||||||
|
|
||||||
// Configure your compilers
|
|
||||||
compilers: {
|
|
||||||
solc: {
|
|
||||||
version: '0.5.9',
|
|
||||||
settings: {
|
|
||||||
evmVersion: 'constantinople',
|
|
||||||
optimizer: {
|
|
||||||
enabled: true,
|
|
||||||
runs: 1000000,
|
|
||||||
details: { yul: true, deduplicate: true, cse: true, constantOptimizer: true },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../../tsconfig",
|
|
||||||
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
|
|
||||||
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
|
||||||
"files": [
|
|
||||||
"generated-artifacts/ERC1155Proxy.json",
|
|
||||||
"generated-artifacts/ERC20BridgeProxy.json",
|
|
||||||
"generated-artifacts/ERC20Proxy.json",
|
|
||||||
"generated-artifacts/ERC721Proxy.json",
|
|
||||||
"generated-artifacts/Eth2DaiBridge.json",
|
|
||||||
"generated-artifacts/IAssetData.json",
|
|
||||||
"generated-artifacts/IAssetProxy.json",
|
|
||||||
"generated-artifacts/MultiAssetProxy.json",
|
|
||||||
"generated-artifacts/StaticCallProxy.json",
|
|
||||||
"generated-artifacts/TestStaticCallTarget.json",
|
|
||||||
"generated-artifacts/UniswapBridge.json",
|
|
||||||
"test/generated-artifacts/ERC1155Proxy.json",
|
|
||||||
"test/generated-artifacts/ERC20BridgeProxy.json",
|
|
||||||
"test/generated-artifacts/ERC20Proxy.json",
|
|
||||||
"test/generated-artifacts/ERC721Proxy.json",
|
|
||||||
"test/generated-artifacts/Eth2DaiBridge.json",
|
|
||||||
"test/generated-artifacts/IAssetData.json",
|
|
||||||
"test/generated-artifacts/IAssetProxy.json",
|
|
||||||
"test/generated-artifacts/IAssetProxyDispatcher.json",
|
|
||||||
"test/generated-artifacts/IAuthorizable.json",
|
|
||||||
"test/generated-artifacts/IERC20Bridge.json",
|
|
||||||
"test/generated-artifacts/IEth2Dai.json",
|
|
||||||
"test/generated-artifacts/IUniswapExchange.json",
|
|
||||||
"test/generated-artifacts/IUniswapExchangeFactory.json",
|
|
||||||
"test/generated-artifacts/MixinAssetProxyDispatcher.json",
|
|
||||||
"test/generated-artifacts/MixinAuthorizable.json",
|
|
||||||
"test/generated-artifacts/MultiAssetProxy.json",
|
|
||||||
"test/generated-artifacts/Ownable.json",
|
|
||||||
"test/generated-artifacts/StaticCallProxy.json",
|
|
||||||
"test/generated-artifacts/TestERC20Bridge.json",
|
|
||||||
"test/generated-artifacts/TestEth2DaiBridge.json",
|
|
||||||
"test/generated-artifacts/TestStaticCallTarget.json",
|
|
||||||
"test/generated-artifacts/TestUniswapBridge.json",
|
|
||||||
"test/generated-artifacts/UniswapBridge.json"
|
|
||||||
],
|
|
||||||
"exclude": ["./deploy/solc/solc_bin"]
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["@0x/tslint-config"],
|
|
||||||
"rules": {
|
|
||||||
"custom-no-magic-numbers": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../../typedoc-tsconfig",
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "lib"
|
|
||||||
},
|
|
||||||
"include": ["./src/**/*", "./test/**/*"]
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# solhint can't parse `abi.decode` syntax.
|
|
||||||
contracts/src/MixinCoordinatorApprovalVerifier.sol
|
|
||||||
@@ -1,247 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"version": "2.1.0-beta.3",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1574238768
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.1.0-beta.2",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils",
|
|
||||||
"pr": 2330
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Introduced new export CoordinatorRevertErrors",
|
|
||||||
"pr": 2321
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Added dependency on @0x/contracts-utils",
|
|
||||||
"pr": 2321
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1574030254
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.1.0-beta.1",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1573159180
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.1.0-beta.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Add chainId to domain separator",
|
|
||||||
"pr": 1742
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Inherit Exchange domain constants from `exchange-libs` to reduce code duplication",
|
|
||||||
"pr": 1742
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Update domain separator",
|
|
||||||
"pr": 1742
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Refactor contract to use new ITransactions interface",
|
|
||||||
"pr": 1753
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add verifyingContractIfExists arg to LibEIP712CoordinatorDomain constructor",
|
|
||||||
"pr": 1753
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Remove LibZeroExTransaction contract",
|
|
||||||
"pr": 1753
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Update tests for arbitrary fee tokens (ZEIP-28).",
|
|
||||||
"pr": 1819
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Update for new `marketXOrders` consolidation.",
|
|
||||||
"pr": 2042
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Use built in selectors instead of hard coded constants",
|
|
||||||
"pr": 2055
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Compile and export all contracts, artifacts, and wrappers by default",
|
|
||||||
"pr": 2055
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1570135330
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1568744790,
|
|
||||||
"version": "2.0.13",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1567521715,
|
|
||||||
"version": "2.0.12",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1566446343,
|
|
||||||
"version": "2.0.11",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1565296576,
|
|
||||||
"version": "2.0.10",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.0.9",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Updated calls to <contract wrapper>.deployFrom0xArtifactAsync to include artifact dependencies.",
|
|
||||||
"pr": 1995
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1564607468
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1563957393,
|
|
||||||
"version": "2.0.8",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1563193019,
|
|
||||||
"version": "2.0.7",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1563047529,
|
|
||||||
"version": "2.0.6",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1563006338,
|
|
||||||
"version": "2.0.5",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1558712885,
|
|
||||||
"version": "2.0.4",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1557961111,
|
|
||||||
"version": "2.0.3",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1557799313,
|
|
||||||
"version": "2.0.2",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1557507213,
|
|
||||||
"version": "2.0.1",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Make `decodeOrdersFromFillData`, `getCoordinatorApprovalHash`, and `getTransactionHash` public",
|
|
||||||
"pr": 1729
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Make `assertValidTransactionOrdersApproval` internal",
|
|
||||||
"pr": 1729
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1554997931
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "1.1.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Run Web3ProviderEngine without excess block polling",
|
|
||||||
"pr": 1695
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1553183790
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "1.0.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Created Coordinator package"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Use separate EIP712 domains for transactions and approvals",
|
|
||||||
"pr": 1705
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add `SignatureType.Invalid`",
|
|
||||||
"pr": 1705
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Set `evmVersion` to `constantinople`",
|
|
||||||
"pr": 1707
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1553091633
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
<!--
|
|
||||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
|
||||||
Edit the package's CHANGELOG.json file only.
|
|
||||||
-->
|
|
||||||
|
|
||||||
CHANGELOG
|
|
||||||
|
|
||||||
## v2.1.0-beta.3 - _November 20, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.1.0-beta.2 - _November 17, 2019_
|
|
||||||
|
|
||||||
* Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils (#2330)
|
|
||||||
* Introduced new export CoordinatorRevertErrors (#2321)
|
|
||||||
* Added dependency on @0x/contracts-utils (#2321)
|
|
||||||
|
|
||||||
## v2.1.0-beta.1 - _November 7, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.1.0-beta.0 - _October 3, 2019_
|
|
||||||
|
|
||||||
* Add chainId to domain separator (#1742)
|
|
||||||
* Inherit Exchange domain constants from `exchange-libs` to reduce code duplication (#1742)
|
|
||||||
* Update domain separator (#1742)
|
|
||||||
* Refactor contract to use new ITransactions interface (#1753)
|
|
||||||
* Add verifyingContractIfExists arg to LibEIP712CoordinatorDomain constructor (#1753)
|
|
||||||
* Remove LibZeroExTransaction contract (#1753)
|
|
||||||
* Update tests for arbitrary fee tokens (ZEIP-28). (#1819)
|
|
||||||
* Update for new `marketXOrders` consolidation. (#2042)
|
|
||||||
* Use built in selectors instead of hard coded constants (#2055)
|
|
||||||
* Compile and export all contracts, artifacts, and wrappers by default (#2055)
|
|
||||||
|
|
||||||
## v2.0.13 - _September 17, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.0.12 - _September 3, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.0.11 - _August 22, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.0.10 - _August 8, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.0.9 - _July 31, 2019_
|
|
||||||
|
|
||||||
* Updated calls to <contract wrapper>.deployFrom0xArtifactAsync to include artifact dependencies. (#1995)
|
|
||||||
|
|
||||||
## v2.0.8 - _July 24, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.0.7 - _July 15, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.0.6 - _July 13, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.0.5 - _July 13, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.0.4 - _May 24, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.0.3 - _May 15, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.0.2 - _May 14, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.0.1 - _May 10, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v2.0.0 - _April 11, 2019_
|
|
||||||
|
|
||||||
* Make `decodeOrdersFromFillData`, `getCoordinatorApprovalHash`, and `getTransactionHash` public (#1729)
|
|
||||||
* Make `assertValidTransactionOrdersApproval` internal (#1729)
|
|
||||||
|
|
||||||
## v1.1.0 - _March 21, 2019_
|
|
||||||
|
|
||||||
* Run Web3ProviderEngine without excess block polling (#1695)
|
|
||||||
|
|
||||||
## v1.0.0 - _March 20, 2019_
|
|
||||||
|
|
||||||
* Created Coordinator package
|
|
||||||
* Use separate EIP712 domains for transactions and approvals (#1705)
|
|
||||||
* Add `SignatureType.Invalid` (#1705)
|
|
||||||
* Set `evmVersion` to `constantinople` (#1707)
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
## Coordinator
|
|
||||||
|
|
||||||
This package contains a contract that allows users to call arbitrary functions on the Exchange contract with permission from one or more Coordinators. Addresses of the deployed contracts can be found in this 0x [guide](https://0x.org/docs/guides/0x-cheat-sheet) or the [DEPLOYS](./DEPLOYS.json) file within this package.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
**Install**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install @0x/contracts-coordinator --save
|
|
||||||
```
|
|
||||||
|
|
||||||
## Bug bounty
|
|
||||||
|
|
||||||
A bug bounty for the 2.0.0 contracts is ongoing! Instructions can be found [here](https://0x.org/docs/guides/bug-bounty-program).
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein.
|
|
||||||
|
|
||||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
|
||||||
|
|
||||||
### Install Dependencies
|
|
||||||
|
|
||||||
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn config set workspaces-experimental true
|
|
||||||
```
|
|
||||||
|
|
||||||
Then install dependencies
|
|
||||||
|
|
||||||
```bash
|
|
||||||
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
|
|
||||||
PKG=@0x/contracts-coordinator yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
Or continuously rebuild on change:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
PKG=@0x/contracts-coordinator yarn watch
|
|
||||||
```
|
|
||||||
|
|
||||||
### Clean
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn clean
|
|
||||||
```
|
|
||||||
|
|
||||||
### Lint
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn lint
|
|
||||||
```
|
|
||||||
|
|
||||||
### Run Tests
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn test
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Testing options
|
|
||||||
|
|
||||||
Contracts testing options like coverage, profiling, revert traces or backing node choosing - are described [here](../TESTING.md).
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
"artifactsDir": "./test/generated-artifacts",
|
|
||||||
"contractsDir": "./contracts",
|
|
||||||
"useDockerisedSolc": false,
|
|
||||||
"compilerSettings": {
|
|
||||||
"evmVersion": "constantinople",
|
|
||||||
"optimizer": {
|
|
||||||
"enabled": true,
|
|
||||||
"runs": 1000000,
|
|
||||||
"details": { "yul": true, "deduplicate": true, "cse": true, "constantOptimizer": true }
|
|
||||||
},
|
|
||||||
"outputSelection": {
|
|
||||||
"*": {
|
|
||||||
"*": [
|
|
||||||
"abi",
|
|
||||||
"devdoc",
|
|
||||||
"evm.bytecode.object",
|
|
||||||
"evm.bytecode.sourceMap",
|
|
||||||
"evm.deployedBytecode.object",
|
|
||||||
"evm.deployedBytecode.sourceMap"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
|
||||||
import "./libs/LibConstants.sol";
|
|
||||||
import "./libs/LibEIP712CoordinatorDomain.sol";
|
|
||||||
import "./MixinSignatureValidator.sol";
|
|
||||||
import "./MixinCoordinatorApprovalVerifier.sol";
|
|
||||||
import "./MixinCoordinatorCore.sol";
|
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable no-empty-blocks
|
|
||||||
contract Coordinator is
|
|
||||||
LibConstants,
|
|
||||||
MixinSignatureValidator,
|
|
||||||
MixinCoordinatorApprovalVerifier,
|
|
||||||
MixinCoordinatorCore
|
|
||||||
{
|
|
||||||
/// @param exchange Address of the 0x Exchange contract.
|
|
||||||
/// @param chainId Chain ID of the network this contract is deployed on.
|
|
||||||
constructor (address exchange, uint256 chainId)
|
|
||||||
public
|
|
||||||
LibConstants(exchange)
|
|
||||||
LibEIP712CoordinatorDomain(chainId, address(0))
|
|
||||||
LibEIP712ExchangeDomain(chainId, exchange)
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibAddressArray.sol";
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
|
||||||
import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
|
|
||||||
import "./libs/LibCoordinatorApproval.sol";
|
|
||||||
import "./libs/LibCoordinatorRichErrors.sol";
|
|
||||||
import "./interfaces/ICoordinatorSignatureValidator.sol";
|
|
||||||
import "./interfaces/ICoordinatorApprovalVerifier.sol";
|
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable avoid-tx-origin
|
|
||||||
contract MixinCoordinatorApprovalVerifier is
|
|
||||||
LibCoordinatorApproval,
|
|
||||||
LibEIP712ExchangeDomain,
|
|
||||||
ICoordinatorSignatureValidator,
|
|
||||||
ICoordinatorApprovalVerifier
|
|
||||||
{
|
|
||||||
using LibBytes for bytes;
|
|
||||||
using LibAddressArray for address[];
|
|
||||||
|
|
||||||
/// @dev Validates that the 0x transaction has been approved by all of the feeRecipients
|
|
||||||
/// that correspond to each order in the transaction's Exchange calldata.
|
|
||||||
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
|
||||||
/// @param txOrigin Required signer of Ethereum transaction calling this function.
|
|
||||||
/// @param transactionSignature Proof that the transaction has been signed by the signer.
|
|
||||||
/// @param approvalSignatures Array of signatures that correspond to the feeRecipients of each
|
|
||||||
/// order in the transaction's Exchange calldata.
|
|
||||||
function assertValidCoordinatorApprovals(
|
|
||||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
|
||||||
address txOrigin,
|
|
||||||
bytes memory transactionSignature,
|
|
||||||
bytes[] memory approvalSignatures
|
|
||||||
)
|
|
||||||
public
|
|
||||||
view
|
|
||||||
{
|
|
||||||
// Get the orders from the the Exchange calldata in the 0x transaction
|
|
||||||
LibOrder.Order[] memory orders = decodeOrdersFromFillData(transaction.data);
|
|
||||||
|
|
||||||
// No approval is required for non-fill methods
|
|
||||||
if (orders.length > 0) {
|
|
||||||
// Revert if approval is invalid for transaction orders
|
|
||||||
_assertValidTransactionOrdersApproval(
|
|
||||||
transaction,
|
|
||||||
orders,
|
|
||||||
txOrigin,
|
|
||||||
transactionSignature,
|
|
||||||
approvalSignatures
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Decodes the orders from Exchange calldata representing any fill method.
|
|
||||||
/// @param data Exchange calldata representing a fill method.
|
|
||||||
/// @return orders The orders from the Exchange calldata.
|
|
||||||
function decodeOrdersFromFillData(bytes memory data)
|
|
||||||
public
|
|
||||||
pure
|
|
||||||
returns (LibOrder.Order[] memory orders)
|
|
||||||
{
|
|
||||||
bytes4 selector = data.readBytes4(0);
|
|
||||||
if (
|
|
||||||
selector == IExchange(address(0)).fillOrder.selector ||
|
|
||||||
selector == IExchange(address(0)).fillOrKillOrder.selector
|
|
||||||
) {
|
|
||||||
// Decode single order
|
|
||||||
(LibOrder.Order memory order) = abi.decode(
|
|
||||||
data.slice(4, data.length),
|
|
||||||
(LibOrder.Order)
|
|
||||||
);
|
|
||||||
orders = new LibOrder.Order[](1);
|
|
||||||
orders[0] = order;
|
|
||||||
} else if (
|
|
||||||
selector == IExchange(address(0)).batchFillOrders.selector ||
|
|
||||||
selector == IExchange(address(0)).batchFillOrdersNoThrow.selector ||
|
|
||||||
selector == IExchange(address(0)).batchFillOrKillOrders.selector ||
|
|
||||||
selector == IExchange(address(0)).marketBuyOrdersNoThrow.selector ||
|
|
||||||
selector == IExchange(address(0)).marketBuyOrdersFillOrKill.selector ||
|
|
||||||
selector == IExchange(address(0)).marketSellOrdersNoThrow.selector ||
|
|
||||||
selector == IExchange(address(0)).marketSellOrdersFillOrKill.selector
|
|
||||||
) {
|
|
||||||
// Decode all orders
|
|
||||||
// solhint-disable indent
|
|
||||||
(orders) = abi.decode(
|
|
||||||
data.slice(4, data.length),
|
|
||||||
(LibOrder.Order[])
|
|
||||||
);
|
|
||||||
} else if (
|
|
||||||
selector == IExchange(address(0)).matchOrders.selector ||
|
|
||||||
selector == IExchange(address(0)).matchOrdersWithMaximalFill.selector
|
|
||||||
) {
|
|
||||||
// Decode left and right orders
|
|
||||||
(LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder) = abi.decode(
|
|
||||||
data.slice(4, data.length),
|
|
||||||
(LibOrder.Order, LibOrder.Order)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Create array of orders
|
|
||||||
orders = new LibOrder.Order[](2);
|
|
||||||
orders[0] = leftOrder;
|
|
||||||
orders[1] = rightOrder;
|
|
||||||
}
|
|
||||||
return orders;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Validates that the feeRecipients of a batch of order have approved a 0x transaction.
|
|
||||||
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
|
||||||
/// @param orders Array of order structs containing order specifications.
|
|
||||||
/// @param txOrigin Required signer of Ethereum transaction calling this function.
|
|
||||||
/// @param transactionSignature Proof that the transaction has been signed by the signer.
|
|
||||||
/// @param approvalSignatures Array of signatures that correspond to the feeRecipients of each order.
|
|
||||||
function _assertValidTransactionOrdersApproval(
|
|
||||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
|
||||||
LibOrder.Order[] memory orders,
|
|
||||||
address txOrigin,
|
|
||||||
bytes memory transactionSignature,
|
|
||||||
bytes[] memory approvalSignatures
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
view
|
|
||||||
{
|
|
||||||
// Verify that Ethereum tx signer is the same as the approved txOrigin
|
|
||||||
if (tx.origin != txOrigin) {
|
|
||||||
LibRichErrors.rrevert(LibCoordinatorRichErrors.InvalidOriginError(txOrigin));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hash 0x transaction
|
|
||||||
bytes32 transactionHash = LibZeroExTransaction.getTypedDataHash(transaction, EIP712_EXCHANGE_DOMAIN_HASH);
|
|
||||||
|
|
||||||
// Create empty list of approval signers
|
|
||||||
address[] memory approvalSignerAddresses = new address[](0);
|
|
||||||
|
|
||||||
uint256 signaturesLength = approvalSignatures.length;
|
|
||||||
for (uint256 i = 0; i != signaturesLength; i++) {
|
|
||||||
// Create approval message
|
|
||||||
CoordinatorApproval memory approval = CoordinatorApproval({
|
|
||||||
txOrigin: txOrigin,
|
|
||||||
transactionHash: transactionHash,
|
|
||||||
transactionSignature: transactionSignature
|
|
||||||
});
|
|
||||||
|
|
||||||
// Hash approval message and recover signer address
|
|
||||||
bytes32 approvalHash = getCoordinatorApprovalHash(approval);
|
|
||||||
address approvalSignerAddress = getSignerAddress(approvalHash, approvalSignatures[i]);
|
|
||||||
|
|
||||||
// Add approval signer to list of signers
|
|
||||||
approvalSignerAddresses = approvalSignerAddresses.append(approvalSignerAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ethereum transaction signer gives implicit signature of approval
|
|
||||||
approvalSignerAddresses = approvalSignerAddresses.append(tx.origin);
|
|
||||||
|
|
||||||
uint256 ordersLength = orders.length;
|
|
||||||
for (uint256 i = 0; i != ordersLength; i++) {
|
|
||||||
// Do not check approval if the order's senderAddress is null
|
|
||||||
if (orders[i].senderAddress == address(0)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure feeRecipient of order has approved this 0x transaction
|
|
||||||
address approverAddress = orders[i].feeRecipientAddress;
|
|
||||||
bool isOrderApproved = approvalSignerAddresses.contains(approverAddress);
|
|
||||||
if (!isOrderApproved) {
|
|
||||||
LibRichErrors.rrevert(LibCoordinatorRichErrors.InvalidApprovalSignatureError(
|
|
||||||
transactionHash,
|
|
||||||
approverAddress
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
|
||||||
import "@0x/contracts-utils/contracts/src/Refundable.sol";
|
|
||||||
import "./libs/LibConstants.sol";
|
|
||||||
import "./interfaces/ICoordinatorCore.sol";
|
|
||||||
import "./interfaces/ICoordinatorApprovalVerifier.sol";
|
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable no-empty-blocks
|
|
||||||
contract MixinCoordinatorCore is
|
|
||||||
Refundable,
|
|
||||||
LibConstants,
|
|
||||||
ICoordinatorApprovalVerifier,
|
|
||||||
ICoordinatorCore
|
|
||||||
{
|
|
||||||
|
|
||||||
/// @dev A payable fallback function that makes this contract "payable". This is necessary to allow
|
|
||||||
/// this contract to gracefully handle refunds from the Exchange.
|
|
||||||
function ()
|
|
||||||
external
|
|
||||||
payable
|
|
||||||
{}
|
|
||||||
|
|
||||||
/// @dev Executes a 0x transaction that has been signed by the feeRecipients that correspond to
|
|
||||||
/// each order in the transaction's Exchange calldata.
|
|
||||||
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
|
||||||
/// @param txOrigin Required signer of Ethereum transaction calling this function.
|
|
||||||
/// @param transactionSignature Proof that the transaction has been signed by the signer.
|
|
||||||
/// @param approvalSignatures Array of signatures that correspond to the feeRecipients of each
|
|
||||||
/// order in the transaction's Exchange calldata.
|
|
||||||
function executeTransaction(
|
|
||||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
|
||||||
address txOrigin,
|
|
||||||
bytes memory transactionSignature,
|
|
||||||
bytes[] memory approvalSignatures
|
|
||||||
)
|
|
||||||
public
|
|
||||||
payable
|
|
||||||
refundFinalBalance
|
|
||||||
{
|
|
||||||
// Validate that the 0x transaction has been approves by each feeRecipient
|
|
||||||
assertValidCoordinatorApprovals(
|
|
||||||
transaction,
|
|
||||||
txOrigin,
|
|
||||||
transactionSignature,
|
|
||||||
approvalSignatures
|
|
||||||
);
|
|
||||||
|
|
||||||
// Execute the transaction
|
|
||||||
EXCHANGE.executeTransaction.value(msg.value)(transaction, transactionSignature);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
|
||||||
import "./interfaces/ICoordinatorSignatureValidator.sol";
|
|
||||||
import "./libs/LibCoordinatorRichErrors.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MixinSignatureValidator is
|
|
||||||
ICoordinatorSignatureValidator
|
|
||||||
{
|
|
||||||
using LibBytes for bytes;
|
|
||||||
|
|
||||||
/// @dev Recovers the address of a signer given a hash and signature.
|
|
||||||
/// @param hash Any 32 byte hash.
|
|
||||||
/// @param signature Proof that the hash has been signed by signer.
|
|
||||||
/// @return signerAddress Address of the signer.
|
|
||||||
function getSignerAddress(bytes32 hash, bytes memory signature)
|
|
||||||
public
|
|
||||||
pure
|
|
||||||
returns (address signerAddress)
|
|
||||||
{
|
|
||||||
uint256 signatureLength = signature.length;
|
|
||||||
if (signatureLength == 0) {
|
|
||||||
LibRichErrors.rrevert(LibCoordinatorRichErrors.SignatureError(
|
|
||||||
LibCoordinatorRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
|
||||||
hash,
|
|
||||||
signature
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pop last byte off of signature byte array.
|
|
||||||
uint8 signatureTypeRaw = uint8(signature[signature.length - 1]);
|
|
||||||
|
|
||||||
// Ensure signature is supported
|
|
||||||
if (signatureTypeRaw >= uint8(SignatureType.NSignatureTypes)) {
|
|
||||||
LibRichErrors.rrevert(LibCoordinatorRichErrors.SignatureError(
|
|
||||||
LibCoordinatorRichErrors.SignatureErrorCodes.UNSUPPORTED,
|
|
||||||
hash,
|
|
||||||
signature
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
SignatureType signatureType = SignatureType(signatureTypeRaw);
|
|
||||||
|
|
||||||
// Always illegal signature.
|
|
||||||
// This is always an implicit option since a signer can create a
|
|
||||||
// signature array with invalid type or length. We may as well make
|
|
||||||
// it an explicit option. This aids testing and analysis. It is
|
|
||||||
// also the initialization value for the enum type.
|
|
||||||
if (signatureType == SignatureType.Illegal) {
|
|
||||||
LibRichErrors.rrevert(LibCoordinatorRichErrors.SignatureError(
|
|
||||||
LibCoordinatorRichErrors.SignatureErrorCodes.ILLEGAL,
|
|
||||||
hash,
|
|
||||||
signature
|
|
||||||
));
|
|
||||||
|
|
||||||
// Always invalid signature.
|
|
||||||
// Like Illegal, this is always implicitly available and therefore
|
|
||||||
// offered explicitly. It can be implicitly created by providing
|
|
||||||
// a correctly formatted but incorrect signature.
|
|
||||||
} else if (signatureType == SignatureType.Invalid) {
|
|
||||||
LibRichErrors.rrevert(LibCoordinatorRichErrors.SignatureError(
|
|
||||||
LibCoordinatorRichErrors.SignatureErrorCodes.INVALID,
|
|
||||||
hash,
|
|
||||||
signature
|
|
||||||
));
|
|
||||||
|
|
||||||
// Signature using EIP712
|
|
||||||
} else if (signatureType == SignatureType.EIP712) {
|
|
||||||
if (signatureLength != 66) {
|
|
||||||
LibRichErrors.rrevert(LibCoordinatorRichErrors.SignatureError(
|
|
||||||
LibCoordinatorRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
|
||||||
hash,
|
|
||||||
signature
|
|
||||||
));
|
|
||||||
}
|
|
||||||
uint8 v = uint8(signature[0]);
|
|
||||||
bytes32 r = signature.readBytes32(1);
|
|
||||||
bytes32 s = signature.readBytes32(33);
|
|
||||||
signerAddress = ecrecover(
|
|
||||||
hash,
|
|
||||||
v,
|
|
||||||
r,
|
|
||||||
s
|
|
||||||
);
|
|
||||||
return signerAddress;
|
|
||||||
|
|
||||||
// Signed using web3.eth_sign
|
|
||||||
} else if (signatureType == SignatureType.EthSign) {
|
|
||||||
if (signatureLength != 66) {
|
|
||||||
LibRichErrors.rrevert(LibCoordinatorRichErrors.SignatureError(
|
|
||||||
LibCoordinatorRichErrors.SignatureErrorCodes.INVALID_LENGTH,
|
|
||||||
hash,
|
|
||||||
signature
|
|
||||||
));
|
|
||||||
}
|
|
||||||
uint8 v = uint8(signature[0]);
|
|
||||||
bytes32 r = signature.readBytes32(1);
|
|
||||||
bytes32 s = signature.readBytes32(33);
|
|
||||||
signerAddress = ecrecover(
|
|
||||||
keccak256(abi.encodePacked(
|
|
||||||
"\x19Ethereum Signed Message:\n32",
|
|
||||||
hash
|
|
||||||
)),
|
|
||||||
v,
|
|
||||||
r,
|
|
||||||
s
|
|
||||||
);
|
|
||||||
return signerAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Anything else is illegal (We do not return false because
|
|
||||||
// the signature may actually be valid, just not in a format
|
|
||||||
// that we currently support. In this case returning false
|
|
||||||
// may lead the caller to incorrectly believe that the
|
|
||||||
// signature was invalid.)
|
|
||||||
LibRichErrors.rrevert(LibCoordinatorRichErrors.SignatureError(
|
|
||||||
LibCoordinatorRichErrors.SignatureErrorCodes.UNSUPPORTED,
|
|
||||||
hash,
|
|
||||||
signature
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract ICoordinatorApprovalVerifier {
|
|
||||||
|
|
||||||
/// @dev Validates that the 0x transaction has been approved by all of the feeRecipients
|
|
||||||
/// that correspond to each order in the transaction's Exchange calldata.
|
|
||||||
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
|
||||||
/// @param txOrigin Required signer of Ethereum transaction calling this function.
|
|
||||||
/// @param transactionSignature Proof that the transaction has been signed by the signer.
|
|
||||||
/// @param approvalSignatures Array of signatures that correspond to the feeRecipients of each
|
|
||||||
/// order in the transaction's Exchange calldata.
|
|
||||||
function assertValidCoordinatorApprovals(
|
|
||||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
|
||||||
address txOrigin,
|
|
||||||
bytes memory transactionSignature,
|
|
||||||
bytes[] memory approvalSignatures
|
|
||||||
)
|
|
||||||
public
|
|
||||||
view;
|
|
||||||
|
|
||||||
/// @dev Decodes the orders from Exchange calldata representing any fill method.
|
|
||||||
/// @param data Exchange calldata representing a fill method.
|
|
||||||
/// @return orders The orders from the Exchange calldata.
|
|
||||||
function decodeOrdersFromFillData(bytes memory data)
|
|
||||||
public
|
|
||||||
pure
|
|
||||||
returns (LibOrder.Order[] memory orders);
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract ICoordinatorCore {
|
|
||||||
|
|
||||||
/// @dev Executes a 0x transaction that has been signed by the feeRecipients that correspond to
|
|
||||||
/// each order in the transaction's Exchange calldata.
|
|
||||||
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
|
||||||
/// @param txOrigin Required signer of Ethereum transaction calling this function.
|
|
||||||
/// @param transactionSignature Proof that the transaction has been signed by the signer.
|
|
||||||
/// @param approvalSignatures Array of signatures that correspond to the feeRecipients of each
|
|
||||||
/// order in the transaction's Exchange calldata.
|
|
||||||
function executeTransaction(
|
|
||||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
|
||||||
address txOrigin,
|
|
||||||
bytes memory transactionSignature,
|
|
||||||
bytes[] memory approvalSignatures
|
|
||||||
)
|
|
||||||
public
|
|
||||||
payable;
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
|
|
||||||
contract ICoordinatorSignatureValidator {
|
|
||||||
|
|
||||||
// Allowed signature types.
|
|
||||||
enum SignatureType {
|
|
||||||
Illegal, // 0x00, default value
|
|
||||||
Invalid, // 0x01
|
|
||||||
EIP712, // 0x02
|
|
||||||
EthSign, // 0x03
|
|
||||||
Wallet, // 0x04
|
|
||||||
Validator, // 0x05
|
|
||||||
PreSigned, // 0x06
|
|
||||||
EIP1271Wallet, // 0x07
|
|
||||||
NSignatureTypes // 0x08, number of signature types. Always leave at end.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Recovers the address of a signer given a hash and signature.
|
|
||||||
/// @param hash Any 32 byte hash.
|
|
||||||
/// @param signature Proof that the hash has been signed by signer.
|
|
||||||
/// @return signerAddress Address of the signer.
|
|
||||||
function getSignerAddress(bytes32 hash, bytes memory signature)
|
|
||||||
public
|
|
||||||
pure
|
|
||||||
returns (address signerAddress);
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "./LibEIP712CoordinatorDomain.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract LibCoordinatorApproval is
|
|
||||||
LibEIP712CoordinatorDomain
|
|
||||||
{
|
|
||||||
// Hash for the EIP712 Coordinator approval message
|
|
||||||
// keccak256(abi.encodePacked(
|
|
||||||
// "CoordinatorApproval(",
|
|
||||||
// "address txOrigin,",
|
|
||||||
// "bytes32 transactionHash,",
|
|
||||||
// "bytes transactionSignature",
|
|
||||||
// ")"
|
|
||||||
// ));
|
|
||||||
bytes32 constant public EIP712_COORDINATOR_APPROVAL_SCHEMA_HASH =
|
|
||||||
0xa6511c04ca44625d50986f8c36bedc09366207a17b96e347094053a9f8507168;
|
|
||||||
|
|
||||||
struct CoordinatorApproval {
|
|
||||||
address txOrigin; // Required signer of Ethereum transaction that is submitting approval.
|
|
||||||
bytes32 transactionHash; // EIP712 hash of the transaction.
|
|
||||||
bytes transactionSignature; // Signature of the 0x transaction.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Calculates the EIP712 hash of the Coordinator approval mesasage using the domain
|
|
||||||
/// separator of this contract.
|
|
||||||
/// @param approval Coordinator approval message containing the transaction hash, and transaction
|
|
||||||
/// signature.
|
|
||||||
/// @return approvalHash EIP712 hash of the Coordinator approval message with the domain
|
|
||||||
/// separator of this contract.
|
|
||||||
function getCoordinatorApprovalHash(CoordinatorApproval memory approval)
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (bytes32 approvalHash)
|
|
||||||
{
|
|
||||||
approvalHash = _hashEIP712CoordinatorMessage(_hashCoordinatorApproval(approval));
|
|
||||||
return approvalHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Calculates the EIP712 hash of the Coordinator approval mesasage with no domain separator.
|
|
||||||
/// @param approval Coordinator approval message containing the transaction hash, and transaction
|
|
||||||
// signature.
|
|
||||||
/// @return result EIP712 hash of the Coordinator approval message with no domain separator.
|
|
||||||
function _hashCoordinatorApproval(CoordinatorApproval memory approval)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes32 result)
|
|
||||||
{
|
|
||||||
bytes32 schemaHash = EIP712_COORDINATOR_APPROVAL_SCHEMA_HASH;
|
|
||||||
bytes memory transactionSignature = approval.transactionSignature;
|
|
||||||
address txOrigin = approval.txOrigin;
|
|
||||||
bytes32 transactionHash = approval.transactionHash;
|
|
||||||
|
|
||||||
// Assembly for more efficiently computing:
|
|
||||||
// keccak256(abi.encodePacked(
|
|
||||||
// EIP712_COORDINATOR_APPROVAL_SCHEMA_HASH,
|
|
||||||
// approval.txOrigin,
|
|
||||||
// approval.transactionHash,
|
|
||||||
// keccak256(approval.transactionSignature)
|
|
||||||
// ));
|
|
||||||
|
|
||||||
assembly {
|
|
||||||
// Compute hash of transaction signature
|
|
||||||
let transactionSignatureHash := keccak256(add(transactionSignature, 32), mload(transactionSignature))
|
|
||||||
|
|
||||||
// Load free memory pointer
|
|
||||||
let memPtr := mload(64)
|
|
||||||
|
|
||||||
mstore(memPtr, schemaHash) // hash of schema
|
|
||||||
mstore(add(memPtr, 32), txOrigin) // txOrigin
|
|
||||||
mstore(add(memPtr, 64), transactionHash) // transactionHash
|
|
||||||
mstore(add(memPtr, 96), transactionSignatureHash) // transactionSignatureHash
|
|
||||||
// Compute hash
|
|
||||||
result := keccak256(memPtr, 128)
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
|
|
||||||
library LibCoordinatorRichErrors {
|
|
||||||
enum SignatureErrorCodes {
|
|
||||||
INVALID_LENGTH,
|
|
||||||
UNSUPPORTED,
|
|
||||||
ILLEGAL,
|
|
||||||
INVALID
|
|
||||||
}
|
|
||||||
|
|
||||||
// bytes4(keccak256("SignatureError(uint8,bytes32,bytes)"))
|
|
||||||
bytes4 internal constant SIGNATURE_ERROR_SELECTOR =
|
|
||||||
0x779c5223;
|
|
||||||
|
|
||||||
// bytes4(keccak256("InvalidOriginError(address)"))
|
|
||||||
bytes4 internal constant INVALID_ORIGIN_ERROR_SELECTOR =
|
|
||||||
0xa458d7ff;
|
|
||||||
|
|
||||||
// bytes4(keccak256("InvalidApprovalSignatureError(bytes32,address)"))
|
|
||||||
bytes4 internal constant INVALID_APPROVAL_SIGNATURE_ERROR_SELECTOR =
|
|
||||||
0xd789b640;
|
|
||||||
|
|
||||||
// solhint-disable func-name-mixedcase
|
|
||||||
function SignatureError(
|
|
||||||
SignatureErrorCodes errorCode,
|
|
||||||
bytes32 hash,
|
|
||||||
bytes memory signature
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory)
|
|
||||||
{
|
|
||||||
return abi.encodeWithSelector(
|
|
||||||
SIGNATURE_ERROR_SELECTOR,
|
|
||||||
errorCode,
|
|
||||||
hash,
|
|
||||||
signature
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function InvalidOriginError(
|
|
||||||
address expectedOrigin
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory)
|
|
||||||
{
|
|
||||||
return abi.encodeWithSelector(
|
|
||||||
INVALID_ORIGIN_ERROR_SELECTOR,
|
|
||||||
expectedOrigin
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function InvalidApprovalSignatureError(
|
|
||||||
bytes32 transactionHash,
|
|
||||||
address approverAddress
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory)
|
|
||||||
{
|
|
||||||
return abi.encodeWithSelector(
|
|
||||||
INVALID_APPROVAL_SIGNATURE_ERROR_SELECTOR,
|
|
||||||
transactionHash,
|
|
||||||
approverAddress
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibEIP712.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract LibEIP712CoordinatorDomain {
|
|
||||||
|
|
||||||
// EIP712 Domain Name value for the Coordinator
|
|
||||||
string constant public EIP712_COORDINATOR_DOMAIN_NAME = "0x Protocol Coordinator";
|
|
||||||
|
|
||||||
// EIP712 Domain Version value for the Coordinator
|
|
||||||
string constant public EIP712_COORDINATOR_DOMAIN_VERSION = "3.0.0";
|
|
||||||
|
|
||||||
// Hash of the EIP712 Domain Separator data for the Coordinator
|
|
||||||
// solhint-disable-next-line var-name-mixedcase
|
|
||||||
bytes32 public EIP712_COORDINATOR_DOMAIN_HASH;
|
|
||||||
|
|
||||||
/// @param chainId Chain ID of the network this contract is deployed on.
|
|
||||||
/// @param verifyingContractAddressIfExists Address of the verifying contract (null if the address of this contract)
|
|
||||||
constructor (
|
|
||||||
uint256 chainId,
|
|
||||||
address verifyingContractAddressIfExists
|
|
||||||
)
|
|
||||||
public
|
|
||||||
{
|
|
||||||
address verifyingContractAddress = verifyingContractAddressIfExists == address(0)
|
|
||||||
? address(this)
|
|
||||||
: verifyingContractAddressIfExists;
|
|
||||||
EIP712_COORDINATOR_DOMAIN_HASH = LibEIP712.hashEIP712Domain(
|
|
||||||
EIP712_COORDINATOR_DOMAIN_NAME,
|
|
||||||
EIP712_COORDINATOR_DOMAIN_VERSION,
|
|
||||||
chainId,
|
|
||||||
verifyingContractAddress
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Calculates EIP712 encoding for a hash struct in the EIP712 domain
|
|
||||||
/// of this contract.
|
|
||||||
/// @param hashStruct The EIP712 hash struct.
|
|
||||||
/// @return result EIP712 hash applied to this EIP712 Domain.
|
|
||||||
function _hashEIP712CoordinatorMessage(bytes32 hashStruct)
|
|
||||||
internal
|
|
||||||
view
|
|
||||||
returns (bytes32 result)
|
|
||||||
{
|
|
||||||
return LibEIP712.hashEIP712Message(EIP712_COORDINATOR_DOMAIN_HASH, hashStruct);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "./interfaces/ICoordinatorRegistryCore.sol";
|
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable no-empty-blocks
|
|
||||||
contract MixinCoordinatorRegistryCore is
|
|
||||||
ICoordinatorRegistryCore
|
|
||||||
{
|
|
||||||
// mapping from `coordinatorOperator` -> `coordinatorEndpoint`
|
|
||||||
mapping (address => string) internal coordinatorEndpoints;
|
|
||||||
|
|
||||||
/// @dev Called by a Coordinator operator to set the endpoint of their Coordinator.
|
|
||||||
/// @param coordinatorEndpoint Endpoint of the Coordinator as a string.
|
|
||||||
function setCoordinatorEndpoint(string calldata coordinatorEndpoint) external {
|
|
||||||
address coordinatorOperator = msg.sender;
|
|
||||||
coordinatorEndpoints[coordinatorOperator] = coordinatorEndpoint;
|
|
||||||
emit CoordinatorEndpointSet(coordinatorOperator, coordinatorEndpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Gets the endpoint for a Coordinator.
|
|
||||||
/// @param coordinatorOperator Operator of the Coordinator endpoint.
|
|
||||||
/// @return coordinatorEndpoint Endpoint of the Coordinator as a string.
|
|
||||||
function getCoordinatorEndpoint(address coordinatorOperator)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (string memory coordinatorEndpoint)
|
|
||||||
{
|
|
||||||
return coordinatorEndpoints[coordinatorOperator];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable no-empty-blocks
|
|
||||||
contract ICoordinatorRegistryCore
|
|
||||||
{
|
|
||||||
/// @dev Emitted when a Coordinator endpoint is set.
|
|
||||||
event CoordinatorEndpointSet(
|
|
||||||
address coordinatorOperator,
|
|
||||||
string coordinatorEndpoint
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @dev Called by a Coordinator operator to set the endpoint of their Coordinator.
|
|
||||||
/// @param coordinatorEndpoint Endpoint of the Coordinator as a string.
|
|
||||||
function setCoordinatorEndpoint(string calldata coordinatorEndpoint) external;
|
|
||||||
|
|
||||||
/// @dev Gets the endpoint for a Coordinator.
|
|
||||||
/// @param coordinatorOperator Operator of the Coordinator endpoint.
|
|
||||||
/// @return coordinatorEndpoint Endpoint of the Coordinator as a string.
|
|
||||||
function getCoordinatorEndpoint(address coordinatorOperator)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (string memory coordinatorEndpoint);
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@0x/contracts-coordinator",
|
|
||||||
"version": "2.1.0-beta.3",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6.12"
|
|
||||||
},
|
|
||||||
"description": "Smart contract extensions of 0x protocol",
|
|
||||||
"main": "lib/src/index.js",
|
|
||||||
"directories": {
|
|
||||||
"test": "test"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"build": "yarn pre_build && tsc -b",
|
|
||||||
"build:ci": "yarn build",
|
|
||||||
"pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy",
|
|
||||||
"test": "yarn run_mocha",
|
|
||||||
"rebuild_and_test": "run-s build test",
|
|
||||||
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
|
|
||||||
"test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html",
|
|
||||||
"test:trace": "SOLIDITY_REVERT_TRACE=true run-s build run_mocha",
|
|
||||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit",
|
|
||||||
"compile": "sol-compiler",
|
|
||||||
"watch": "sol-compiler -w",
|
|
||||||
"clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers",
|
|
||||||
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers",
|
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
|
||||||
"coverage:report:text": "istanbul report text",
|
|
||||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
|
||||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
|
||||||
"coverage:report:lcov": "istanbul report lcov",
|
|
||||||
"test:circleci": "yarn test",
|
|
||||||
"contracts:gen": "contracts-gen generate",
|
|
||||||
"contracts:copy": "contracts-gen copy",
|
|
||||||
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol",
|
|
||||||
"compile:truffle": "truffle compile",
|
|
||||||
"docs:md": "ts-doc-gen --sourceDir='$PROJECT_FILES' --output=$MD_FILE_DIR --fileExtension=mdx --tsconfig=./typedoc-tsconfig.json",
|
|
||||||
"docs:json": "typedoc --excludePrivate --excludeExternals --excludeProtected --ignoreCompilerErrors --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"publicInterfaceContracts": "Coordinator,CoordinatorRegistry,LibCoordinatorApproval,LibCoordinatorRichErrors,LibEIP712CoordinatorDomain,LibConstants",
|
|
||||||
"abis": "./test/generated-artifacts/@(Coordinator|CoordinatorRegistry|ICoordinatorApprovalVerifier|ICoordinatorCore|ICoordinatorRegistryCore|ICoordinatorSignatureValidator|LibConstants|LibCoordinatorApproval|LibCoordinatorRichErrors|LibEIP712CoordinatorDomain|MixinCoordinatorApprovalVerifier|MixinCoordinatorCore|MixinCoordinatorRegistryCore|MixinSignatureValidator).json",
|
|
||||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/0xProject/0x-monorepo.git"
|
|
||||||
},
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/0xProject/0x-monorepo/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
|
|
||||||
"devDependencies": {
|
|
||||||
"@0x/abi-gen": "^4.4.0-beta.3",
|
|
||||||
"@0x/contracts-asset-proxy": "^2.3.0-beta.3",
|
|
||||||
"@0x/contracts-dev-utils": "^0.1.0-beta.3",
|
|
||||||
"@0x/contracts-erc20": "^2.3.0-beta.3",
|
|
||||||
"@0x/contracts-exchange": "^2.2.0-beta.3",
|
|
||||||
"@0x/contracts-gen": "^1.1.0-beta.3",
|
|
||||||
"@0x/contracts-test-utils": "^3.2.0-beta.3",
|
|
||||||
"@0x/dev-utils": "^2.4.0-beta.3",
|
|
||||||
"@0x/order-utils": "^8.5.0-beta.3",
|
|
||||||
"@0x/sol-compiler": "^3.2.0-beta.3",
|
|
||||||
"@0x/ts-doc-gen": "^0.0.22",
|
|
||||||
"@0x/tslint-config": "^3.1.0-beta.2",
|
|
||||||
"@0x/web3-wrapper": "^6.1.0-beta.2",
|
|
||||||
"@types/lodash": "4.14.104",
|
|
||||||
"@types/mocha": "^5.2.7",
|
|
||||||
"@types/node": "*",
|
|
||||||
"chai": "^4.0.1",
|
|
||||||
"chai-as-promised": "^7.1.0",
|
|
||||||
"chai-bignumber": "^3.0.0",
|
|
||||||
"dirty-chai": "^2.0.1",
|
|
||||||
"lodash": "^4.17.11",
|
|
||||||
"make-promises-safe": "^1.1.0",
|
|
||||||
"mocha": "^6.2.0",
|
|
||||||
"npm-run-all": "^4.1.2",
|
|
||||||
"shx": "^0.2.2",
|
|
||||||
"solhint": "^1.4.1",
|
|
||||||
"truffle": "^5.0.32",
|
|
||||||
"tslint": "5.11.0",
|
|
||||||
"typedoc": "^0.15.0",
|
|
||||||
"typescript": "3.0.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@0x/base-contract": "^5.5.0-beta.3",
|
|
||||||
"@0x/contracts-utils": "^3.3.0-beta.3",
|
|
||||||
"@0x/types": "^2.5.0-beta.2",
|
|
||||||
"@0x/typescript-typings": "^4.4.0-beta.2",
|
|
||||||
"@0x/utils": "^4.6.0-beta.2",
|
|
||||||
"ethereum-types": "^2.2.0-beta.2"
|
|
||||||
},
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
import { hexConcat, signingUtils } from '@0x/contracts-test-utils';
|
|
||||||
import { SignatureType, SignedZeroExTransaction } from '@0x/types';
|
|
||||||
|
|
||||||
import { hashUtils } from './hash_utils';
|
|
||||||
import { SignedCoordinatorApproval } from './types';
|
|
||||||
|
|
||||||
export class ApprovalFactory {
|
|
||||||
private readonly _privateKey: Buffer;
|
|
||||||
private readonly _verifyingContractAddress: string;
|
|
||||||
|
|
||||||
constructor(privateKey: Buffer, verifyingContract: string) {
|
|
||||||
this._privateKey = privateKey;
|
|
||||||
this._verifyingContractAddress = verifyingContract;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async newSignedApprovalAsync(
|
|
||||||
transaction: SignedZeroExTransaction,
|
|
||||||
txOrigin: string,
|
|
||||||
signatureType: SignatureType = SignatureType.EthSign,
|
|
||||||
): Promise<SignedCoordinatorApproval> {
|
|
||||||
const approvalHashBuff = await hashUtils.getApprovalHashBufferAsync(
|
|
||||||
transaction,
|
|
||||||
this._verifyingContractAddress,
|
|
||||||
txOrigin,
|
|
||||||
);
|
|
||||||
const signatureBuff = signingUtils.signMessage(approvalHashBuff, this._privateKey, signatureType);
|
|
||||||
const signedApproval = {
|
|
||||||
txOrigin,
|
|
||||||
transaction,
|
|
||||||
signature: hexConcat(signatureBuff),
|
|
||||||
};
|
|
||||||
return signedApproval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
import { ContractArtifact } from 'ethereum-types';
|
|
||||||
|
|
||||||
import * as Coordinator from '../generated-artifacts/Coordinator.json';
|
|
||||||
import * as CoordinatorRegistry from '../generated-artifacts/CoordinatorRegistry.json';
|
|
||||||
import * as LibConstants from '../generated-artifacts/LibConstants.json';
|
|
||||||
import * as LibCoordinatorApproval from '../generated-artifacts/LibCoordinatorApproval.json';
|
|
||||||
import * as LibCoordinatorRichErrors from '../generated-artifacts/LibCoordinatorRichErrors.json';
|
|
||||||
import * as LibEIP712CoordinatorDomain from '../generated-artifacts/LibEIP712CoordinatorDomain.json';
|
|
||||||
export const artifacts = {
|
|
||||||
Coordinator: Coordinator as ContractArtifact,
|
|
||||||
CoordinatorRegistry: CoordinatorRegistry as ContractArtifact,
|
|
||||||
LibCoordinatorApproval: LibCoordinatorApproval as ContractArtifact,
|
|
||||||
LibCoordinatorRichErrors: LibCoordinatorRichErrors as ContractArtifact,
|
|
||||||
LibEIP712CoordinatorDomain: LibEIP712CoordinatorDomain as ContractArtifact,
|
|
||||||
LibConstants: LibConstants as ContractArtifact,
|
|
||||||
};
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
import { hexConcat } from '@0x/contracts-test-utils';
|
|
||||||
import { eip712Utils } from '@0x/order-utils';
|
|
||||||
import { SignedZeroExTransaction } from '@0x/types';
|
|
||||||
import { signTypedDataUtils } from '@0x/utils';
|
|
||||||
|
|
||||||
export const hashUtils = {
|
|
||||||
async getApprovalHashBufferAsync(
|
|
||||||
transaction: SignedZeroExTransaction,
|
|
||||||
verifyingContract: string,
|
|
||||||
txOrigin: string,
|
|
||||||
): Promise<Buffer> {
|
|
||||||
const typedData = await eip712Utils.createCoordinatorApprovalTypedDataAsync(
|
|
||||||
transaction,
|
|
||||||
verifyingContract,
|
|
||||||
txOrigin,
|
|
||||||
);
|
|
||||||
const hashBuffer = signTypedDataUtils.generateTypedDataHash(typedData);
|
|
||||||
return hashBuffer;
|
|
||||||
},
|
|
||||||
async getApprovalHashHexAsync(
|
|
||||||
transaction: SignedZeroExTransaction,
|
|
||||||
verifyingContract: string,
|
|
||||||
txOrigin: string,
|
|
||||||
): Promise<string> {
|
|
||||||
const hashHex = hexConcat(await hashUtils.getApprovalHashBufferAsync(transaction, verifyingContract, txOrigin));
|
|
||||||
return hashHex;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
export { artifacts } from './artifacts';
|
|
||||||
export {
|
|
||||||
CoordinatorContract,
|
|
||||||
CoordinatorRegistryContract,
|
|
||||||
LibConstantsContract,
|
|
||||||
LibCoordinatorApprovalContract,
|
|
||||||
LibCoordinatorRichErrorsContract,
|
|
||||||
LibEIP712CoordinatorDomainContract,
|
|
||||||
} from './wrappers';
|
|
||||||
export import CoordinatorRevertErrors = require('./revert_errors');
|
|
||||||
export { ApprovalFactory } from './approval_factory';
|
|
||||||
export { SignedCoordinatorApproval } from './types';
|
|
||||||
export { SignatureType, SignedZeroExTransaction, EIP712DomainWithDefaultSchema } from '@0x/types';
|
|
||||||
export {
|
|
||||||
ContractArtifact,
|
|
||||||
ContractChains,
|
|
||||||
CompilerOpts,
|
|
||||||
StandardContractOutput,
|
|
||||||
CompilerSettings,
|
|
||||||
ContractChainData,
|
|
||||||
ContractAbi,
|
|
||||||
DevdocOutput,
|
|
||||||
EvmOutput,
|
|
||||||
CompilerSettingsMetadata,
|
|
||||||
OptimizerSettings,
|
|
||||||
OutputField,
|
|
||||||
ParamDescription,
|
|
||||||
EvmBytecodeOutput,
|
|
||||||
AbiDefinition,
|
|
||||||
FunctionAbi,
|
|
||||||
EventAbi,
|
|
||||||
RevertErrorAbi,
|
|
||||||
EventParameter,
|
|
||||||
DataItem,
|
|
||||||
MethodAbi,
|
|
||||||
ConstructorAbi,
|
|
||||||
FallbackAbi,
|
|
||||||
ConstructorStateMutability,
|
|
||||||
TupleDataItem,
|
|
||||||
StateMutability,
|
|
||||||
} from 'ethereum-types';
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
import { BigNumber, RevertError } from '@0x/utils';
|
|
||||||
|
|
||||||
// tslint:disable:max-classes-per-file
|
|
||||||
|
|
||||||
export enum SignatureErrorCodes {
|
|
||||||
InvalidLength,
|
|
||||||
Unsupported,
|
|
||||||
Illegal,
|
|
||||||
Invalid,
|
|
||||||
}
|
|
||||||
|
|
||||||
export class SignatureError extends RevertError {
|
|
||||||
constructor(errorCode?: SignatureErrorCodes, hash?: string, signature?: string) {
|
|
||||||
super('SignatureError', 'SignatureError(uint8 errorCode, bytes32 hash, bytes signature)', {
|
|
||||||
errorCode,
|
|
||||||
hash,
|
|
||||||
signature,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class InvalidOriginError extends RevertError {
|
|
||||||
constructor(expectedOrigin?: string) {
|
|
||||||
super('InvalidOriginError', 'InvalidOriginError(address expectedOrigin)', { expectedOrigin });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ApprovalExpiredError extends RevertError {
|
|
||||||
constructor(transactionHash?: string, approvalExpirationTime?: BigNumber | number | string) {
|
|
||||||
super('ApprovalExpiredError', 'ApprovalExpiredError(bytes32 transactionHash, uint256 approvalExpirationTime)', {
|
|
||||||
transactionHash,
|
|
||||||
approvalExpirationTime,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class InvalidApprovalSignatureError extends RevertError {
|
|
||||||
constructor(transactionHash?: string, approverAddress?: string) {
|
|
||||||
super(
|
|
||||||
'InvalidApprovalSignatureError',
|
|
||||||
'InvalidApprovalSignatureError(bytes32 transactionHash, address approverAddress)',
|
|
||||||
{ transactionHash, approverAddress },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const types = [SignatureError, InvalidOriginError, ApprovalExpiredError, InvalidApprovalSignatureError];
|
|
||||||
|
|
||||||
// Register the types we've defined.
|
|
||||||
for (const type of types) {
|
|
||||||
RevertError.registerType(type);
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { SignedZeroExTransaction } from '@0x/types';
|
|
||||||
|
|
||||||
export interface CoordinatorApproval {
|
|
||||||
transaction: SignedZeroExTransaction;
|
|
||||||
txOrigin: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SignedCoordinatorApproval extends CoordinatorApproval {
|
|
||||||
signature: string;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/*
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
export * from '../generated-wrappers/coordinator';
|
|
||||||
export * from '../generated-wrappers/coordinator_registry';
|
|
||||||
export * from '../generated-wrappers/lib_constants';
|
|
||||||
export * from '../generated-wrappers/lib_coordinator_approval';
|
|
||||||
export * from '../generated-wrappers/lib_coordinator_rich_errors';
|
|
||||||
export * from '../generated-wrappers/lib_e_i_p712_coordinator_domain';
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
import { ContractArtifact } from 'ethereum-types';
|
|
||||||
|
|
||||||
import * as Coordinator from '../test/generated-artifacts/Coordinator.json';
|
|
||||||
import * as CoordinatorRegistry from '../test/generated-artifacts/CoordinatorRegistry.json';
|
|
||||||
import * as ICoordinatorApprovalVerifier from '../test/generated-artifacts/ICoordinatorApprovalVerifier.json';
|
|
||||||
import * as ICoordinatorCore from '../test/generated-artifacts/ICoordinatorCore.json';
|
|
||||||
import * as ICoordinatorRegistryCore from '../test/generated-artifacts/ICoordinatorRegistryCore.json';
|
|
||||||
import * as ICoordinatorSignatureValidator from '../test/generated-artifacts/ICoordinatorSignatureValidator.json';
|
|
||||||
import * as LibConstants from '../test/generated-artifacts/LibConstants.json';
|
|
||||||
import * as LibCoordinatorApproval from '../test/generated-artifacts/LibCoordinatorApproval.json';
|
|
||||||
import * as LibCoordinatorRichErrors from '../test/generated-artifacts/LibCoordinatorRichErrors.json';
|
|
||||||
import * as LibEIP712CoordinatorDomain from '../test/generated-artifacts/LibEIP712CoordinatorDomain.json';
|
|
||||||
import * as MixinCoordinatorApprovalVerifier from '../test/generated-artifacts/MixinCoordinatorApprovalVerifier.json';
|
|
||||||
import * as MixinCoordinatorCore from '../test/generated-artifacts/MixinCoordinatorCore.json';
|
|
||||||
import * as MixinCoordinatorRegistryCore from '../test/generated-artifacts/MixinCoordinatorRegistryCore.json';
|
|
||||||
import * as MixinSignatureValidator from '../test/generated-artifacts/MixinSignatureValidator.json';
|
|
||||||
export const artifacts = {
|
|
||||||
Coordinator: Coordinator as ContractArtifact,
|
|
||||||
MixinCoordinatorApprovalVerifier: MixinCoordinatorApprovalVerifier as ContractArtifact,
|
|
||||||
MixinCoordinatorCore: MixinCoordinatorCore as ContractArtifact,
|
|
||||||
MixinSignatureValidator: MixinSignatureValidator as ContractArtifact,
|
|
||||||
ICoordinatorApprovalVerifier: ICoordinatorApprovalVerifier as ContractArtifact,
|
|
||||||
ICoordinatorCore: ICoordinatorCore as ContractArtifact,
|
|
||||||
ICoordinatorSignatureValidator: ICoordinatorSignatureValidator as ContractArtifact,
|
|
||||||
LibConstants: LibConstants as ContractArtifact,
|
|
||||||
LibCoordinatorApproval: LibCoordinatorApproval as ContractArtifact,
|
|
||||||
LibCoordinatorRichErrors: LibCoordinatorRichErrors as ContractArtifact,
|
|
||||||
LibEIP712CoordinatorDomain: LibEIP712CoordinatorDomain as ContractArtifact,
|
|
||||||
CoordinatorRegistry: CoordinatorRegistry as ContractArtifact,
|
|
||||||
MixinCoordinatorRegistryCore: MixinCoordinatorRegistryCore as ContractArtifact,
|
|
||||||
ICoordinatorRegistryCore: ICoordinatorRegistryCore as ContractArtifact,
|
|
||||||
};
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
import { blockchainTests, expect, verifyEvents } from '@0x/contracts-test-utils';
|
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
|
|
||||||
import { CoordinatorRegistryContract, CoordinatorRegistryCoordinatorEndpointSetEventArgs } from './wrappers';
|
|
||||||
|
|
||||||
// tslint:disable:no-unnecessary-type-assertion
|
|
||||||
blockchainTests.resets('Coordinator Registry tests', env => {
|
|
||||||
let coordinatorRegistry: CoordinatorRegistryContract;
|
|
||||||
let coordinatorOperator: string;
|
|
||||||
const coordinatorEndpoint = 'http://sometec.0x.org';
|
|
||||||
const nilCoordinatorEndpoint = '';
|
|
||||||
// tests
|
|
||||||
before(async () => {
|
|
||||||
// setup accounts (skip owner)
|
|
||||||
const accounts = await env.getAccountAddressesAsync();
|
|
||||||
[, coordinatorOperator] = accounts;
|
|
||||||
// deploy coordinator registry
|
|
||||||
coordinatorRegistry = await CoordinatorRegistryContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.CoordinatorRegistry,
|
|
||||||
env.provider,
|
|
||||||
env.txDefaults,
|
|
||||||
artifacts,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
describe('core', () => {
|
|
||||||
it('Should successfully set a Coordinator endpoint', async () => {
|
|
||||||
await coordinatorRegistry.setCoordinatorEndpoint(coordinatorEndpoint).awaitTransactionSuccessAsync({
|
|
||||||
from: coordinatorOperator,
|
|
||||||
});
|
|
||||||
const recordedCoordinatorEndpoint = await coordinatorRegistry
|
|
||||||
.getCoordinatorEndpoint(coordinatorOperator)
|
|
||||||
.callAsync();
|
|
||||||
expect(recordedCoordinatorEndpoint).to.be.equal(coordinatorEndpoint);
|
|
||||||
});
|
|
||||||
it('Should successfully unset a Coordinator endpoint', async () => {
|
|
||||||
// set Coordinator endpoint
|
|
||||||
await coordinatorRegistry.setCoordinatorEndpoint(coordinatorEndpoint).awaitTransactionSuccessAsync({
|
|
||||||
from: coordinatorOperator,
|
|
||||||
});
|
|
||||||
let recordedCoordinatorEndpoint = await coordinatorRegistry
|
|
||||||
.getCoordinatorEndpoint(coordinatorOperator)
|
|
||||||
.callAsync();
|
|
||||||
expect(recordedCoordinatorEndpoint).to.be.equal(coordinatorEndpoint);
|
|
||||||
// unset Coordinator endpoint
|
|
||||||
await coordinatorRegistry.setCoordinatorEndpoint(nilCoordinatorEndpoint).awaitTransactionSuccessAsync({
|
|
||||||
from: coordinatorOperator,
|
|
||||||
});
|
|
||||||
recordedCoordinatorEndpoint = await coordinatorRegistry
|
|
||||||
.getCoordinatorEndpoint(coordinatorOperator)
|
|
||||||
.callAsync();
|
|
||||||
expect(recordedCoordinatorEndpoint).to.be.equal(nilCoordinatorEndpoint);
|
|
||||||
});
|
|
||||||
it('Should emit an event when setting Coordinator endpoint', async () => {
|
|
||||||
// set Coordinator endpoint
|
|
||||||
const txReceipt = await coordinatorRegistry
|
|
||||||
.setCoordinatorEndpoint(coordinatorEndpoint)
|
|
||||||
.awaitTransactionSuccessAsync({
|
|
||||||
from: coordinatorOperator,
|
|
||||||
});
|
|
||||||
const recordedCoordinatorEndpoint = await coordinatorRegistry
|
|
||||||
.getCoordinatorEndpoint(coordinatorOperator)
|
|
||||||
.callAsync();
|
|
||||||
expect(recordedCoordinatorEndpoint).to.be.equal(coordinatorEndpoint);
|
|
||||||
// validate event
|
|
||||||
const expectedEvent: CoordinatorRegistryCoordinatorEndpointSetEventArgs = {
|
|
||||||
coordinatorOperator,
|
|
||||||
coordinatorEndpoint,
|
|
||||||
};
|
|
||||||
verifyEvents(txReceipt, [expectedEvent], 'CoordinatorEndpointSet');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import { env, EnvVars } from '@0x/dev-utils';
|
|
||||||
|
|
||||||
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
|
|
||||||
import { providerUtils } from '@0x/utils';
|
|
||||||
|
|
||||||
before('start web3 provider', () => {
|
|
||||||
providerUtils.startProviderEngine(provider);
|
|
||||||
});
|
|
||||||
after('generate coverage report', async () => {
|
|
||||||
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
|
|
||||||
const coverageSubprovider = coverage.getCoverageSubproviderSingleton();
|
|
||||||
await coverageSubprovider.writeCoverageAsync();
|
|
||||||
}
|
|
||||||
if (env.parseBoolean(EnvVars.SolidityProfiler)) {
|
|
||||||
const profilerSubprovider = profiler.getProfilerSubproviderSingleton();
|
|
||||||
await profilerSubprovider.writeProfilerOutputAsync();
|
|
||||||
}
|
|
||||||
provider.stop();
|
|
||||||
});
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
import { blockchainTests, constants, expect, randomAddress, transactionHashUtils } from '@0x/contracts-test-utils';
|
|
||||||
import { BigNumber } from '@0x/utils';
|
|
||||||
|
|
||||||
import { hashUtils } from '../src/hash_utils';
|
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
|
|
||||||
import { CoordinatorContract } from './wrappers';
|
|
||||||
|
|
||||||
blockchainTests.resets('Libs tests', env => {
|
|
||||||
let coordinatorContract: CoordinatorContract;
|
|
||||||
let chainId: number;
|
|
||||||
const exchangeAddress = randomAddress();
|
|
||||||
|
|
||||||
before(async () => {
|
|
||||||
chainId = await env.getChainIdAsync();
|
|
||||||
coordinatorContract = await CoordinatorContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.Coordinator,
|
|
||||||
env.provider,
|
|
||||||
env.txDefaults,
|
|
||||||
artifacts,
|
|
||||||
exchangeAddress,
|
|
||||||
new BigNumber(chainId),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getApprovalHash', () => {
|
|
||||||
it('should return the correct approval hash', async () => {
|
|
||||||
const signedTx = {
|
|
||||||
salt: constants.ZERO_AMOUNT,
|
|
||||||
gasPrice: constants.ZERO_AMOUNT,
|
|
||||||
expirationTimeSeconds: constants.ZERO_AMOUNT,
|
|
||||||
signerAddress: constants.NULL_ADDRESS,
|
|
||||||
data: '0x1234',
|
|
||||||
signature: '0x5678',
|
|
||||||
domain: {
|
|
||||||
verifyingContract: exchangeAddress,
|
|
||||||
chainId,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const txOrigin = constants.NULL_ADDRESS;
|
|
||||||
const approval = {
|
|
||||||
txOrigin,
|
|
||||||
transactionHash: transactionHashUtils.getTransactionHashHex(signedTx),
|
|
||||||
transactionSignature: signedTx.signature,
|
|
||||||
};
|
|
||||||
const expectedApprovalHash = await hashUtils.getApprovalHashHexAsync(
|
|
||||||
signedTx,
|
|
||||||
coordinatorContract.address,
|
|
||||||
txOrigin,
|
|
||||||
);
|
|
||||||
const approvalHash = await coordinatorContract.getCoordinatorApprovalHash(approval).callAsync();
|
|
||||||
expect(expectedApprovalHash).to.eq(approvalHash);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,538 +0,0 @@
|
|||||||
import { exchangeDataEncoder } from '@0x/contracts-exchange';
|
|
||||||
import {
|
|
||||||
blockchainTests,
|
|
||||||
constants,
|
|
||||||
ExchangeFunctionName,
|
|
||||||
expect,
|
|
||||||
hexConcat,
|
|
||||||
hexSlice,
|
|
||||||
randomAddress,
|
|
||||||
TransactionFactory,
|
|
||||||
transactionHashUtils,
|
|
||||||
} from '@0x/contracts-test-utils';
|
|
||||||
import { LibBytesRevertErrors } from '@0x/contracts-utils';
|
|
||||||
import { SignatureType, SignedOrder } from '@0x/types';
|
|
||||||
import { BigNumber } from '@0x/utils';
|
|
||||||
|
|
||||||
import CoordinatorRevertErrors = require('../src/revert_errors');
|
|
||||||
|
|
||||||
import { ApprovalFactory } from '../src/approval_factory';
|
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
|
|
||||||
import { CoordinatorContract } from './wrappers';
|
|
||||||
|
|
||||||
blockchainTests.resets('Mixins tests', env => {
|
|
||||||
let chainId: number;
|
|
||||||
let transactionSignerAddress: string;
|
|
||||||
let approvalSignerAddress1: string;
|
|
||||||
let approvalSignerAddress2: string;
|
|
||||||
let mixins: CoordinatorContract;
|
|
||||||
let transactionFactory: TransactionFactory;
|
|
||||||
let approvalFactory1: ApprovalFactory;
|
|
||||||
let approvalFactory2: ApprovalFactory;
|
|
||||||
let defaultOrder: SignedOrder;
|
|
||||||
const exchangeAddress = randomAddress();
|
|
||||||
|
|
||||||
before(async () => {
|
|
||||||
chainId = await env.getChainIdAsync();
|
|
||||||
mixins = await CoordinatorContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.Coordinator,
|
|
||||||
env.provider,
|
|
||||||
env.txDefaults,
|
|
||||||
artifacts,
|
|
||||||
exchangeAddress,
|
|
||||||
new BigNumber(chainId),
|
|
||||||
);
|
|
||||||
const accounts = await env.getAccountAddressesAsync();
|
|
||||||
[transactionSignerAddress, approvalSignerAddress1, approvalSignerAddress2] = accounts;
|
|
||||||
defaultOrder = {
|
|
||||||
makerAddress: constants.NULL_ADDRESS,
|
|
||||||
takerAddress: constants.NULL_ADDRESS,
|
|
||||||
senderAddress: mixins.address,
|
|
||||||
feeRecipientAddress: approvalSignerAddress1,
|
|
||||||
makerAssetData: constants.NULL_BYTES,
|
|
||||||
takerAssetData: constants.NULL_BYTES,
|
|
||||||
makerAssetAmount: constants.ZERO_AMOUNT,
|
|
||||||
takerAssetAmount: constants.ZERO_AMOUNT,
|
|
||||||
makerFee: constants.ZERO_AMOUNT,
|
|
||||||
takerFee: constants.ZERO_AMOUNT,
|
|
||||||
makerFeeAssetData: constants.NULL_BYTES,
|
|
||||||
takerFeeAssetData: constants.NULL_BYTES,
|
|
||||||
expirationTimeSeconds: constants.ZERO_AMOUNT,
|
|
||||||
salt: constants.ZERO_AMOUNT,
|
|
||||||
signature: constants.NULL_BYTES,
|
|
||||||
exchangeAddress: constants.NULL_ADDRESS,
|
|
||||||
chainId,
|
|
||||||
};
|
|
||||||
const transactionSignerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(transactionSignerAddress)];
|
|
||||||
const approvalSignerPrivateKey1 = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(approvalSignerAddress1)];
|
|
||||||
const approvalSignerPrivateKey2 = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(approvalSignerAddress2)];
|
|
||||||
transactionFactory = new TransactionFactory(transactionSignerPrivateKey, exchangeAddress, chainId);
|
|
||||||
approvalFactory1 = new ApprovalFactory(approvalSignerPrivateKey1, mixins.address);
|
|
||||||
approvalFactory2 = new ApprovalFactory(approvalSignerPrivateKey2, mixins.address);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getSignerAddress', () => {
|
|
||||||
it('should return the correct address using the EthSign signature type', async () => {
|
|
||||||
const data = constants.NULL_BYTES;
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data }, SignatureType.EthSign);
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
|
||||||
const signerAddress = await mixins.getSignerAddress(transactionHash, transaction.signature).callAsync();
|
|
||||||
expect(transaction.signerAddress).to.eq(signerAddress);
|
|
||||||
});
|
|
||||||
it('should return the correct address using the EIP712 signature type', async () => {
|
|
||||||
const data = constants.NULL_BYTES;
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data }, SignatureType.EIP712);
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
|
||||||
const signerAddress = await mixins.getSignerAddress(transactionHash, transaction.signature).callAsync();
|
|
||||||
expect(transaction.signerAddress).to.eq(signerAddress);
|
|
||||||
});
|
|
||||||
it('should revert with with the Illegal signature type', async () => {
|
|
||||||
const data = constants.NULL_BYTES;
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
transaction.signature = hexConcat(
|
|
||||||
hexSlice(transaction.signature, 0, transaction.signature.length - 1),
|
|
||||||
SignatureType.Illegal,
|
|
||||||
);
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
|
||||||
expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith(
|
|
||||||
new CoordinatorRevertErrors.SignatureError(
|
|
||||||
CoordinatorRevertErrors.SignatureErrorCodes.Illegal,
|
|
||||||
transactionHash,
|
|
||||||
transaction.signature,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('should revert with with the Invalid signature type', async () => {
|
|
||||||
const data = constants.NULL_BYTES;
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
transaction.signature = hexConcat(SignatureType.Invalid);
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
|
||||||
expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith(
|
|
||||||
new CoordinatorRevertErrors.SignatureError(
|
|
||||||
CoordinatorRevertErrors.SignatureErrorCodes.Invalid,
|
|
||||||
transactionHash,
|
|
||||||
transaction.signature,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('should revert with with a signature type that equals `NSignatureTypes`', async () => {
|
|
||||||
const data = constants.NULL_BYTES;
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
transaction.signature = hexConcat(
|
|
||||||
hexSlice(transaction.signature, 0, transaction.signature.length - 1),
|
|
||||||
SignatureType.NSignatureTypes,
|
|
||||||
);
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
|
||||||
expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith(
|
|
||||||
new CoordinatorRevertErrors.SignatureError(
|
|
||||||
CoordinatorRevertErrors.SignatureErrorCodes.Unsupported,
|
|
||||||
transactionHash,
|
|
||||||
transaction.signature,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it("should revert with with a signature type that isn't supported", async () => {
|
|
||||||
const data = constants.NULL_BYTES;
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
transaction.signature = hexConcat(
|
|
||||||
hexSlice(transaction.signature, 0, transaction.signature.length - 1),
|
|
||||||
SignatureType.Wallet,
|
|
||||||
);
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
|
||||||
expect(mixins.getSignerAddress(transactionHash, transaction.signature).callAsync()).to.revertWith(
|
|
||||||
new CoordinatorRevertErrors.SignatureError(
|
|
||||||
CoordinatorRevertErrors.SignatureErrorCodes.Unsupported,
|
|
||||||
transactionHash,
|
|
||||||
transaction.signature,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('decodeOrdersFromFillData', () => {
|
|
||||||
for (const fnName of constants.SINGLE_FILL_FN_NAMES) {
|
|
||||||
it(`should correctly decode the orders for ${fnName} data`, async () => {
|
|
||||||
const orders = [defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync();
|
|
||||||
const decodedSignedOrders = decodedOrders.map(order => ({
|
|
||||||
...order,
|
|
||||||
signature: constants.NULL_BYTES,
|
|
||||||
exchangeAddress: constants.NULL_ADDRESS,
|
|
||||||
chainId,
|
|
||||||
}));
|
|
||||||
expect(orders).to.deep.eq(decodedSignedOrders);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
for (const fnName of constants.BATCH_FILL_FN_NAMES) {
|
|
||||||
it(`should correctly decode the orders for ${fnName} data`, async () => {
|
|
||||||
const orders = [defaultOrder, defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync();
|
|
||||||
const decodedSignedOrders = decodedOrders.map(order => ({
|
|
||||||
...order,
|
|
||||||
signature: constants.NULL_BYTES,
|
|
||||||
exchangeAddress: constants.NULL_ADDRESS,
|
|
||||||
chainId,
|
|
||||||
}));
|
|
||||||
expect(orders).to.deep.eq(decodedSignedOrders);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
for (const fnName of constants.MARKET_FILL_FN_NAMES) {
|
|
||||||
it(`should correctly decode the orders for ${fnName} data`, async () => {
|
|
||||||
const orders = [defaultOrder, defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync();
|
|
||||||
const decodedSignedOrders = decodedOrders.map(order => ({
|
|
||||||
...order,
|
|
||||||
signature: constants.NULL_BYTES,
|
|
||||||
exchangeAddress: constants.NULL_ADDRESS,
|
|
||||||
chainId,
|
|
||||||
}));
|
|
||||||
expect(orders).to.deep.eq(decodedSignedOrders);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
for (const fnName of constants.MATCH_ORDER_FN_NAMES) {
|
|
||||||
it(`should correctly decode the orders for ${fnName} data`, async () => {
|
|
||||||
const orders = [defaultOrder, defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync();
|
|
||||||
const decodedSignedOrders = decodedOrders.map(order => ({
|
|
||||||
...order,
|
|
||||||
signature: constants.NULL_BYTES,
|
|
||||||
exchangeAddress: constants.NULL_ADDRESS,
|
|
||||||
chainId,
|
|
||||||
}));
|
|
||||||
expect(orders).to.deep.eq(decodedSignedOrders);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
for (const fnName of constants.CANCEL_ORDER_FN_NAMES) {
|
|
||||||
it(`should correctly decode the orders for ${fnName} data`, async () => {
|
|
||||||
const orders = [defaultOrder, defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync();
|
|
||||||
const emptyArray: any[] = [];
|
|
||||||
expect(emptyArray).to.deep.eq(decodedOrders);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
it('should decode an empty array for invalid data', async () => {
|
|
||||||
const data = '0x0123456789';
|
|
||||||
const decodedOrders = await mixins.decodeOrdersFromFillData(data).callAsync();
|
|
||||||
const emptyArray: any[] = [];
|
|
||||||
expect(emptyArray).to.deep.eq(decodedOrders);
|
|
||||||
});
|
|
||||||
it('should revert if data is less than 4 bytes long', async () => {
|
|
||||||
const data = '0x010203';
|
|
||||||
const expectedError = new LibBytesRevertErrors.InvalidByteOperationError(
|
|
||||||
LibBytesRevertErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsFourRequired,
|
|
||||||
new BigNumber(3), // the length of data
|
|
||||||
new BigNumber(4),
|
|
||||||
);
|
|
||||||
return expect(mixins.decodeOrdersFromFillData(data).callAsync()).to.revertWith(expectedError);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Single order approvals', () => {
|
|
||||||
for (const fnName of constants.SINGLE_FILL_FN_NAMES) {
|
|
||||||
it(`Should be successful: function=${fnName}, caller=tx_signer, senderAddress=[verifier], approval_sig=[approver1]`, async () => {
|
|
||||||
const orders = [defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
|
||||||
approval.signature,
|
|
||||||
])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
});
|
|
||||||
it(`Should be successful: function=${fnName}, caller=tx_signer, senderAddress=[null], approval_sig=[approver1]`, async () => {
|
|
||||||
const order = {
|
|
||||||
...defaultOrder,
|
|
||||||
senderAddress: constants.NULL_ADDRESS,
|
|
||||||
};
|
|
||||||
const orders = [order];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
|
||||||
approval.signature,
|
|
||||||
])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
});
|
|
||||||
it(`Should be successful: function=${fnName}, caller=approver1, senderAddress=[verifier], approval_sig=[]`, async () => {
|
|
||||||
const orders = [defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, [])
|
|
||||||
.callAsync({
|
|
||||||
from: approvalSignerAddress1,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it(`Should be successful: function=${fnName}, caller=approver1, senderAddress=[verifier], approval_sig=[approver1]`, async () => {
|
|
||||||
const orders = [defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, [
|
|
||||||
approval.signature,
|
|
||||||
])
|
|
||||||
.callAsync({ from: approvalSignerAddress1 });
|
|
||||||
});
|
|
||||||
it(`Should be successful: function=${fnName}, caller=approver1, senderAddress=[verifier], approval_sig=[]`, async () => {
|
|
||||||
const orders = [defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, [])
|
|
||||||
.callAsync({
|
|
||||||
from: approvalSignerAddress1,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it(`Should revert: function=${fnName}, caller=tx_signer, senderAddress=[verifier], approval_sig=[invalid]`, async () => {
|
|
||||||
const orders = [defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
const signature = hexConcat(
|
|
||||||
hexSlice(approval.signature, 0, 2),
|
|
||||||
'0xFFFFFFFF',
|
|
||||||
hexSlice(approval.signature, 6),
|
|
||||||
);
|
|
||||||
const tx = mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
|
||||||
signature,
|
|
||||||
])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
|
||||||
expect(tx).to.revertWith(
|
|
||||||
new CoordinatorRevertErrors.InvalidApprovalSignatureError(transactionHash, approvalSignerAddress1),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it(`Should revert: function=${fnName}, caller=approver2, senderAddress=[verifier], approval_sig=[approver1]`, async () => {
|
|
||||||
const orders = [defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
|
|
||||||
const tx = mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
|
||||||
approval.signature,
|
|
||||||
])
|
|
||||||
.callAsync({ from: approvalSignerAddress2 });
|
|
||||||
expect(tx).to.revertWith(new CoordinatorRevertErrors.InvalidOriginError(transactionSignerAddress));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
describe('Batch order approvals', () => {
|
|
||||||
for (const fnName of [
|
|
||||||
...constants.BATCH_FILL_FN_NAMES,
|
|
||||||
...constants.MARKET_FILL_FN_NAMES,
|
|
||||||
...constants.MATCH_ORDER_FN_NAMES,
|
|
||||||
]) {
|
|
||||||
it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver1], approval_sig=[approver1]`, async () => {
|
|
||||||
const orders = [defaultOrder, defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
|
||||||
approval.signature,
|
|
||||||
])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
});
|
|
||||||
it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[null,null], feeRecipient=[approver1,approver1], approval_sig=[approver1]`, async () => {
|
|
||||||
const orders = [defaultOrder, defaultOrder].map(order => ({
|
|
||||||
...order,
|
|
||||||
senderAddress: constants.NULL_ADDRESS,
|
|
||||||
}));
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
|
||||||
approval.signature,
|
|
||||||
])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
});
|
|
||||||
it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[null,null], feeRecipient=[approver1,approver1], approval_sig=[]`, async () => {
|
|
||||||
const orders = [defaultOrder, defaultOrder].map(order => ({
|
|
||||||
...order,
|
|
||||||
senderAddress: constants.NULL_ADDRESS,
|
|
||||||
}));
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
});
|
|
||||||
it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,null], feeRecipient=[approver1,approver1], approval_sig=[approver1]`, async () => {
|
|
||||||
const orders = [defaultOrder, { ...defaultOrder, senderAddress: constants.NULL_ADDRESS }];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
|
||||||
approval.signature,
|
|
||||||
])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
});
|
|
||||||
it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver2], approval_sig=[approver1,approver2]`, async () => {
|
|
||||||
const orders = [defaultOrder, { ...defaultOrder, feeRecipientAddress: approvalSignerAddress2 }];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval1 = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
const approval2 = await approvalFactory2.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
|
||||||
approval1.signature,
|
|
||||||
approval2.signature,
|
|
||||||
])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
});
|
|
||||||
it(`Should be successful: function=${fnName} caller=approver1, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver1], approval_sig=[]`, async () => {
|
|
||||||
const orders = [defaultOrder, defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, [])
|
|
||||||
.callAsync({ from: approvalSignerAddress1 });
|
|
||||||
});
|
|
||||||
it(`Should revert: function=${fnName} caller=approver1, senderAddress=[verifier,verifier], feeRecipient=[approver1,approver2], approval_sig=[approver2]`, async () => {
|
|
||||||
const orders = [defaultOrder, { ...defaultOrder, feeRecipientAddress: approvalSignerAddress2 }];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval2 = await approvalFactory2.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
|
|
||||||
const tx = mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
|
||||||
approval2.signature,
|
|
||||||
])
|
|
||||||
.callAsync({ from: approvalSignerAddress1 });
|
|
||||||
expect(tx).to.revertWith(new CoordinatorRevertErrors.InvalidOriginError(transactionSignerAddress));
|
|
||||||
});
|
|
||||||
it(`Should revert: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1, approver1], approval_sig=[]`, async () => {
|
|
||||||
const orders = [defaultOrder, defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const tx = mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
|
||||||
expect(tx).to.revertWith(
|
|
||||||
new CoordinatorRevertErrors.InvalidApprovalSignatureError(transactionHash, approvalSignerAddress1),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it(`Should revert: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1, approver1], approval_sig=[invalid]`, async () => {
|
|
||||||
const orders = [defaultOrder, defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
const signature = hexConcat(
|
|
||||||
hexSlice(approval.signature, 0, 2),
|
|
||||||
'0xFFFFFFFF',
|
|
||||||
hexSlice(approval.signature, 6),
|
|
||||||
);
|
|
||||||
const tx = mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
|
||||||
signature,
|
|
||||||
])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
|
||||||
expect(tx).to.revertWith(
|
|
||||||
new CoordinatorRevertErrors.InvalidApprovalSignatureError(transactionHash, approvalSignerAddress1),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it(`Should revert: function=${fnName} caller=tx_signer, senderAddress=[verifier,verifier], feeRecipient=[approver1, approver2], approval_sig=[valid,invalid]`, async () => {
|
|
||||||
const orders = [defaultOrder, { ...defaultOrder, feeRecipientAddress: approvalSignerAddress2 }];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval1 = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
const approval2 = await approvalFactory2.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
const approvalSignature2 = hexConcat(
|
|
||||||
hexSlice(approval2.signature, 0, 2),
|
|
||||||
'0xFFFFFFFF',
|
|
||||||
hexSlice(approval2.signature, 6),
|
|
||||||
);
|
|
||||||
const tx = mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
|
||||||
approval1.signature,
|
|
||||||
approvalSignature2,
|
|
||||||
])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
|
||||||
expect(tx).to.revertWith(
|
|
||||||
new CoordinatorRevertErrors.InvalidApprovalSignatureError(transactionHash, approvalSignerAddress2),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it(`Should revert: function=${fnName} caller=approver1, senderAddress=[verifier,verifier], feeRecipient=[approver1, approver2], approval_sig=[invalid]`, async () => {
|
|
||||||
const orders = [defaultOrder, { ...defaultOrder, feeRecipientAddress: approvalSignerAddress2 }];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval2 = await approvalFactory2.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
const approvalSignature2 = hexConcat(
|
|
||||||
hexSlice(approval2.signature, 0, 2),
|
|
||||||
'0xFFFFFFFF',
|
|
||||||
hexSlice(approval2.signature, 6),
|
|
||||||
);
|
|
||||||
const tx = mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, approvalSignerAddress1, transaction.signature, [
|
|
||||||
approvalSignature2,
|
|
||||||
])
|
|
||||||
.callAsync({ from: approvalSignerAddress1 });
|
|
||||||
|
|
||||||
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
|
|
||||||
expect(tx).to.revertWith(
|
|
||||||
new CoordinatorRevertErrors.InvalidApprovalSignatureError(transactionHash, approvalSignerAddress2),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it(`Should revert: function=${fnName} caller=approver2, senderAddress=[verifier,verifier], feeRecipient=[approver1, approver1], approval_sig=[valid]`, async () => {
|
|
||||||
const orders = [defaultOrder, defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
const approval1 = await approvalFactory1.newSignedApprovalAsync(transaction, transactionSignerAddress);
|
|
||||||
|
|
||||||
const tx = mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [
|
|
||||||
approval1.signature,
|
|
||||||
])
|
|
||||||
.callAsync({ from: approvalSignerAddress2 });
|
|
||||||
expect(tx).to.revertWith(new CoordinatorRevertErrors.InvalidOriginError(transactionSignerAddress));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
describe('cancels', () => {
|
|
||||||
it('should allow the tx signer to call `cancelOrder` without approval', async () => {
|
|
||||||
const orders = [defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.CancelOrder, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
});
|
|
||||||
it('should allow the tx signer to call `batchCancelOrders` without approval', async () => {
|
|
||||||
const orders = [defaultOrder, defaultOrder];
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.BatchCancelOrders, orders);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
});
|
|
||||||
it('should allow the tx signer to call `cancelOrdersUpTo` without approval', async () => {
|
|
||||||
const data = exchangeDataEncoder.encodeOrdersToExchangeData(ExchangeFunctionName.CancelOrdersUpTo);
|
|
||||||
const transaction = await transactionFactory.newSignedTransactionAsync({ data });
|
|
||||||
await mixins
|
|
||||||
.assertValidCoordinatorApprovals(transaction, transactionSignerAddress, transaction.signature, [])
|
|
||||||
.callAsync({ from: transactionSignerAddress });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// tslint:disable:max-file-line-count
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
|
||||||
* -----------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
export * from '../test/generated-wrappers/coordinator';
|
|
||||||
export * from '../test/generated-wrappers/coordinator_registry';
|
|
||||||
export * from '../test/generated-wrappers/i_coordinator_approval_verifier';
|
|
||||||
export * from '../test/generated-wrappers/i_coordinator_core';
|
|
||||||
export * from '../test/generated-wrappers/i_coordinator_registry_core';
|
|
||||||
export * from '../test/generated-wrappers/i_coordinator_signature_validator';
|
|
||||||
export * from '../test/generated-wrappers/lib_constants';
|
|
||||||
export * from '../test/generated-wrappers/lib_coordinator_approval';
|
|
||||||
export * from '../test/generated-wrappers/lib_coordinator_rich_errors';
|
|
||||||
export * from '../test/generated-wrappers/lib_e_i_p712_coordinator_domain';
|
|
||||||
export * from '../test/generated-wrappers/mixin_coordinator_approval_verifier';
|
|
||||||
export * from '../test/generated-wrappers/mixin_coordinator_core';
|
|
||||||
export * from '../test/generated-wrappers/mixin_coordinator_registry_core';
|
|
||||||
export * from '../test/generated-wrappers/mixin_signature_validator';
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../../tsconfig",
|
|
||||||
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
|
|
||||||
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
|
|
||||||
"files": [
|
|
||||||
"generated-artifacts/Coordinator.json",
|
|
||||||
"generated-artifacts/CoordinatorRegistry.json",
|
|
||||||
"generated-artifacts/LibConstants.json",
|
|
||||||
"generated-artifacts/LibCoordinatorApproval.json",
|
|
||||||
"generated-artifacts/LibCoordinatorRichErrors.json",
|
|
||||||
"generated-artifacts/LibEIP712CoordinatorDomain.json",
|
|
||||||
"test/generated-artifacts/Coordinator.json",
|
|
||||||
"test/generated-artifacts/CoordinatorRegistry.json",
|
|
||||||
"test/generated-artifacts/ICoordinatorApprovalVerifier.json",
|
|
||||||
"test/generated-artifacts/ICoordinatorCore.json",
|
|
||||||
"test/generated-artifacts/ICoordinatorRegistryCore.json",
|
|
||||||
"test/generated-artifacts/ICoordinatorSignatureValidator.json",
|
|
||||||
"test/generated-artifacts/LibConstants.json",
|
|
||||||
"test/generated-artifacts/LibCoordinatorApproval.json",
|
|
||||||
"test/generated-artifacts/LibCoordinatorRichErrors.json",
|
|
||||||
"test/generated-artifacts/LibEIP712CoordinatorDomain.json",
|
|
||||||
"test/generated-artifacts/MixinCoordinatorApprovalVerifier.json",
|
|
||||||
"test/generated-artifacts/MixinCoordinatorCore.json",
|
|
||||||
"test/generated-artifacts/MixinCoordinatorRegistryCore.json",
|
|
||||||
"test/generated-artifacts/MixinSignatureValidator.json"
|
|
||||||
],
|
|
||||||
"exclude": ["./deploy/solc/solc_bin"]
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["@0x/tslint-config"],
|
|
||||||
"rules": {
|
|
||||||
"custom-no-magic-numbers": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../../typedoc-tsconfig",
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "lib"
|
|
||||||
},
|
|
||||||
"include": ["./src/**/*", "./test/**/*"]
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# Blacklist all files
|
|
||||||
.*
|
|
||||||
*
|
|
||||||
# Whitelist lib
|
|
||||||
!lib/**/*
|
|
||||||
# Whitelist Solidity contracts
|
|
||||||
!contracts/src/**/*
|
|
||||||
# Blacklist tests in lib
|
|
||||||
/lib/test/*
|
|
||||||
# Package specific ignore
|
|
||||||
@@ -1,193 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"version": "0.1.0-beta.3",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1574238768
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "0.1.0-beta.2",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils",
|
|
||||||
"pr": 2330
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add new method getOrderHash() to DevUtils contract",
|
|
||||||
"pr": 2321
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add new method getTransactionHash() to DevUtils contract",
|
|
||||||
"pr": 2321
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1574030254
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "0.1.0-beta.1",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Add `encodeStaticCallAssetData` and `decodeStaticCallAssetData` in LibAssetData",
|
|
||||||
"pr": 2034
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add `revertIfInvalidAssetData` in LibAssetData",
|
|
||||||
"pr": 2034
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1573159180
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "0.1.0-beta.0",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Use built in selectors instead of hard coded constants",
|
|
||||||
"pr": 2055
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Compile and export all contracts, artifacts, and wrappers by default",
|
|
||||||
"pr": 2055
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add `marketBuy/SellOrdersNoThrow` and `marketBuy/SellOrdersFillOrKill` to `LibTransactionDecoder`.",
|
|
||||||
"pr": 2075
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "`run_mocha` package script runs with `UNLIMITED_CONTRACT_SIZE=true` environment variable.",
|
|
||||||
"pr": 2075
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1570135330
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1568744790,
|
|
||||||
"version": "0.0.10",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1567521715,
|
|
||||||
"version": "0.0.9",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1566446343,
|
|
||||||
"version": "0.0.8",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1565296576,
|
|
||||||
"version": "0.0.7",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1564607468,
|
|
||||||
"version": "0.0.6",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "0.0.5",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Updated calls to <contract wrapper>.deployFrom0xArtifactAsync to include artifact dependencies.",
|
|
||||||
"pr": 1995
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": 1564604963
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1563957393,
|
|
||||||
"version": "0.0.5",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1563193019,
|
|
||||||
"version": "0.0.4",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1563047529,
|
|
||||||
"version": "0.0.3",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"timestamp": 1563006338,
|
|
||||||
"version": "0.0.2",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Dependencies updated"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"version": "0.0.1",
|
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"note": "Create dev-utils package",
|
|
||||||
"pr": 1848
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add `LibAssetData` and `LibTransactionDecoder` contracts",
|
|
||||||
"pr": 1848
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Refactor `LibAssetData` to only check 0x-specific allowances",
|
|
||||||
"pr": 1848
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Refactor `LibAssetData` balance/allowance checks to never revert",
|
|
||||||
"pr": 1848
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Refactor `OrderValidationUtils` to calculate `fillableTakerAssetAmount`",
|
|
||||||
"pr": 1848
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add support for StaticCallProxy",
|
|
||||||
"pr": 1863
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Add `OrderTransferSimulationUtils` contract for simulating order transfers on-chain",
|
|
||||||
"pr": 1868
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"note": "Updated to use the new rich error pattern from @0x/contracts-exchange",
|
|
||||||
"pr": 1913
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
<!--
|
|
||||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
|
||||||
Edit the package's CHANGELOG.json file only.
|
|
||||||
-->
|
|
||||||
|
|
||||||
CHANGELOG
|
|
||||||
|
|
||||||
## v0.1.0-beta.3 - _November 20, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v0.1.0-beta.2 - _November 17, 2019_
|
|
||||||
|
|
||||||
* Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils (#2330)
|
|
||||||
* Add new method getOrderHash() to DevUtils contract (#2321)
|
|
||||||
* Add new method getTransactionHash() to DevUtils contract (#2321)
|
|
||||||
|
|
||||||
## v0.1.0-beta.1 - _November 7, 2019_
|
|
||||||
|
|
||||||
* Add `encodeStaticCallAssetData` and `decodeStaticCallAssetData` in LibAssetData (#2034)
|
|
||||||
* Add `revertIfInvalidAssetData` in LibAssetData (#2034)
|
|
||||||
|
|
||||||
## v0.1.0-beta.0 - _October 3, 2019_
|
|
||||||
|
|
||||||
* Use built in selectors instead of hard coded constants (#2055)
|
|
||||||
* Compile and export all contracts, artifacts, and wrappers by default (#2055)
|
|
||||||
* Add `marketBuy/SellOrdersNoThrow` and `marketBuy/SellOrdersFillOrKill` to `LibTransactionDecoder`. (#2075)
|
|
||||||
* `run_mocha` package script runs with `UNLIMITED_CONTRACT_SIZE=true` environment variable. (#2075)
|
|
||||||
|
|
||||||
## v0.0.10 - _September 17, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v0.0.9 - _September 3, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v0.0.8 - _August 22, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v0.0.7 - _August 8, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v0.0.6 - _July 31, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v0.0.5 - _July 31, 2019_
|
|
||||||
|
|
||||||
* Updated calls to <contract wrapper>.deployFrom0xArtifactAsync to include artifact dependencies. (#1995)
|
|
||||||
|
|
||||||
## v0.0.5 - _July 24, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v0.0.4 - _July 15, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v0.0.3 - _July 13, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v0.0.2 - _July 13, 2019_
|
|
||||||
|
|
||||||
* Dependencies updated
|
|
||||||
|
|
||||||
## v0.0.1 - _Invalid date_
|
|
||||||
|
|
||||||
* Create dev-utils package (#1848)
|
|
||||||
* Add `LibAssetData` and `LibTransactionDecoder` contracts (#1848)
|
|
||||||
* Refactor `LibAssetData` to only check 0x-specific allowances (#1848)
|
|
||||||
* Refactor `LibAssetData` balance/allowance checks to never revert (#1848)
|
|
||||||
* Refactor `OrderValidationUtils` to calculate `fillableTakerAssetAmount` (#1848)
|
|
||||||
* Add support for StaticCallProxy (#1863)
|
|
||||||
* Add `OrderTransferSimulationUtils` contract for simulating order transfers on-chain (#1868)
|
|
||||||
* Updated to use the new rich error pattern from @0x/contracts-exchange (#1913)
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
## Dev-Utils
|
|
||||||
|
|
||||||
This package implements various utilities for developers. For example, the `DevUtils` contract can query batches of balances or allowances given some `assetData`, can validate batches of orders, and can decode 0x-specific calldata. Addresses of the deployed contracts can be found in this 0x [guide](https://0x.org/docs/guides/0x-cheat-sheet) or the [DEPLOYS](./DEPLOYS.json) file within this package.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
**Install**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install @0x/contracts-dev-utils --save
|
|
||||||
```
|
|
||||||
|
|
||||||
## Bug bounty
|
|
||||||
|
|
||||||
A bug bounty for the 2.0.0 contracts is ongoing! Instructions can be found [here](https://0x.org/docs/guides/bug-bounty-program).
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein.
|
|
||||||
|
|
||||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
|
||||||
|
|
||||||
### Install Dependencies
|
|
||||||
|
|
||||||
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn config set workspaces-experimental true
|
|
||||||
```
|
|
||||||
|
|
||||||
Then install dependencies
|
|
||||||
|
|
||||||
```bash
|
|
||||||
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
|
|
||||||
PKG=@0x/contracts-extensions yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
Or continuously rebuild on change:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
PKG=@0x/contracts-extensions yarn watch
|
|
||||||
```
|
|
||||||
|
|
||||||
### Clean
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn clean
|
|
||||||
```
|
|
||||||
|
|
||||||
### Lint
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn lint
|
|
||||||
```
|
|
||||||
|
|
||||||
### Run Tests
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn test
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Testing options
|
|
||||||
|
|
||||||
Contracts testing options like coverage, profiling, revert traces or backing node choosing - are described [here](../TESTING.md).
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user