Compare commits
478 Commits
contracts@
...
@0xproject
Author | SHA1 | Date | |
---|---|---|---|
|
599554b785 | ||
|
d57d282cab | ||
|
562bef98e2 | ||
|
900f819be8 | ||
|
e7337c2451 | ||
|
dc81193132 | ||
|
fa868b4963 | ||
|
62945ad363 | ||
|
61c38d35be | ||
|
4e0ec72896 | ||
|
c28289e9a8 | ||
|
e7e9ddf232 | ||
|
f03784ba37 | ||
|
2445e23c0b | ||
|
cd29483187 | ||
|
9bacbdab48 | ||
|
551d484fb7 | ||
|
ff66432b83 | ||
|
a7ae82a2d1 | ||
|
5f34b5a80e | ||
|
8fca2a8116 | ||
|
5472500119 | ||
|
8fb5c29b4b | ||
|
40a061a5ca | ||
|
2ef82592a3 | ||
|
14b5448d70 | ||
|
e7d45e47bf | ||
|
28268d4355 | ||
|
50fa02c1d1 | ||
|
b36ff9103d | ||
|
f032c2466c | ||
|
b63ddc9be4 | ||
|
171430b617 | ||
|
d561043774 | ||
|
b1871e9ddd | ||
|
b4a5e7258c | ||
|
3c75debdf9 | ||
|
84d1053f73 | ||
|
f9df42f5d9 | ||
|
4414ef0a0f | ||
|
b7729ada38 | ||
|
3da67feeb2 | ||
|
8a0d563a32 | ||
|
612fc4a949 | ||
|
bf915ce403 | ||
|
0f9ea9773e | ||
|
447a3a6c26 | ||
|
f1cc16c44d | ||
|
aae16b6343 | ||
|
834e1538d1 | ||
|
afc489bc2c | ||
|
3e061e7364 | ||
|
6395c2a8b2 | ||
|
c8225288cd | ||
|
4a108aa67d | ||
|
fd9b3e0dcf | ||
|
f94b647e61 | ||
|
2eccc3efaf | ||
|
972341725e | ||
|
40b10fd29d | ||
|
b31fcffc76 | ||
|
ec222ea0cd | ||
|
5533220da0 | ||
|
6ee7024457 | ||
|
f839ac9c58 | ||
|
1a8b1460a6 | ||
|
feac0779a4 | ||
|
d9eeb0421c | ||
|
031f97e97c | ||
|
b9e1c3c34f | ||
|
1a35107a1d | ||
|
d3e086c850 | ||
|
ab9cfd293b | ||
|
cc840a6911 | ||
|
c4a2f70017 | ||
|
a26cc7c14d | ||
|
7fab782907 | ||
|
cf7967e629 | ||
|
0eacbac8f6 | ||
|
cec76c33b6 | ||
|
18dcf98998 | ||
|
251218af8b | ||
|
c06ed58582 | ||
|
4de6221825 | ||
|
22f3f57f44 | ||
|
b2f362225c | ||
|
40ed59ce28 | ||
|
839db68571 | ||
|
fec6ac3ff0 | ||
|
45fa26dc6c | ||
|
f49d432fdc | ||
|
1a31ceff8e | ||
|
cc486cb86d | ||
|
7a45a579c0 | ||
|
dc58d539c2 | ||
|
2ba78eb740 | ||
|
f43b275f16 | ||
|
509a81a572 | ||
|
184232ba4f | ||
|
0bc338ba42 | ||
|
406e91d387 | ||
|
473acafd14 | ||
|
7474e6b1c9 | ||
|
323955277c | ||
|
03b5b09122 | ||
|
fe00c06d4b | ||
|
ca08dd9705 | ||
|
b3e53b609b | ||
|
fdeab0475c | ||
|
f86cc0dc7a | ||
|
0457c959dd | ||
|
c520b7f1fb | ||
|
5422bf5733 | ||
|
a703160226 | ||
|
d0905eda49 | ||
|
da60008048 | ||
|
7c023233f2 | ||
|
1e7003a307 | ||
|
8cb074657d | ||
|
5f72b86ce4 | ||
|
09d33792f3 | ||
|
a6773b85d2 | ||
|
5f678acf46 | ||
|
76f9ad0705 | ||
|
478f6ed011 | ||
|
c94d1b2275 | ||
|
7d60356fac | ||
|
58fa35641d | ||
|
b74957acdf | ||
|
6aed4fb1ae | ||
|
ad8e12eeae | ||
|
31763a018c | ||
|
bc20f8a004 | ||
|
3f6876c419 | ||
|
fb9c774558 | ||
|
7df9393d29 | ||
|
c6439def2c | ||
|
273d3445e4 | ||
|
bc3dc52377 | ||
|
ef1d484d9e | ||
|
63cd5a6296 | ||
|
657dc785ea | ||
|
461e74d8be | ||
|
a7daea1728 | ||
|
c4416f9696 | ||
|
f9ad34170d | ||
|
45f2a8ad06 | ||
|
3dad802c90 | ||
|
735166f06c | ||
|
042df52e5c | ||
|
294a65f842 | ||
|
bf8550ae1e | ||
|
91549ef28c | ||
|
95956eff64 | ||
|
bcae71dfa4 | ||
|
d370296e82 | ||
|
f42f608f3f | ||
|
f78b5741c3 | ||
|
733fe5b335 | ||
|
c093aab350 | ||
|
44f17c1706 | ||
|
8302e1687a | ||
|
7ad4380653 | ||
|
bea185ce8b | ||
|
5a73b8a8e6 | ||
|
da62a0af3b | ||
|
1137abfd33 | ||
|
e972ed8456 | ||
|
2e1c2d9dfe | ||
|
83dd333eba | ||
|
f854f3ee2b | ||
|
1055ca6d44 | ||
|
a5fea3b9c3 | ||
|
62f1430a2c | ||
|
1dec6a442e | ||
|
97831e3702 | ||
|
7eb9444458 | ||
|
ebc296ea31 | ||
|
75d24dea0e | ||
|
a6f72de09d | ||
|
96037aed52 | ||
|
f9d80adaee | ||
|
422e5a19d4 | ||
|
3d58b38e4e | ||
|
0a044199a1 | ||
|
cd5f00ac4d | ||
|
23c4027c83 | ||
|
eeb08b7fae | ||
|
20beb2bdb6 | ||
|
c6882d0bd8 | ||
|
ce47e83939 | ||
|
832e1e2cf7 | ||
|
6d61616492 | ||
|
d5304fb5bd | ||
|
13a61db289 | ||
|
93b74cc766 | ||
|
28e83c21e2 | ||
|
33ed5cd437 | ||
|
37c8e21f25 | ||
|
7b726650e9 | ||
|
d3adb48c2e | ||
|
9838124abc | ||
|
4df847c349 | ||
|
c64ad1af28 | ||
|
e83b056bd4 | ||
|
eba6dcc497 | ||
|
017b5a23d8 | ||
|
c7a147f49d | ||
|
f84a466d16 | ||
|
382a805c7e | ||
|
0b38e575d6 | ||
|
209266dbed | ||
|
20f6d8d3d0 | ||
|
09b26645ee | ||
|
9f2258ebd9 | ||
|
71e2ee62e4 | ||
|
6c8ee4d55d | ||
|
f94d4b492d | ||
|
e01a4fcbb4 | ||
|
5ed9b8b1dc | ||
|
17f3d5f6ba | ||
|
607d738342 | ||
|
1b102f9ed3 | ||
|
6c38481550 | ||
|
9cbd151658 | ||
|
419b670aa3 | ||
|
a44874d2eb | ||
|
e9d70b7b1e | ||
|
73c6f11c9c | ||
|
a9c5488620 | ||
|
906af858a5 | ||
|
b699a61f56 | ||
|
8eabc49e9d | ||
|
9e67e12732 | ||
|
2d30183d65 | ||
|
fcb0a05880 | ||
|
fad7dc9f04 | ||
|
7c1e05d33c | ||
|
02147f546e | ||
|
3d51bc1ada | ||
|
95df4433dc | ||
|
0f1589a43f | ||
|
27262c4e56 | ||
|
c9b8f2a397 | ||
|
72b2a1c66f | ||
|
69a6166b6a | ||
|
bf87b1a6af | ||
|
2e8a5602b2 | ||
|
0ec1c4ad6d | ||
|
15a3a8c62f | ||
|
f001181e39 | ||
|
2c659d3d82 | ||
|
5ffff7397e | ||
|
1a36459ab8 | ||
|
33cc79c13b | ||
|
b4cb21b55e | ||
|
ae68c3abe4 | ||
|
939e2c70c4 | ||
|
14b29172b1 | ||
|
58794fc8e9 | ||
|
91fdd6fc29 | ||
|
8dd9124863 | ||
|
3fc99dbad5 | ||
|
01dd84dced | ||
|
6b92ef733c | ||
|
fe0f4ae257 | ||
|
cf9555debc | ||
|
528008b1a9 | ||
|
5e3576ed69 | ||
|
28ee9e247e | ||
|
a054b485d0 | ||
|
3585326d7e | ||
|
a6046af024 | ||
|
adaff92c92 | ||
|
0499541e11 | ||
|
f08738e133 | ||
|
1fbdc14734 | ||
|
3e683162e9 | ||
|
8e7937bdb6 | ||
|
b36587fac8 | ||
|
3a1f9d01e8 | ||
|
1131d66b3d | ||
|
7104ae4752 | ||
|
2403323463 | ||
|
feb7dfffa1 | ||
|
005e633e2a | ||
|
127fe971e9 | ||
|
3c4bde6ea1 | ||
|
dc19690863 | ||
|
47604384d4 | ||
|
c69984e309 | ||
|
b8c611de2b | ||
|
9c827a0298 | ||
|
766aeaa9e1 | ||
|
567768c66a | ||
|
deaa5f3211 | ||
|
5682cd0048 | ||
|
11f1ccf3ff | ||
|
2896110d4d | ||
|
d05b175e04 | ||
|
10a379077c | ||
|
ffd9b79100 | ||
|
04c07d9006 | ||
|
a3cc5c1dd7 | ||
|
941342cc24 | ||
|
cc471dd127 | ||
|
9b535e3cec | ||
|
9656895726 | ||
|
121b6949a1 | ||
|
fb31c49317 | ||
|
e51f9b3593 | ||
|
d08bfbf705 | ||
|
a10e466fed | ||
|
35bb010c35 | ||
|
0046a0762c | ||
|
c453012a8e | ||
|
1f82c7eadf | ||
|
b6fb8dbb52 | ||
|
30256cbe51 | ||
|
7f46e9af2c | ||
|
417cec9e04 | ||
|
62a55c0135 | ||
|
72336eb393 | ||
|
12d8c0b6af | ||
|
5c232b6a8d | ||
|
f6fd4281a4 | ||
|
4bee63afc6 | ||
|
d186f6148b | ||
|
2b15c03b9a | ||
|
60d879e045 | ||
|
858d1768ce | ||
|
fc2b7f747b | ||
|
207019c7f3 | ||
|
b264bbea84 | ||
|
32efb3e280 | ||
|
1a0d68d49a | ||
|
7dd3b2d38b | ||
|
4bc65faf1a | ||
|
8634551f53 | ||
|
089663ccc1 | ||
|
d1d26f8bf6 | ||
|
1ca86730fa | ||
|
12ae7c009d | ||
|
51b2fce8c1 | ||
|
62fcb51e1a | ||
|
cbc55f2ef8 | ||
|
679f828e4e | ||
|
4a8b4e7398 | ||
|
b6a11ca31e | ||
|
a30ccf2b25 | ||
|
2574405699 | ||
|
3ba78553f0 | ||
|
4d485fc424 | ||
|
85f28ade86 | ||
|
f6f2991a44 | ||
|
4ea222bbff | ||
|
f9f5e04b41 | ||
|
ea6706a2af | ||
|
64c5c5eb40 | ||
|
823f2db09f | ||
|
a71e511f82 | ||
|
39c0064ffb | ||
|
12d5c35d14 | ||
|
1a161cc02e | ||
|
96f19ba8da | ||
|
a63dfb7995 | ||
|
97ea1e300a | ||
|
d87d93dfac | ||
|
3ffcb03d87 | ||
|
33b08b90a3 | ||
|
cbca2061f7 | ||
|
bf4873e519 | ||
|
8fc1b38ff2 | ||
|
7d957538b4 | ||
|
7a8edb5018 | ||
|
2193d9ae6e | ||
|
79d01fe2d7 | ||
|
0d02037a12 | ||
|
d263f7783f | ||
|
d8ef76fd5e | ||
|
bc3c7a30c4 | ||
|
7b318b3cc2 | ||
|
e5cf41b313 | ||
|
74012ad584 | ||
|
06b4f007f8 | ||
|
a9cf425410 | ||
|
5355da6cad | ||
|
38f7c4a0d2 | ||
|
1fcf3c5dc4 | ||
|
20b0afacf5 | ||
|
6dbe8dbc50 | ||
|
73e23996a6 | ||
|
e40bce253c | ||
|
74c279ea3a | ||
|
6c13b792f9 | ||
|
6be7466c4a | ||
|
1dbdd7ee1f | ||
|
eb89926cee | ||
|
7923ff4ac6 | ||
|
783314c037 | ||
|
15cf64318c | ||
|
442017f93a | ||
|
4dd9f29769 | ||
|
f2f9bd2e7a | ||
|
d95b8ef3e1 | ||
|
ed0c64fdcf | ||
|
9a91e39b3f | ||
|
ce3f25d48f | ||
|
b669508c34 | ||
|
364d8824af | ||
|
749354b1c0 | ||
|
be73084e04 | ||
|
5eb90697c8 | ||
|
faedd2fa0b | ||
|
c47fb8f9a8 | ||
|
27b915789e | ||
|
ddc6dca98c | ||
|
72aa3d3005 | ||
|
3c84ce2050 | ||
|
9db1ce7ceb | ||
|
e472f7899f | ||
|
b053781453 | ||
|
f892b7dbf6 | ||
|
b146acc69e | ||
|
63b941fbaf | ||
|
29dc22e208 | ||
|
41bd0e30d6 | ||
|
40f4dd91e9 | ||
|
5bf43a3560 | ||
|
f0afc0ae45 | ||
|
916b4d3a26 | ||
|
6d1a587c5c | ||
|
bce97c2543 | ||
|
34446cf569 | ||
|
1e13e927d0 | ||
|
3c0fa0b7e6 | ||
|
ad894fbdbb | ||
|
7d9c6eafbf | ||
|
de6f757ec8 | ||
|
3eeb8f4d6d | ||
|
f44ef7ce59 | ||
|
b08c616713 | ||
|
3ad693d334 | ||
|
4aa67e2925 | ||
|
260ab2d413 | ||
|
a824957de7 | ||
|
4017c172a2 | ||
|
65b2c936ab | ||
|
eee190826a | ||
|
20a1deb187 | ||
|
9169913a2c | ||
|
bf0ef055fb | ||
|
4e4842a62f | ||
|
a34c9095c3 | ||
|
84a4b7d1c1 | ||
|
5b69cd4a22 | ||
|
c80b42712a | ||
|
8d76d74a17 | ||
|
6f72fed8b5 | ||
|
27575e9866 | ||
|
986ba175ce | ||
|
919b327fc5 | ||
|
e05b55d4a5 | ||
|
6f24337a53 | ||
|
0e8f5004d6 | ||
|
22fa5a57a5 | ||
|
e30c76b743 | ||
|
75a51af006 | ||
|
24454938e5 | ||
|
89a72ebf0d | ||
|
20aaab0847 | ||
|
3e648cfb7e | ||
|
2106d7476d | ||
|
43e07e7ce3 | ||
|
5e4e27fed5 | ||
|
6c02722f56 | ||
|
5cfebd2680 | ||
|
bd20b1747d |
@@ -3,7 +3,7 @@ version: 2
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:6.12
|
- image: circleci/node:9
|
||||||
environment:
|
environment:
|
||||||
CONTRACTS_COMMIT_HASH: '9ed05f5'
|
CONTRACTS_COMMIT_HASH: '9ed05f5'
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
@@ -11,25 +11,25 @@ jobs:
|
|||||||
- 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
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: dependency-cache-{{ checksum "package.json" }}
|
key: dependency-cache-v1-{{ checksum "package.json" }}
|
||||||
- run:
|
- run:
|
||||||
name: yarn
|
name: yarn
|
||||||
command: yarn --frozen-lockfile
|
command: yarn --frozen-lockfile
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: dependency-cache-{{ checksum "package.json" }}
|
key: dependency-cache-v1-{{ checksum "package.json" }}
|
||||||
paths:
|
paths:
|
||||||
- ./node_modules
|
- ./node_modules
|
||||||
- run: wget https://s3.amazonaws.com/testrpc-shapshots/${CONTRACTS_COMMIT_HASH}.zip
|
- run: wget https://s3.amazonaws.com/testrpc-shapshots/${CONTRACTS_COMMIT_HASH}.zip
|
||||||
- run: unzip ${CONTRACTS_COMMIT_HASH}.zip -d testrpc_snapshot
|
- run: unzip ${CONTRACTS_COMMIT_HASH}.zip -d testrpc_snapshot
|
||||||
- run: node ./node_modules/lerna/bin/lerna.js bootstrap
|
- run: node ./node_modules/lerna/bin/lerna.js bootstrap
|
||||||
- run: yarn lerna:run build
|
- run: yarn build
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: repo-{{ .Environment.CIRCLE_SHA1 }}
|
key: repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
- ~/repo
|
- ~/repo
|
||||||
test-installation:
|
test-installation:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:6.12
|
- image: circleci/node:9
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
@@ -38,7 +38,7 @@ jobs:
|
|||||||
- run: yarn test:installation
|
- run: yarn test:installation
|
||||||
test-0xjs:
|
test-0xjs:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:6.12
|
- image: circleci/node:9
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
@@ -48,14 +48,14 @@ jobs:
|
|||||||
name: testrpc
|
name: testrpc
|
||||||
command: npm run testrpc -- --db testrpc_snapshot
|
command: npm run testrpc -- --db testrpc_snapshot
|
||||||
background: true
|
background: true
|
||||||
- run: yarn lerna:run --scope 0x.js test:circleci
|
- run: yarn wsrun test:circleci 0x.js
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
|
key: coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
- ~/repo/packages/0x.js/coverage/lcov.info
|
- ~/repo/packages/0x.js/coverage/lcov.info
|
||||||
test-contracts:
|
test-contracts:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:6.12
|
- image: circleci/node:9
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
@@ -65,14 +65,14 @@ jobs:
|
|||||||
name: testrpc
|
name: testrpc
|
||||||
command: npm run testrpc -- --db testrpc_snapshot
|
command: npm run testrpc -- --db testrpc_snapshot
|
||||||
background: true
|
background: true
|
||||||
- run: yarn lerna:run --scope contracts test:circleci
|
- run: yarn wsrun test:circleci contracts
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: coverage-contracts-{{ .Environment.CIRCLE_SHA1 }}
|
key: coverage-contracts-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
- ~/repo/packages/contracts/coverage/lcov.info
|
- ~/repo/packages/contracts/coverage/lcov.info
|
||||||
test-deployer:
|
test-sol-compiler:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:6.12
|
- image: circleci/node:9
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
@@ -82,14 +82,14 @@ jobs:
|
|||||||
name: testrpc
|
name: testrpc
|
||||||
command: npm run testrpc -- --db testrpc_snapshot
|
command: npm run testrpc -- --db testrpc_snapshot
|
||||||
background: true
|
background: true
|
||||||
- run: yarn lerna:run --scope @0xproject/deployer test:circleci
|
- run: yarn wsrun test:circleci @0xproject/sol-compiler
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: coverage-deployer-{{ .Environment.CIRCLE_SHA1 }}
|
key: coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
- ~/repo/packages/deployer/coverage/lcov.info
|
- ~/repo/packages/sol-compiler/coverage/lcov.info
|
||||||
test-rest:
|
test-rest:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:6.12
|
- image: circleci/node:9
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
@@ -99,7 +99,7 @@ jobs:
|
|||||||
name: testrpc
|
name: testrpc
|
||||||
command: npm run testrpc -- --db testrpc_snapshot
|
command: npm run testrpc -- --db testrpc_snapshot
|
||||||
background: true
|
background: true
|
||||||
- run: yarn lerna:run --ignore contracts --ignore 0x.js --ignore @0xproject/deployer test:circleci
|
- run: yarn wsrun test:circleci --exclude contracts --exclude 0x.js --exclude @0xproject/sol-compiler --stages --exclude-missing
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
|
key: coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
@@ -124,10 +124,14 @@ jobs:
|
|||||||
key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
|
key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
- ~/repo/packages/sol-cov/coverage/lcov.info
|
- ~/repo/packages/sol-cov/coverage/lcov.info
|
||||||
|
- save_cache:
|
||||||
|
key: coverage-metacoin-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
|
paths:
|
||||||
|
- ~/repo/packages/metacoin/coverage/lcov.info
|
||||||
lint:
|
lint:
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:6.12
|
- image: circleci/node:9
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
@@ -136,7 +140,7 @@ jobs:
|
|||||||
prettier:
|
prettier:
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:6.12
|
- image: circleci/node:9
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
@@ -144,7 +148,7 @@ jobs:
|
|||||||
- run: yarn prettier:ci
|
- run: yarn prettier:ci
|
||||||
submit-coverage:
|
submit-coverage:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:6.12
|
- image: circleci/node:9
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
@@ -173,26 +177,29 @@ jobs:
|
|||||||
- coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
|
- coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- coverage-deployer-{{ .Environment.CIRCLE_SHA1 }}
|
- coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
|
- coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- coverage-metacoin-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run: yarn report_coverage
|
- run: yarn report_coverage
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
main:
|
main:
|
||||||
jobs:
|
jobs:
|
||||||
- build
|
- build
|
||||||
# - test-installation:
|
- test-installation:
|
||||||
# requires:
|
requires:
|
||||||
# - build
|
- build
|
||||||
- test-0xjs:
|
- test-0xjs:
|
||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
- test-contracts:
|
- test-contracts:
|
||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
- test-deployer:
|
- test-sol-compiler:
|
||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
- test-rest:
|
- test-rest:
|
||||||
@@ -207,6 +214,6 @@ workflows:
|
|||||||
- submit-coverage:
|
- submit-coverage:
|
||||||
requires:
|
requires:
|
||||||
- test-0xjs
|
- test-0xjs
|
||||||
- test-deployer
|
- test-sol-compiler
|
||||||
- test-rest
|
- test-rest
|
||||||
- test-contracts
|
- test-contracts
|
||||||
|
21
.gitignore
vendored
21
.gitignore
vendored
@@ -70,19 +70,28 @@ TODO.md
|
|||||||
packages/website/public/bundle*
|
packages/website/public/bundle*
|
||||||
packages/react-docs/example/public/bundle*
|
packages/react-docs/example/public/bundle*
|
||||||
|
|
||||||
# generated binaries
|
# server cli
|
||||||
bin/
|
packages/testnet-faucets/server/
|
||||||
|
|
||||||
# generated contract artifacts
|
# generated contract artifacts/
|
||||||
packages/contracts/src/artifacts
|
packages/sol-cov/test/fixtures/artifacts/
|
||||||
|
packages/metacoin/artifacts/
|
||||||
|
packages/order-watcher/test/artifacts/
|
||||||
|
packages/contract-wrappers/test/artifacts/
|
||||||
|
|
||||||
# generated contract wrappers
|
# generated contract wrappers
|
||||||
packages/0x.js/src/contract_wrappers/generated/
|
packages/0x.js/src/contract_wrappers/generated/
|
||||||
packages/contracts/src/contract_wrappers/generated/
|
packages/contracts/src/contract_wrappers/generated/
|
||||||
|
packages/contract-wrappers/src/contract_wrappers/generated/
|
||||||
packages/metacoin/src/contract_wrappers
|
packages/metacoin/src/contract_wrappers
|
||||||
|
packages/fill-scenarios/src/generated_contract_wrappers/
|
||||||
|
packages/order-watcher/src/generated_contract_wrappers/
|
||||||
|
packages/migrations/src/contract_wrappers
|
||||||
|
|
||||||
# solc-bin in deployer
|
# solc-bin in sol-compiler
|
||||||
packages/deployer/solc_bin/
|
packages/sol-compiler/solc_bin/
|
||||||
|
|
||||||
# Monorepo scripts
|
# Monorepo scripts
|
||||||
packages/*/scripts/
|
packages/*/scripts/
|
||||||
|
|
||||||
|
ganache.log
|
||||||
|
@@ -1,5 +1,10 @@
|
|||||||
lib
|
lib
|
||||||
.nyc_output
|
.nyc_output
|
||||||
|
/packages/0x.js/test/artifacts
|
||||||
/packages/contracts/src/artifacts
|
/packages/contracts/src/artifacts
|
||||||
|
/packages/metacoin/artifacts
|
||||||
|
/packages/contract-wrappers/test/artifacts
|
||||||
|
/packages/order-watcher/test/artifacts
|
||||||
|
/packages/migrations/artifacts/1.0.0
|
||||||
package.json
|
package.json
|
||||||
scripts/postpublish_utils.js
|
scripts/postpublish_utils.js
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
* @abandeali1 @BMillman19 @dekz @fabioberger @LogvinovLeon @Recmo
|
|
46
CODE_OF_CONDUCT.md
Normal file
46
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at team@0xproject.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
|
[homepage]: http://contributor-covenant.org
|
||||||
|
[version]: http://contributor-covenant.org/version/1/4/
|
@@ -36,7 +36,6 @@
|
|||||||
|
|
||||||
* [ ] Change requires a change to the documentation.
|
* [ ] Change requires a change to the documentation.
|
||||||
* [ ] Added tests to cover my changes.
|
* [ ] Added tests to cover my changes.
|
||||||
* [ ] Added new entries to the relevant CHANGELOGs.
|
* [ ] Added new entries to the relevant CHANGELOG.jsons.
|
||||||
* [ ] Updated the new versions of the changed packages in the relevant CHANGELOGs.
|
|
||||||
* [ ] Labeled this PR with the 'WIP' label if it is a work in progress.
|
* [ ] Labeled this PR with the 'WIP' label if it is a work in progress.
|
||||||
* [ ] Labeled this PR with the labels corresponding to the changed package.
|
* [ ] Labeled this PR with the labels corresponding to the changed package.
|
||||||
|
134
README.md
134
README.md
@@ -14,31 +14,30 @@ This repository is a monorepo including the 0x protocol smart contracts and nume
|
|||||||
[](https://chat.0xproject.com)
|
[](https://chat.0xproject.com)
|
||||||
[](https://gitter.im/0xProject/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://gitter.im/0xProject/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
[](https://opensource.org/licenses/Apache-2.0)
|
[](https://opensource.org/licenses/Apache-2.0)
|
||||||
[](https://greenkeeper.io/)
|
|
||||||
|
|
||||||
### Published Packages
|
### Published Packages
|
||||||
|
|
||||||
| Package | Version | Description |
|
| Package | Version | Description |
|
||||||
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
|
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| [`0x.js`](/packages/0x.js) | [](https://www.npmjs.com/package/0x.js) | A Javascript library for interacting with the 0x protocol |
|
| [`0x.js`](/packages/0x.js) | [](https://www.npmjs.com/package/0x.js) | A Javascript library for interacting with the 0x protocol |
|
||||||
| [`@0xproject/abi-gen`](/packages/abi-gen) | [](https://www.npmjs.com/package/@0xproject/abi-gen) | Tool to generate TS wrappers from smart contract ABIs |
|
| [`@0xproject/abi-gen`](/packages/abi-gen) | [](https://www.npmjs.com/package/@0xproject/abi-gen) | Tool to generate TS wrappers from smart contract ABIs |
|
||||||
| [`@0xproject/assert`](/packages/assert) | [](https://www.npmjs.com/package/@0xproject/assert) | Type and schema assertions used by our packages |
|
| [`@0xproject/assert`](/packages/assert) | [](https://www.npmjs.com/package/@0xproject/assert) | Type and schema assertions used by our packages |
|
||||||
| [`@0xproject/base-contract`](/packages/base-contract) | [](https://www.npmjs.com/package/@0xproject/base-contract) | BaseContract used by auto-generated `abi-gen` wrapper contracts |
|
| [`@0xproject/base-contract`](/packages/base-contract) | [](https://www.npmjs.com/package/@0xproject/base-contract) | BaseContract used by auto-generated `abi-gen` wrapper contracts |
|
||||||
| [`@0xproject/connect`](/packages/connect) | [](https://www.npmjs.com/package/@0xproject/connect) | A Javascript library for interacting with the Standard Relayer API |
|
| [`@0xproject/connect`](/packages/connect) | [](https://www.npmjs.com/package/@0xproject/connect) | A Javascript library for interacting with the Standard Relayer API |
|
||||||
| [`@0xproject/deployer`](/packages/deployer) | [](https://www.npmjs.com/package/@0xproject/deployer) | Solidity project compiler and deployer framework |
|
| [`@0xproject/sol-compiler`](/packages/sol-compiler) | [](https://www.npmjs.com/package/@0xproject/sol-compiler) | A thin wrapper around Solc.js that outputs artifacts, resolves imports, only re-compiles when needed, and other niceties. |
|
||||||
| [`@0xproject/dev-utils`](/packages/dev-utils) | [](https://www.npmjs.com/package/@0xproject/dev-utils) | Dev utils to be shared across 0x projects and packages |
|
| [`@0xproject/dev-utils`](/packages/dev-utils) | [](https://www.npmjs.com/package/@0xproject/dev-utils) | Dev utils to be shared across 0x projects and packages |
|
||||||
| [`@0xproject/json-schemas`](/packages/json-schemas) | [](https://www.npmjs.com/package/@0xproject/json-schemas) | 0x-related json schemas |
|
| [`@0xproject/json-schemas`](/packages/json-schemas) | [](https://www.npmjs.com/package/@0xproject/json-schemas) | 0x-related json schemas |
|
||||||
| [`@0xproject/monorepo-scripts`](/packages/monorepo-scripts) | [](https://www.npmjs.com/package/@0xproject/monorepo-scripts) | Monorepo scripts |
|
| [`@0xproject/monorepo-scripts`](/packages/monorepo-scripts) | [](https://www.npmjs.com/package/@0xproject/monorepo-scripts) | Monorepo scripts |
|
||||||
| [`@0xproject/react-docs`](/packages/react-docs) | [](https://www.npmjs.com/package/@0xproject/react-docs) | React documentation component for rendering TypeDoc & Doxity generated JSON |
|
| [`@0xproject/react-docs`](/packages/react-docs) | [](https://www.npmjs.com/package/@0xproject/react-docs) | React documentation component for rendering TypeDoc & Doxity generated JSON |
|
||||||
| [`@0xproject/react-shared`](/packages/react-shared) | [](https://www.npmjs.com/package/@0xproject/react-shared) | 0x shared react components |
|
| [`@0xproject/react-shared`](/packages/react-shared) | [](https://www.npmjs.com/package/@0xproject/react-shared) | 0x shared react components |
|
||||||
| [`@0xproject/sra-report`](/packages/sra-report) | [](https://www.npmjs.com/package/@0xproject/sra-report) | Generate reports for standard relayer API compliance |
|
| [`@0xproject/sra-report`](/packages/sra-report) | [](https://www.npmjs.com/package/@0xproject/sra-report) | Generate reports for standard relayer API compliance |
|
||||||
| [`@0xproject/sol-cov`](/packages/sol-cov) | [](https://www.npmjs.com/package/@0xproject/sol-cov) | Solidity test coverage tool tool |
|
| [`@0xproject/sol-cov`](/packages/sol-cov) | [](https://www.npmjs.com/package/@0xproject/sol-cov) | Solidity test coverage tool |
|
||||||
| [`@0xproject/subproviders`](/packages/subproviders) | [](https://www.npmjs.com/package/@0xproject/subproviders) | Useful web3 subproviders (e.g LedgerSubprovider) |
|
| [`@0xproject/subproviders`](/packages/subproviders) | [](https://www.npmjs.com/package/@0xproject/subproviders) | Useful web3 subproviders (e.g LedgerSubprovider) |
|
||||||
| [`@0xproject/tslint-config`](/packages/tslint-config) | [](https://www.npmjs.com/package/@0xproject/tslint-config) | Custom 0x development TSLint rules |
|
| [`@0xproject/tslint-config`](/packages/tslint-config) | [](https://www.npmjs.com/package/@0xproject/tslint-config) | Custom 0x development TSLint rules |
|
||||||
| [`@0xproject/types`](/packages/types) | [](https://www.npmjs.com/package/@0xproject/types) | Shared type declarations |
|
| [`@0xproject/types`](/packages/types) | [](https://www.npmjs.com/package/@0xproject/types) | Shared type declarations |
|
||||||
| [`@0xproject/typescript-typings`](/packages/typescript-typings) | [](https://www.npmjs.com/package/@0xproject/typescript-typings) | Repository of types for external packages |
|
| [`@0xproject/typescript-typings`](/packages/typescript-typings) | [](https://www.npmjs.com/package/@0xproject/typescript-typings) | Repository of types for external packages |
|
||||||
| [`@0xproject/utils`](/packages/utils) | [](https://www.npmjs.com/package/@0xproject/utils) | Shared utilities |
|
| [`@0xproject/utils`](/packages/utils) | [](https://www.npmjs.com/package/@0xproject/utils) | Shared utilities |
|
||||||
| [`@0xproject/web3-wrapper`](/packages/web3-wrapper) | [](https://www.npmjs.com/package/@0xproject/web3-wrapper) | Web3 wrapper |
|
| [`@0xproject/web3-wrapper`](/packages/web3-wrapper) | [](https://www.npmjs.com/package/@0xproject/web3-wrapper) | Web3 wrapper |
|
||||||
|
|
||||||
### Private Packages
|
### Private Packages
|
||||||
|
|
||||||
@@ -57,12 +56,14 @@ Dedicated documentation pages:
|
|||||||
* [0x Connect](https://0xproject.com/docs/connect)
|
* [0x Connect](https://0xproject.com/docs/connect)
|
||||||
* [Smart contracts](https://0xproject.com/docs/contracts)
|
* [Smart contracts](https://0xproject.com/docs/contracts)
|
||||||
* [Subproviders](https://0xproject.com/docs/subproviders)
|
* [Subproviders](https://0xproject.com/docs/subproviders)
|
||||||
* [Deployer](https://0xproject.com/docs/deployer)
|
* [Sol Compiler](https://0xproject.com/docs/sol-compiler)
|
||||||
* [Web3-wrapper](https://0xproject.com/docs/web3-wrapper)
|
* [Web3-wrapper](https://0xproject.com/docs/web3-wrapper)
|
||||||
* [JSON-schemas](https://0xproject.com/docs/json-schemas)
|
* [JSON-schemas](https://0xproject.com/docs/json-schemas)
|
||||||
* [Sol-cov](https://0xproject.com/docs/sol-cov)
|
* [Sol-cov](https://0xproject.com/docs/sol-cov)
|
||||||
* [Standard Relayer API](https://github.com/0xProject/standard-relayer-api/blob/master/README.md)
|
* [Standard Relayer API](https://github.com/0xProject/standard-relayer-api/blob/master/README.md)
|
||||||
|
|
||||||
|
Node version >= 6.12 is required.
|
||||||
|
|
||||||
Most of the packages require additional typings for external dependencies.
|
Most of the packages require additional typings for external dependencies.
|
||||||
You can include those by prepending @0xproject/typescript-typings package to your [`typeRoots`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) config.
|
You can include those by prepending @0xproject/typescript-typings package to your [`typeRoots`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) config.
|
||||||
|
|
||||||
@@ -74,7 +75,7 @@ You can include those by prepending @0xproject/typescript-typings package to you
|
|||||||
|
|
||||||
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
|
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
|
||||||
|
|
||||||
Please read our [contribution guidelines](./CONTRIBUTING.md) before getting started.
|
#### Read our [contribution guidelines](./CONTRIBUTING.md).
|
||||||
|
|
||||||
### Install dependencies
|
### Install dependencies
|
||||||
|
|
||||||
@@ -92,50 +93,87 @@ yarn install
|
|||||||
|
|
||||||
### Build
|
### Build
|
||||||
|
|
||||||
Build all packages. You need to do this before working on any given package. Although these packages
|
To build all packages:
|
||||||
as independent, when run from within the monorepo, they are internally symlinked, to make development
|
|
||||||
easier. You can change several packages and run the changes without publishing them first to NPM. When
|
|
||||||
running `rebuild`, Lerna will figure out the dependency order of all the packages, and build them in
|
|
||||||
this order.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn lerna:rebuild
|
yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
Or continuously rebuild on change:
|
To build a specific package:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn dev
|
PKG=@0xproject/web3-wrapper yarn build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Watch
|
||||||
|
|
||||||
|
To re-build all packages on change:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn watch
|
||||||
|
```
|
||||||
|
|
||||||
|
To watch a specific package and all it's dependent packages:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PKG=[NPM_PACKAGE_NAME] yarn watch
|
||||||
|
|
||||||
|
e.g
|
||||||
|
PKG=@0xproject/web3-wrapper yarn watch
|
||||||
|
```
|
||||||
|
|
||||||
|
### Clean
|
||||||
|
|
||||||
|
Clean all packages:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn clean
|
||||||
|
```
|
||||||
|
|
||||||
|
Clean a specific package
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PKG=0x.js yarn clean
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rebuild
|
||||||
|
|
||||||
|
To re-build (clean & build) all packages:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn rebuild
|
||||||
|
```
|
||||||
|
|
||||||
|
To re-build (clean & build) a specific package & it's deps:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PKG=0x.js yarn rebuild
|
||||||
```
|
```
|
||||||
|
|
||||||
### Lint
|
### Lint
|
||||||
|
|
||||||
Lint all packages
|
Lint all packages:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn lerna:run lint
|
yarn lint
|
||||||
|
```
|
||||||
|
|
||||||
|
Lint a specific package:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PKG=0x.js yarn lint
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run Tests
|
### Run Tests
|
||||||
|
|
||||||
Before running the tests, you will need to spin up a [TestRPC](https://www.npmjs.com/package/ethereumjs-testrpc) instance and deploy all the 0x smart contracts.
|
Run all tests:
|
||||||
|
|
||||||
In a separate terminal, start TestRPC (a convenience command is provided as part of this repo)
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn testrpc
|
yarn test
|
||||||
```
|
```
|
||||||
|
|
||||||
Then in your main terminal run
|
Run a specific package's test:
|
||||||
|
|
||||||
```
|
|
||||||
cd packages/contracts
|
|
||||||
yarn migrate
|
|
||||||
cd ..
|
|
||||||
```
|
|
||||||
|
|
||||||
And finally from the root project directory run
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn lerna:run test
|
PKG=@0xproject/web3-wrapper yarn test
|
||||||
```
|
```
|
||||||
|
41
package.json
41
package.json
@@ -1,37 +1,46 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "0x-monorepo",
|
"name": "0x-monorepo",
|
||||||
|
"engines": {
|
||||||
|
"node" : ">=6.12"
|
||||||
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "lerna run --parallel build:watch",
|
"ganache": "ganache-cli -p 8545 --networkId 50 -m \"${npm_package_config_mnemonic}\"",
|
||||||
"testrpc": "testrpc -p 8545 --networkId 50 -m \"${npm_package_config_mnemonic}\"",
|
|
||||||
"prettier": "prettier --write '**/*.{ts,tsx,json,md}' --config .prettierrc",
|
"prettier": "prettier --write '**/*.{ts,tsx,json,md}' --config .prettierrc",
|
||||||
"prettier:ci": "prettier --list-different '**/*.{ts,tsx,json,md}' --config .prettierrc",
|
"prettier:ci": "prettier --list-different '**/*.{ts,tsx,json,md}' --config .prettierrc",
|
||||||
"report_coverage": "lcov-result-merger 'packages/*/coverage/lcov.info' | coveralls",
|
"report_coverage": "lcov-result-merger 'packages/*/coverage/lcov.info' | coveralls",
|
||||||
"test:installation": "node ./packages/monorepo-scripts/lib/test_installation.js",
|
"test:installation": "node ./packages/monorepo-scripts/lib/test_installation.js",
|
||||||
"lerna:install": "yarn install",
|
"run:publish": "run-s install:all build:monorepo_scripts script:prepublish_checks rebuild script:publish",
|
||||||
"lerna:run": "lerna run",
|
"run:publish:dry": "run-s install:all build:monorepo_scripts script:prepublish_checks rebuild script:publish:dry",
|
||||||
"lerna:clean": "lerna run clean",
|
"script:prepublish_checks": "node ./packages/monorepo-scripts/lib/prepublish_checks.js",
|
||||||
"lerna:build": "lerna run build",
|
|
||||||
"lerna:rebuild": "run-s lerna:clean lerna:build",
|
|
||||||
"lerna:publish": "run-s lerna:install lerna:rebuild script:publish",
|
|
||||||
"lerna:publish:dry": "run-s lerna:install lerna:rebuild script:publish:dry",
|
|
||||||
"lerna:stage_docs": "lerna run docs:stage",
|
|
||||||
"script:publish": "node ./packages/monorepo-scripts/lib/publish.js",
|
"script:publish": "node ./packages/monorepo-scripts/lib/publish.js",
|
||||||
"script:publish:dry": "IS_DRY_RUN=true yarn script:publish"
|
"script:publish:dry": "IS_DRY_RUN=true yarn script:publish",
|
||||||
|
"install:all": "yarn install",
|
||||||
|
"wsrun": "wsrun",
|
||||||
|
"lerna:run": "lerna run",
|
||||||
|
"watch": "wsrun watch $PKG --fast-exit -r --stages --done-criteria='complete|successfully'",
|
||||||
|
"build": "wsrun build $PKG --fast-exit -r --stages",
|
||||||
|
"build:monorepo_scripts": "PKG=@0xproject/monorepo-scripts yarn build",
|
||||||
|
"clean": "wsrun clean $PKG --fast-exit -r --parallel",
|
||||||
|
"rebuild": "run-s clean build",
|
||||||
|
"test": "wsrun test $PKG --serial --exclude-missing",
|
||||||
|
"stage_docs": "wsrun docs:stage $PKG --parallel --exclude-missing",
|
||||||
|
"lint": "wsrun lint $PKG --parallel --exclude-missing"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic"
|
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"async-child-process": "^1.1.1",
|
"async-child-process": "1.1.1",
|
||||||
"coveralls": "^3.0.0",
|
"coveralls": "^3.0.0",
|
||||||
"ethereumjs-testrpc": "^6.0.3",
|
"ganache-cli": "^6.1.0",
|
||||||
"lcov-result-merger": "^2.0.0",
|
"lcov-result-merger": "^3.0.0",
|
||||||
"lerna": "^2.5.1",
|
"lerna": "^2.5.1",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "4.1.2",
|
||||||
"prettier": "^1.11.1"
|
"prettier": "1.12.1",
|
||||||
|
"wsrun": "^2.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,3 +9,5 @@ test/
|
|||||||
/generated_docs/
|
/generated_docs/
|
||||||
/scripts/
|
/scripts/
|
||||||
/lib/src/monorepo_scripts/
|
/lib/src/monorepo_scripts/
|
||||||
|
/lib/test/
|
||||||
|
ganache.log
|
||||||
|
@@ -1,10 +1,146 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"timestamp": 1531149657,
|
||||||
|
"version": "0.38.5",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1529397769,
|
||||||
|
"version": "0.38.4",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1527617805,
|
||||||
|
"version": "0.38.3",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1527617227,
|
||||||
|
"version": "0.38.2",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1527616612,
|
||||||
|
"version": "0.38.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "0.38.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Renamed createOrderStateWatcher to createOrderWatcherAsync since it is now async",
|
||||||
|
"pr": 579
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Renamed ZeroExError to ContractWrappersErrors since they now lives in the @0xproject/contract-wrappers subpackage",
|
||||||
|
"pr": 579
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1527008270
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1525477860,
|
||||||
|
"version": "0.37.2",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1525453812,
|
||||||
|
"version": "0.37.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "0.37.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Fixed expiration watcher comparator to handle orders with equal expiration times",
|
||||||
|
"pr": 526
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Update Web3 Provider Engine to 14.0.4",
|
||||||
|
"pr": 555
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Add `zeroEx.getProvider()`",
|
||||||
|
"pr": 559
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Move `ZeroExError.InvalidSignature` to `@0xproject/order-utils` `OrderError.InvalidSignature`",
|
||||||
|
"pr": 559
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1525428773
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "0.36.3",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Move @0xproject/migrations to devDependencies"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1524079658
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1524073495,
|
||||||
|
"version": "0.36.2",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "0.36.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Internal changes and refactoring"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Fix redundant expired order removal bug",
|
||||||
|
"pr": 527
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1524044013
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "0.36.0",
|
"version": "0.36.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
{
|
{
|
||||||
"note": "Moved Web3.Provider to `@0xproject/types:Provider`",
|
"note": "Moved Web3.Provider to `@0xproject/types:Provider`",
|
||||||
"pr": 501
|
"pr": 501
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Add `zeroEx.exchange.getOrderStateAsync` to allow obtaining current OrderState for a signedOrder",
|
||||||
|
"pr": 510
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"timestamp": 1523462196
|
"timestamp": 1523462196
|
||||||
@@ -14,7 +150,7 @@
|
|||||||
"changes": [
|
"changes": [
|
||||||
{
|
{
|
||||||
"note":
|
"note":
|
||||||
"Removed `ZeroExError.TransactionMiningTimeout` and moved it to '@0xproject/web3_wrapper' `Web3WrapperErrors.TransactionMiningTimeout`",
|
"Removed `ZeroExError.TransactionMiningTimeout` and moved it to '@0xproject/web3-wrapper' `Web3WrapperErrors.TransactionMiningTimeout`",
|
||||||
"pr": 485
|
"pr": 485
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@@ -5,13 +5,67 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v0.38.5 - _July 9, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.38.4 - _June 19, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.38.3 - _May 29, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.38.2 - _May 29, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.38.1 - _May 29, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.38.0 - _May 22, 2018_
|
||||||
|
|
||||||
|
* Renamed createOrderStateWatcher to createOrderWatcherAsync since it is now async (#579)
|
||||||
|
* Renamed ZeroExError to ContractWrappersErrors since they now lives in the @0xproject/contract-wrappers subpackage (#579)
|
||||||
|
|
||||||
|
## v0.37.2 - _May 5, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.37.1 - _May 4, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.37.0 - _May 4, 2018_
|
||||||
|
|
||||||
|
* Fixed expiration watcher comparator to handle orders with equal expiration times (#526)
|
||||||
|
* Update Web3 Provider Engine to 14.0.4 (#555)
|
||||||
|
* Add `zeroEx.getProvider()` (#559)
|
||||||
|
* Move `ZeroExError.InvalidSignature` to `@0xproject/order-utils` `OrderError.InvalidSignature` (#559)
|
||||||
|
|
||||||
|
## v0.36.3 - _April 18, 2018_
|
||||||
|
|
||||||
|
* Move @0xproject/migrations to devDependencies
|
||||||
|
|
||||||
|
## v0.36.2 - _April 18, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.36.1 - _April 18, 2018_
|
||||||
|
|
||||||
|
* Internal changes and refactoring
|
||||||
|
* Fix redundant expired order removal bug (#527)
|
||||||
|
|
||||||
## v0.36.0 - _April 11, 2018_
|
## v0.36.0 - _April 11, 2018_
|
||||||
|
|
||||||
* Moved Web3.Provider to `@0xproject/types:Provider` (#501)
|
* Moved Web3.Provider to `@0xproject/types:Provider` (#501)
|
||||||
|
* Add `zeroEx.exchange.getOrderStateAsync` to allow obtaining current OrderState for a signedOrder (#510)
|
||||||
|
|
||||||
## v0.35.0 - _April 2, 2018_
|
## v0.35.0 - _April 2, 2018_
|
||||||
|
|
||||||
* Removed `ZeroExError.TransactionMiningTimeout` and moved it to '@0xproject/web3_wrapper' `Web3WrapperErrors.TransactionMiningTimeout` (#485)
|
* Removed `ZeroExError.TransactionMiningTimeout` and moved it to '@0xproject/web3-wrapper' `Web3WrapperErrors.TransactionMiningTimeout` (#485)
|
||||||
|
|
||||||
## v0.34.0 - _April 2, 2018_
|
## v0.34.0 - _April 2, 2018_
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
A TypeScript/Javascript library for interacting with the 0x protocol.
|
A TypeScript/Javascript library for interacting with the 0x protocol.
|
||||||
|
|
||||||
### Read the [Documentation](https://0xproject.com/docs/0xjs).
|
### Read the [Documentation](https://0xproject.com/docs/0x.js).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ Download the UMD module from our [releases page](https://github.com/0xProject/0x
|
|||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
|
We strongly recommend that the community help us make improvements and determine the future direction of 0x protocol. To report bugs within this package, please create an issue in this repository.
|
||||||
|
|
||||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
||||||
|
|
||||||
@@ -64,28 +64,16 @@ yarn install
|
|||||||
|
|
||||||
### Build
|
### Build
|
||||||
|
|
||||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn lerna:rebuild
|
PKG=0x.js yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
Or continuously rebuild on change:
|
Or continuously rebuild on change:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn dev
|
PKG=0x.js yarn watch
|
||||||
```
|
|
||||||
|
|
||||||
You can also build this specific package by running the following from within its directory:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
or continuously rebuild on change:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn build:watch
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Clean
|
### Clean
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "0x.js",
|
"name": "0x.js",
|
||||||
"version": "0.36.0",
|
"version": "0.38.5",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.12"
|
||||||
|
},
|
||||||
"description": "A javascript library for interacting with the 0x protocol",
|
"description": "A javascript library for interacting with the 0x protocol",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"0x.js",
|
"0x.js",
|
||||||
@@ -12,28 +15,27 @@
|
|||||||
"main": "lib/src/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:watch": "tsc -w",
|
"watch": "tsc -w",
|
||||||
"prebuild": "run-s clean generate_contract_wrappers",
|
"prebuild": "run-s clean generate_contract_wrappers",
|
||||||
"build": "run-p build:umd:prod build:commonjs; exit 0;",
|
"build": "run-p build:umd:prod build:commonjs; exit 0;",
|
||||||
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
|
"generate_contract_wrappers": "abi-gen --abis 'src/compact_artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
|
||||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
"lint": "tslint --project .",
|
||||||
"test:circleci": "run-s test:coverage",
|
"test:circleci": "run-s test:coverage",
|
||||||
"test": "run-s clean test:commonjs",
|
"test": "run-s clean test:commonjs",
|
||||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||||
"update_contracts": "for i in ${npm_package_config_artifacts}; do copyfiles -u 4 ../contracts/build/contracts/$i.json ../0x.js/src/artifacts; done;",
|
"clean": "shx rm -rf _bundles lib test_temp scripts src/contract_wrappers/generated",
|
||||||
"clean": "shx rm -rf _bundles lib test_temp scripts",
|
|
||||||
"build:umd:prod": "NODE_ENV=production webpack",
|
"build:umd:prod": "NODE_ENV=production webpack",
|
||||||
"build:commonjs": "tsc && copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
"build:commonjs": "tsc && copyfiles -u 2 './src/compact_artifacts/**/*.json' ./lib/src/compact_artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||||
"test:commonjs": "run-s build:commonjs run_mocha",
|
"test:commonjs": "run-s build:commonjs run_mocha",
|
||||||
"run_mocha": "mocha lib/test/**/*_test.js --timeout 10000 --bail --exit",
|
"run_mocha": "mocha lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
|
||||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
|
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
|
||||||
"docs:stage": "yarn build && node ./scripts/stage_docs.js",
|
"docs:stage": "node scripts/stage_docs.js",
|
||||||
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
|
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
|
||||||
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
|
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"artifacts": "TokenTransferProxy Exchange TokenRegistry Token EtherToken",
|
"compact_artifacts": "Exchange DummyToken ZRXToken Token EtherToken TokenTransferProxy TokenRegistry",
|
||||||
"postpublish": {
|
"postpublish": {
|
||||||
"assets": [
|
"assets": [
|
||||||
"packages/0x.js/_bundles/index.js",
|
"packages/0x.js/_bundles/index.js",
|
||||||
@@ -42,6 +44,13 @@
|
|||||||
"docPublishConfigs": {
|
"docPublishConfigs": {
|
||||||
"extraFileIncludes": [
|
"extraFileIncludes": [
|
||||||
"../types/src/index.ts",
|
"../types/src/index.ts",
|
||||||
|
"../contract-wrappers/src/types.ts",
|
||||||
|
"../contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts",
|
||||||
|
"../contract-wrappers/src/contract_wrappers/exchange_wrapper.ts",
|
||||||
|
"../contract-wrappers/src/contract_wrappers/token_registry_wrapper.ts",
|
||||||
|
"../contract-wrappers/src/contract_wrappers/token_transfer_proxy_wrapper.ts",
|
||||||
|
"../contract-wrappers/src/contract_wrappers/token_wrapper.ts",
|
||||||
|
"../order-watcher/src/order_watcher/order_watcher.ts",
|
||||||
"./src/contract_wrappers/generated/ether_token.ts",
|
"./src/contract_wrappers/generated/ether_token.ts",
|
||||||
"./src/contract_wrappers/generated/token.ts",
|
"./src/contract_wrappers/generated/token.ts",
|
||||||
"./src/contract_wrappers/generated/exchange.ts"
|
"./src/contract_wrappers/generated/exchange.ts"
|
||||||
@@ -56,60 +65,50 @@
|
|||||||
"url": "https://github.com/0xProject/0x-monorepo"
|
"url": "https://github.com/0xProject/0x-monorepo"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"engines": {
|
|
||||||
"node": ">=6.0.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/dev-utils": "^0.3.5",
|
"@0xproject/abi-gen": "^0.3.3",
|
||||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
"@0xproject/dev-utils": "^0.4.5",
|
||||||
"@0xproject/tslint-config": "^0.4.15",
|
"@0xproject/migrations": "^0.0.9",
|
||||||
"@types/bintrees": "^1.0.2",
|
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||||
|
"@0xproject/tslint-config": "^0.4.21",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/mocha": "^2.2.42",
|
"@types/mocha": "2.2.48",
|
||||||
"@types/node": "^8.0.53",
|
"@types/node": "9.6.0",
|
||||||
"@types/request": "2.47.0",
|
"@types/sinon": "2.3.7",
|
||||||
"@types/sinon": "^2.2.2",
|
"awesome-typescript-loader": "3.5.0",
|
||||||
"@types/uuid": "^3.4.2",
|
"chai": "4.1.2",
|
||||||
"awesome-typescript-loader": "^3.1.3",
|
"chai-as-promised": "7.1.1",
|
||||||
"chai": "^4.0.1",
|
"chai-bignumber": "2.0.1",
|
||||||
"chai-as-promised": "^7.1.0",
|
"copyfiles": "1.2.0",
|
||||||
"chai-bignumber": "^2.0.1",
|
"dirty-chai": "2.0.1",
|
||||||
"copyfiles": "^1.2.0",
|
"json-loader": "0.5.7",
|
||||||
"dirty-chai": "^2.0.1",
|
"make-promises-safe": "1.1.0",
|
||||||
"json-loader": "^0.5.4",
|
"mocha": "4.1.0",
|
||||||
"mocha": "^4.0.1",
|
"npm-run-all": "4.1.2",
|
||||||
"npm-run-all": "^4.1.2",
|
"nyc": "11.6.0",
|
||||||
"nyc": "^11.0.1",
|
"opn-cli": "3.1.0",
|
||||||
"opn-cli": "^3.1.0",
|
"prettier": "1.12.1",
|
||||||
"prettier": "^1.11.1",
|
"shx": "0.2.2",
|
||||||
"request": "^2.81.0",
|
"sinon": "4.4.9",
|
||||||
"shx": "^0.2.2",
|
"source-map-support": "0.5.4",
|
||||||
"sinon": "^4.0.0",
|
|
||||||
"source-map-support": "^0.5.0",
|
|
||||||
"truffle-hdwallet-provider": "^0.0.3",
|
|
||||||
"tslint": "5.8.0",
|
"tslint": "5.8.0",
|
||||||
"typedoc": "0xProject/typedoc",
|
"typedoc": "0xProject/typedoc",
|
||||||
"typescript": "2.7.1",
|
"typescript": "2.7.1",
|
||||||
"webpack": "^3.1.0"
|
"webpack": "3.11.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/assert": "^0.2.6",
|
"@0xproject/assert": "^0.2.13",
|
||||||
"@0xproject/base-contract": "^0.2.0",
|
"@0xproject/base-contract": "^0.3.5",
|
||||||
"@0xproject/json-schemas": "^0.7.20",
|
"@0xproject/contract-wrappers": "^0.1.0",
|
||||||
"@0xproject/types": "^0.6.0",
|
"@0xproject/order-utils": "^0.0.8",
|
||||||
"@0xproject/typescript-typings": "^0.1.0",
|
"@0xproject/order-watcher": "^0.0.7",
|
||||||
"@0xproject/utils": "^0.5.1",
|
"@0xproject/sol-compiler": "^0.5.3",
|
||||||
"@0xproject/web3-wrapper": "^0.6.0",
|
"@0xproject/types": "^0.8.2",
|
||||||
"bintrees": "^1.0.2",
|
"@0xproject/typescript-typings": "^0.4.2",
|
||||||
"bn.js": "^4.11.8",
|
"@0xproject/utils": "^0.7.2",
|
||||||
"ethereumjs-abi": "^0.6.4",
|
"@0xproject/web3-wrapper": "^0.7.2",
|
||||||
"ethereumjs-blockstream": "^2.0.6",
|
"ethers": "3.0.22",
|
||||||
"ethereumjs-util": "^5.1.1",
|
"lodash": "4.17.10"
|
||||||
"ethers-contracts": "^2.2.1",
|
|
||||||
"js-sha3": "^0.7.0",
|
|
||||||
"lodash": "^4.17.4",
|
|
||||||
"uuid": "^3.1.0",
|
|
||||||
"web3": "^0.20.0"
|
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
@@ -1,26 +1,27 @@
|
|||||||
import { schemas, SchemaValidator } from '@0xproject/json-schemas';
|
import { assert } from '@0xproject/assert';
|
||||||
|
import {
|
||||||
|
ContractWrappers,
|
||||||
|
ContractWrappersConfig,
|
||||||
|
EtherTokenWrapper,
|
||||||
|
ExchangeWrapper,
|
||||||
|
TokenRegistryWrapper,
|
||||||
|
TokenTransferProxyWrapper,
|
||||||
|
TokenWrapper,
|
||||||
|
} from '@0xproject/contract-wrappers';
|
||||||
|
import {
|
||||||
|
generatePseudoRandomSalt,
|
||||||
|
getOrderHashHex,
|
||||||
|
isValidOrderHash,
|
||||||
|
isValidSignature,
|
||||||
|
signOrderHashAsync,
|
||||||
|
} from '@0xproject/order-utils';
|
||||||
|
import { OrderWatcher, OrderWatcherConfig } from '@0xproject/order-watcher';
|
||||||
import { ECSignature, Order, Provider, SignedOrder, TransactionReceiptWithDecodedLogs } from '@0xproject/types';
|
import { ECSignature, Order, Provider, SignedOrder, TransactionReceiptWithDecodedLogs } from '@0xproject/types';
|
||||||
import { AbiDecoder, BigNumber, intervalUtils } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import * as ethUtil from 'ethereumjs-util';
|
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
import { EtherTokenWrapper } from './contract_wrappers/ether_token_wrapper';
|
|
||||||
import { ExchangeWrapper } from './contract_wrappers/exchange_wrapper';
|
|
||||||
import { TokenRegistryWrapper } from './contract_wrappers/token_registry_wrapper';
|
|
||||||
import { TokenTransferProxyWrapper } from './contract_wrappers/token_transfer_proxy_wrapper';
|
|
||||||
import { TokenWrapper } from './contract_wrappers/token_wrapper';
|
|
||||||
import { OrderStateWatcher } from './order_watcher/order_state_watcher';
|
|
||||||
import { zeroExConfigSchema } from './schemas/zero_ex_config_schema';
|
|
||||||
import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema';
|
|
||||||
import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema';
|
|
||||||
import { OrderStateWatcherConfig, ZeroExConfig, ZeroExError } from './types';
|
|
||||||
import { assert } from './utils/assert';
|
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
import { decorators } from './utils/decorators';
|
|
||||||
import { signatureUtils } from './utils/signature_utils';
|
|
||||||
import { utils } from './utils/utils';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ZeroEx class is the single entry-point into the 0x.js library. It contains all of the library's functionality
|
* The ZeroEx class is the single entry-point into the 0x.js library. It contains all of the library's functionality
|
||||||
@@ -33,7 +34,6 @@ export class ZeroEx {
|
|||||||
* this constant for your convenience.
|
* this constant for your convenience.
|
||||||
*/
|
*/
|
||||||
public static NULL_ADDRESS = constants.NULL_ADDRESS;
|
public static NULL_ADDRESS = constants.NULL_ADDRESS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An instance of the ExchangeWrapper class containing methods for interacting with the 0x Exchange smart contract.
|
* An instance of the ExchangeWrapper class containing methods for interacting with the 0x Exchange smart contract.
|
||||||
*/
|
*/
|
||||||
@@ -57,7 +57,16 @@ export class ZeroEx {
|
|||||||
* tokenTransferProxy smart contract.
|
* tokenTransferProxy smart contract.
|
||||||
*/
|
*/
|
||||||
public proxy: TokenTransferProxyWrapper;
|
public proxy: TokenTransferProxyWrapper;
|
||||||
private _web3Wrapper: Web3Wrapper;
|
private _contractWrappers: ContractWrappers;
|
||||||
|
/**
|
||||||
|
* Generates a pseudo-random 256-bit salt.
|
||||||
|
* The salt can be included in a 0x order, ensuring that the order generates a unique orderHash
|
||||||
|
* and will not collide with other outstanding orders that are identical in all other parameters.
|
||||||
|
* @return A pseudo-random 256-bit number that can be used as a salt.
|
||||||
|
*/
|
||||||
|
public static generatePseudoRandomSalt(): BigNumber {
|
||||||
|
return generatePseudoRandomSalt();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Verifies that the elliptic curve signature `signature` was generated
|
* Verifies that the elliptic curve signature `signature` was generated
|
||||||
* by signing `data` with the private key corresponding to the `signerAddress` address.
|
* by signing `data` with the private key corresponding to the `signerAddress` address.
|
||||||
@@ -67,27 +76,15 @@ export class ZeroEx {
|
|||||||
* @return Whether the signature is valid for the supplied signerAddress and data.
|
* @return Whether the signature is valid for the supplied signerAddress and data.
|
||||||
*/
|
*/
|
||||||
public static isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean {
|
public static isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean {
|
||||||
assert.isHexString('data', data);
|
return isValidSignature(data, signature, signerAddress);
|
||||||
assert.doesConformToSchema('signature', signature, schemas.ecSignatureSchema);
|
|
||||||
assert.isETHAddressHex('signerAddress', signerAddress);
|
|
||||||
const normalizedSignerAddress = signerAddress.toLowerCase();
|
|
||||||
|
|
||||||
const isValidSignature = signatureUtils.isValidSignature(data, signature, normalizedSignerAddress);
|
|
||||||
return isValidSignature;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Generates a pseudo-random 256-bit salt.
|
* Computes the orderHash for a supplied order.
|
||||||
* The salt can be included in a 0x order, ensuring that the order generates a unique orderHash
|
* @param order An object that conforms to the Order or SignedOrder interface definitions.
|
||||||
* and will not collide with other outstanding orders that are identical in all other parameters.
|
* @return The resulting orderHash from hashing the supplied order.
|
||||||
* @return A pseudo-random 256-bit number that can be used as a salt.
|
|
||||||
*/
|
*/
|
||||||
public static generatePseudoRandomSalt(): BigNumber {
|
public static getOrderHashHex(order: Order | SignedOrder): string {
|
||||||
// BigNumber.random returns a pseudo-random number between 0 & 1 with a passed in number of decimal places.
|
return getOrderHashHex(order);
|
||||||
// Source: https://mikemcl.github.io/bignumber.js/#random
|
|
||||||
const randomNumber = BigNumber.random(constants.MAX_DIGITS_IN_UNSIGNED_256_INT);
|
|
||||||
const factor = new BigNumber(10).pow(constants.MAX_DIGITS_IN_UNSIGNED_256_INT - 1);
|
|
||||||
const salt = randomNumber.times(factor).round();
|
|
||||||
return salt;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Checks if the supplied hex encoded order hash is valid.
|
* Checks if the supplied hex encoded order hash is valid.
|
||||||
@@ -97,12 +94,7 @@ export class ZeroEx {
|
|||||||
* @return Whether the supplied orderHash has the expected format.
|
* @return Whether the supplied orderHash has the expected format.
|
||||||
*/
|
*/
|
||||||
public static isValidOrderHash(orderHash: string): boolean {
|
public static isValidOrderHash(orderHash: string): boolean {
|
||||||
// Since this method can be called to check if any arbitrary string conforms to an orderHash's
|
return isValidOrderHash(orderHash);
|
||||||
// format, we only assert that we were indeed passed a string.
|
|
||||||
assert.isString('orderHash', orderHash);
|
|
||||||
const schemaValidator = new SchemaValidator();
|
|
||||||
const isValidOrderHash = schemaValidator.validate(orderHash, schemas.orderHashSchema).valid;
|
|
||||||
return isValidOrderHash;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* A unit amount is defined as the amount of a token above the specified decimal places (integer part).
|
* A unit amount is defined as the amount of a token above the specified decimal places (integer part).
|
||||||
@@ -132,17 +124,6 @@ export class ZeroEx {
|
|||||||
const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amount, decimals);
|
const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amount, decimals);
|
||||||
return baseUnitAmount;
|
return baseUnitAmount;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Computes the orderHash for a supplied order.
|
|
||||||
* @param order An object that conforms to the Order or SignedOrder interface definitions.
|
|
||||||
* @return The resulting orderHash from hashing the supplied order.
|
|
||||||
*/
|
|
||||||
@decorators.syncZeroExErrorHandler
|
|
||||||
public static getOrderHashHex(order: Order | SignedOrder): string {
|
|
||||||
assert.doesConformToSchema('order', order, schemas.orderSchema);
|
|
||||||
const orderHashHex = utils.getOrderHashHex(order);
|
|
||||||
return orderHashHex;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new ZeroEx instance that provides the public interface to the 0x.js library.
|
* Instantiates a new ZeroEx instance that provides the public interface to the 0x.js library.
|
||||||
* @param provider The Provider instance you would like the 0x.js library to use for interacting with
|
* @param provider The Provider instance you would like the 0x.js library to use for interacting with
|
||||||
@@ -150,40 +131,15 @@ export class ZeroEx {
|
|||||||
* @param config The configuration object. Look up the type for the description.
|
* @param config The configuration object. Look up the type for the description.
|
||||||
* @return An instance of the 0x.js ZeroEx class.
|
* @return An instance of the 0x.js ZeroEx class.
|
||||||
*/
|
*/
|
||||||
constructor(provider: Provider, config: ZeroExConfig) {
|
constructor(provider: Provider, config: ContractWrappersConfig) {
|
||||||
assert.isWeb3Provider('provider', provider);
|
assert.isWeb3Provider('provider', provider);
|
||||||
assert.doesConformToSchema('config', config, zeroExConfigSchema, [
|
this._contractWrappers = new ContractWrappers(provider, config);
|
||||||
zeroExPrivateNetworkConfigSchema,
|
|
||||||
zeroExPublicNetworkConfigSchema,
|
this.proxy = this._contractWrappers.proxy;
|
||||||
]);
|
this.token = this._contractWrappers.token;
|
||||||
const artifactJSONs = _.values(artifacts);
|
this.exchange = this._contractWrappers.exchange;
|
||||||
const abiArrays = _.map(artifactJSONs, artifact => artifact.abi);
|
this.tokenRegistry = this._contractWrappers.tokenRegistry;
|
||||||
const defaults = {
|
this.etherToken = this._contractWrappers.etherToken;
|
||||||
gasPrice: config.gasPrice,
|
|
||||||
};
|
|
||||||
this._web3Wrapper = new Web3Wrapper(provider, defaults);
|
|
||||||
_.forEach(abiArrays, abi => {
|
|
||||||
this._web3Wrapper.abiDecoder.addABI(abi);
|
|
||||||
});
|
|
||||||
this.proxy = new TokenTransferProxyWrapper(
|
|
||||||
this._web3Wrapper,
|
|
||||||
config.networkId,
|
|
||||||
config.tokenTransferProxyContractAddress,
|
|
||||||
);
|
|
||||||
this.token = new TokenWrapper(this._web3Wrapper, config.networkId, this.proxy);
|
|
||||||
this.exchange = new ExchangeWrapper(
|
|
||||||
this._web3Wrapper,
|
|
||||||
config.networkId,
|
|
||||||
this.token,
|
|
||||||
config.exchangeContractAddress,
|
|
||||||
config.zrxContractAddress,
|
|
||||||
);
|
|
||||||
this.tokenRegistry = new TokenRegistryWrapper(
|
|
||||||
this._web3Wrapper,
|
|
||||||
config.networkId,
|
|
||||||
config.tokenRegistryContractAddress,
|
|
||||||
);
|
|
||||||
this.etherToken = new EtherTokenWrapper(this._web3Wrapper, config.networkId, this.token);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sets a new web3 provider for 0x.js. Updating the provider will stop all
|
* Sets a new web3 provider for 0x.js. Updating the provider will stop all
|
||||||
@@ -192,24 +148,23 @@ export class ZeroEx {
|
|||||||
* @param networkId The id of the network your provider is connected to
|
* @param networkId The id of the network your provider is connected to
|
||||||
*/
|
*/
|
||||||
public setProvider(provider: Provider, networkId: number): void {
|
public setProvider(provider: Provider, networkId: number): void {
|
||||||
this._web3Wrapper.setProvider(provider);
|
this._contractWrappers.setProvider(provider, networkId);
|
||||||
(this.exchange as any)._invalidateContractInstances();
|
}
|
||||||
(this.exchange as any)._setNetworkId(networkId);
|
/**
|
||||||
(this.tokenRegistry as any)._invalidateContractInstance();
|
* Get the provider instance currently used by 0x.js
|
||||||
(this.tokenRegistry as any)._setNetworkId(networkId);
|
* @return Web3 provider instance
|
||||||
(this.token as any)._invalidateContractInstances();
|
*/
|
||||||
(this.token as any)._setNetworkId(networkId);
|
public getProvider(): Provider {
|
||||||
(this.proxy as any)._invalidateContractInstance();
|
return this._contractWrappers.getProvider();
|
||||||
(this.proxy as any)._setNetworkId(networkId);
|
|
||||||
(this.etherToken as any)._invalidateContractInstance();
|
|
||||||
(this.etherToken as any)._setNetworkId(networkId);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get user Ethereum addresses available through the supplied web3 provider available for sending transactions.
|
* Get user Ethereum addresses available through the supplied web3 provider available for sending transactions.
|
||||||
* @return An array of available user Ethereum addresses.
|
* @return An array of available user Ethereum addresses.
|
||||||
*/
|
*/
|
||||||
public async getAvailableAddressesAsync(): Promise<string[]> {
|
public async getAvailableAddressesAsync(): Promise<string[]> {
|
||||||
const availableAddresses = await this._web3Wrapper.getAvailableAddressesAsync();
|
// Hack: Get Web3Wrapper from ContractWrappers
|
||||||
|
const web3Wrapper: Web3Wrapper = (this._contractWrappers as any)._web3Wrapper;
|
||||||
|
const availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||||
return availableAddresses;
|
return availableAddresses;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -229,41 +184,12 @@ export class ZeroEx {
|
|||||||
signerAddress: string,
|
signerAddress: string,
|
||||||
shouldAddPersonalMessagePrefix: boolean,
|
shouldAddPersonalMessagePrefix: boolean,
|
||||||
): Promise<ECSignature> {
|
): Promise<ECSignature> {
|
||||||
assert.isHexString('orderHash', orderHash);
|
return signOrderHashAsync(
|
||||||
await assert.isSenderAddressAsync('signerAddress', signerAddress, this._web3Wrapper);
|
this._contractWrappers.getProvider(),
|
||||||
const normalizedSignerAddress = signerAddress.toLowerCase();
|
orderHash,
|
||||||
|
signerAddress,
|
||||||
let msgHashHex = orderHash;
|
shouldAddPersonalMessagePrefix,
|
||||||
if (shouldAddPersonalMessagePrefix) {
|
);
|
||||||
const orderHashBuff = ethUtil.toBuffer(orderHash);
|
|
||||||
const msgHashBuff = ethUtil.hashPersonalMessage(orderHashBuff);
|
|
||||||
msgHashHex = ethUtil.bufferToHex(msgHashBuff);
|
|
||||||
}
|
|
||||||
|
|
||||||
const signature = await this._web3Wrapper.signMessageAsync(normalizedSignerAddress, msgHashHex);
|
|
||||||
|
|
||||||
// HACK: There is no consensus on whether the signatureHex string should be formatted as
|
|
||||||
// v + r + s OR r + s + v, and different clients (even different versions of the same client)
|
|
||||||
// return the signature params in different orders. In order to support all client implementations,
|
|
||||||
// we parse the signature in both ways, and evaluate if either one is a valid signature.
|
|
||||||
const validVParamValues = [27, 28];
|
|
||||||
const ecSignatureVRS = signatureUtils.parseSignatureHexAsVRS(signature);
|
|
||||||
if (_.includes(validVParamValues, ecSignatureVRS.v)) {
|
|
||||||
const isValidVRSSignature = ZeroEx.isValidSignature(orderHash, ecSignatureVRS, normalizedSignerAddress);
|
|
||||||
if (isValidVRSSignature) {
|
|
||||||
return ecSignatureVRS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ecSignatureRSV = signatureUtils.parseSignatureHexAsRSV(signature);
|
|
||||||
if (_.includes(validVParamValues, ecSignatureRSV.v)) {
|
|
||||||
const isValidRSVSignature = ZeroEx.isValidSignature(orderHash, ecSignatureRSV, normalizedSignerAddress);
|
|
||||||
if (isValidRSVSignature) {
|
|
||||||
return ecSignatureRSV;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error(ZeroExError.InvalidSignature);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Waits for a transaction to be mined and returns the transaction receipt.
|
* Waits for a transaction to be mined and returns the transaction receipt.
|
||||||
@@ -274,10 +200,12 @@ export class ZeroEx {
|
|||||||
*/
|
*/
|
||||||
public async awaitTransactionMinedAsync(
|
public async awaitTransactionMinedAsync(
|
||||||
txHash: string,
|
txHash: string,
|
||||||
pollingIntervalMs = 1000,
|
pollingIntervalMs: number = 1000,
|
||||||
timeoutMs?: number,
|
timeoutMs?: number,
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const transactionReceiptWithDecodedLogs = await this._web3Wrapper.awaitTransactionMinedAsync(
|
// Hack: Get Web3Wrapper from ContractWrappers
|
||||||
|
const web3Wrapper: Web3Wrapper = (this._contractWrappers as any)._web3Wrapper;
|
||||||
|
const transactionReceiptWithDecodedLogs = await web3Wrapper.awaitTransactionMinedAsync(
|
||||||
txHash,
|
txHash,
|
||||||
pollingIntervalMs,
|
pollingIntervalMs,
|
||||||
timeoutMs,
|
timeoutMs,
|
||||||
@@ -285,22 +213,17 @@ export class ZeroEx {
|
|||||||
return transactionReceiptWithDecodedLogs;
|
return transactionReceiptWithDecodedLogs;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Instantiates and returns a new OrderStateWatcher instance.
|
* Instantiates and returns a new OrderWatcher instance.
|
||||||
* Defaults to watching the pending state.
|
* Defaults to watching the pending state.
|
||||||
* @param config The configuration object. Look up the type for the description.
|
* @param config The configuration object. Look up the type for the description.
|
||||||
* @return An instance of the 0x.js OrderStateWatcher class.
|
* @return An instance of the 0x.js OrderWatcher class.
|
||||||
*/
|
*/
|
||||||
public createOrderStateWatcher(config?: OrderStateWatcherConfig) {
|
public async createOrderWatcherAsync(config?: OrderWatcherConfig): Promise<OrderWatcher> {
|
||||||
return new OrderStateWatcher(this._web3Wrapper, this.token, this.exchange, config);
|
// Hack: Get Web3Wrapper from ContractWrappers
|
||||||
}
|
const web3Wrapper: Web3Wrapper = (this._contractWrappers as any)._web3Wrapper;
|
||||||
/*
|
const networkId = await web3Wrapper.getNetworkIdAsync();
|
||||||
* HACK: `TokenWrapper` needs a token transfer proxy address. `TokenTransferProxy` address is fetched from
|
const provider = this._contractWrappers.getProvider();
|
||||||
* an `ExchangeWrapper`. `ExchangeWrapper` needs `TokenWrapper` to validate orders, creating a dependency cycle.
|
const orderWatcher = new OrderWatcher(provider, networkId, config);
|
||||||
* In order to break this - we create this function here and pass it as a parameter to the `TokenWrapper`
|
return orderWatcher;
|
||||||
* and `ProxyWrapper`.
|
|
||||||
*/
|
|
||||||
private async _getTokenTransferProxyAddressAsync(): Promise<string> {
|
|
||||||
const tokenTransferProxyAddress = await (this.exchange as any)._getTokenTransferProxyAddressAsync();
|
|
||||||
return tokenTransferProxyAddress;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
import * as DummyTokenArtifact from './artifacts/DummyToken.json';
|
|
||||||
import * as EtherTokenArtifact from './artifacts/EtherToken.json';
|
|
||||||
import * as ExchangeArtifact from './artifacts/Exchange.json';
|
|
||||||
import * as TokenArtifact from './artifacts/Token.json';
|
|
||||||
import * as TokenRegistryArtifact from './artifacts/TokenRegistry.json';
|
|
||||||
import * as TokenTransferProxyArtifact from './artifacts/TokenTransferProxy.json';
|
|
||||||
import * as ZRXArtifact from './artifacts/ZRX.json';
|
|
||||||
import { Artifact } from './types';
|
|
||||||
|
|
||||||
export const artifacts = {
|
|
||||||
ZRXArtifact: (ZRXArtifact as any) as Artifact,
|
|
||||||
DummyTokenArtifact: (DummyTokenArtifact as any) as Artifact,
|
|
||||||
TokenArtifact: (TokenArtifact as any) as Artifact,
|
|
||||||
ExchangeArtifact: (ExchangeArtifact as any) as Artifact,
|
|
||||||
EtherTokenArtifact: (EtherTokenArtifact as any) as Artifact,
|
|
||||||
TokenRegistryArtifact: (TokenRegistryArtifact as any) as Artifact,
|
|
||||||
TokenTransferProxyArtifact: (TokenTransferProxyArtifact as any) as Artifact,
|
|
||||||
};
|
|
@@ -1,61 +1,53 @@
|
|||||||
export { ZeroEx } from './0x';
|
export { ZeroEx } from './0x';
|
||||||
|
|
||||||
export {
|
|
||||||
ZeroExError,
|
|
||||||
EventCallback,
|
|
||||||
ExchangeContractErrs,
|
|
||||||
ContractEvent,
|
|
||||||
Token,
|
|
||||||
IndexedFilterValues,
|
|
||||||
BlockRange,
|
|
||||||
OrderCancellationRequest,
|
|
||||||
OrderFillRequest,
|
|
||||||
ContractEventArgs,
|
|
||||||
ZeroExConfig,
|
|
||||||
MethodOpts,
|
|
||||||
OrderTransactionOpts,
|
|
||||||
TransactionOpts,
|
|
||||||
LogEvent,
|
|
||||||
DecodedLogEvent,
|
|
||||||
EventWatcherCallback,
|
|
||||||
OnOrderStateChangeCallback,
|
|
||||||
OrderStateValid,
|
|
||||||
OrderStateInvalid,
|
|
||||||
OrderState,
|
|
||||||
} from './types';
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
BlockParamLiteral,
|
BlockParamLiteral,
|
||||||
FilterObject,
|
FilterObject,
|
||||||
BlockParam,
|
BlockParam,
|
||||||
ContractEventArg,
|
ContractEventArg,
|
||||||
|
ExchangeContractErrs,
|
||||||
LogWithDecodedArgs,
|
LogWithDecodedArgs,
|
||||||
Order,
|
Order,
|
||||||
Provider,
|
Provider,
|
||||||
SignedOrder,
|
SignedOrder,
|
||||||
ECSignature,
|
ECSignature,
|
||||||
|
OrderStateValid,
|
||||||
|
OrderStateInvalid,
|
||||||
|
OrderState,
|
||||||
|
Token,
|
||||||
TransactionReceipt,
|
TransactionReceipt,
|
||||||
TransactionReceiptWithDecodedLogs,
|
TransactionReceiptWithDecodedLogs,
|
||||||
} from '@0xproject/types';
|
} from '@0xproject/types';
|
||||||
|
|
||||||
|
export { OrderWatcherConfig } from '@0xproject/order-watcher';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
EventCallback,
|
||||||
|
ContractEvent,
|
||||||
|
IndexedFilterValues,
|
||||||
|
BlockRange,
|
||||||
|
OrderCancellationRequest,
|
||||||
|
OrderFillRequest,
|
||||||
|
ContractEventArgs,
|
||||||
|
MethodOpts,
|
||||||
|
OrderTransactionOpts,
|
||||||
|
TransactionOpts,
|
||||||
|
LogEvent,
|
||||||
|
DecodedLogEvent,
|
||||||
|
OnOrderStateChangeCallback,
|
||||||
|
ContractWrappersError,
|
||||||
EtherTokenContractEventArgs,
|
EtherTokenContractEventArgs,
|
||||||
WithdrawalContractEventArgs,
|
WithdrawalContractEventArgs,
|
||||||
DepositContractEventArgs,
|
DepositContractEventArgs,
|
||||||
EtherTokenEvents,
|
EtherTokenEvents,
|
||||||
} from './contract_wrappers/generated/ether_token';
|
|
||||||
|
|
||||||
export {
|
|
||||||
TransferContractEventArgs,
|
TransferContractEventArgs,
|
||||||
ApprovalContractEventArgs,
|
ApprovalContractEventArgs,
|
||||||
TokenContractEventArgs,
|
TokenContractEventArgs,
|
||||||
TokenEvents,
|
TokenEvents,
|
||||||
} from './contract_wrappers/generated/token';
|
|
||||||
|
|
||||||
export {
|
|
||||||
LogErrorContractEventArgs,
|
LogErrorContractEventArgs,
|
||||||
LogCancelContractEventArgs,
|
LogCancelContractEventArgs,
|
||||||
LogFillContractEventArgs,
|
LogFillContractEventArgs,
|
||||||
ExchangeContractEventArgs,
|
ExchangeContractEventArgs,
|
||||||
ExchangeEvents,
|
ExchangeEvents,
|
||||||
} from './contract_wrappers/generated/exchange';
|
ContractWrappersConfig,
|
||||||
|
} from '@0xproject/contract-wrappers';
|
||||||
|
@@ -1,99 +0,0 @@
|
|||||||
import { BlockParamLiteral, LogEntry } from '@0xproject/types';
|
|
||||||
import { intervalUtils } from '@0xproject/utils';
|
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
import { EventWatcherCallback, ZeroExError } from '../types';
|
|
||||||
import { assert } from '../utils/assert';
|
|
||||||
|
|
||||||
const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200;
|
|
||||||
|
|
||||||
enum LogEventState {
|
|
||||||
Removed,
|
|
||||||
Added,
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The EventWatcher watches for blockchain events at the specified block confirmation
|
|
||||||
* depth.
|
|
||||||
*/
|
|
||||||
export class EventWatcher {
|
|
||||||
private _web3Wrapper: Web3Wrapper;
|
|
||||||
private _pollingIntervalMs: number;
|
|
||||||
private _intervalIdIfExists?: NodeJS.Timer;
|
|
||||||
private _lastEvents: LogEntry[] = [];
|
|
||||||
private _stateLayer: BlockParamLiteral;
|
|
||||||
constructor(
|
|
||||||
web3Wrapper: Web3Wrapper,
|
|
||||||
pollingIntervalIfExistsMs: undefined | number,
|
|
||||||
stateLayer: BlockParamLiteral = BlockParamLiteral.Latest,
|
|
||||||
) {
|
|
||||||
this._web3Wrapper = web3Wrapper;
|
|
||||||
this._stateLayer = stateLayer;
|
|
||||||
this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs)
|
|
||||||
? DEFAULT_EVENT_POLLING_INTERVAL_MS
|
|
||||||
: pollingIntervalIfExistsMs;
|
|
||||||
}
|
|
||||||
public subscribe(callback: EventWatcherCallback): void {
|
|
||||||
assert.isFunction('callback', callback);
|
|
||||||
if (!_.isUndefined(this._intervalIdIfExists)) {
|
|
||||||
throw new Error(ZeroExError.SubscriptionAlreadyPresent);
|
|
||||||
}
|
|
||||||
this._intervalIdIfExists = intervalUtils.setAsyncExcludingInterval(
|
|
||||||
this._pollForBlockchainEventsAsync.bind(this, callback),
|
|
||||||
this._pollingIntervalMs,
|
|
||||||
(err: Error) => {
|
|
||||||
this.unsubscribe();
|
|
||||||
callback(err);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
public unsubscribe(): void {
|
|
||||||
this._lastEvents = [];
|
|
||||||
if (!_.isUndefined(this._intervalIdIfExists)) {
|
|
||||||
intervalUtils.clearAsyncExcludingInterval(this._intervalIdIfExists);
|
|
||||||
delete this._intervalIdIfExists;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private async _pollForBlockchainEventsAsync(callback: EventWatcherCallback): Promise<void> {
|
|
||||||
const pendingEvents = await this._getEventsAsync();
|
|
||||||
if (_.isUndefined(pendingEvents)) {
|
|
||||||
// HACK: This should never happen, but happens frequently on CI due to a ganache bug
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (pendingEvents.length === 0) {
|
|
||||||
// HACK: Sometimes when node rebuilds the pending block we get back the empty result.
|
|
||||||
// We don't want to emit a lot of removal events and bring them back after a couple of miliseconds,
|
|
||||||
// that's why we just ignore those cases.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const removedEvents = _.differenceBy(this._lastEvents, pendingEvents, JSON.stringify);
|
|
||||||
const newEvents = _.differenceBy(pendingEvents, this._lastEvents, JSON.stringify);
|
|
||||||
await this._emitDifferencesAsync(removedEvents, LogEventState.Removed, callback);
|
|
||||||
await this._emitDifferencesAsync(newEvents, LogEventState.Added, callback);
|
|
||||||
this._lastEvents = pendingEvents;
|
|
||||||
}
|
|
||||||
private async _getEventsAsync(): Promise<LogEntry[]> {
|
|
||||||
const eventFilter = {
|
|
||||||
fromBlock: this._stateLayer,
|
|
||||||
toBlock: this._stateLayer,
|
|
||||||
};
|
|
||||||
const events = await this._web3Wrapper.getLogsAsync(eventFilter);
|
|
||||||
return events;
|
|
||||||
}
|
|
||||||
private async _emitDifferencesAsync(
|
|
||||||
logs: LogEntry[],
|
|
||||||
logEventState: LogEventState,
|
|
||||||
callback: EventWatcherCallback,
|
|
||||||
): Promise<void> {
|
|
||||||
for (const log of logs) {
|
|
||||||
const logEvent = {
|
|
||||||
removed: logEventState === LogEventState.Removed,
|
|
||||||
...log,
|
|
||||||
};
|
|
||||||
if (!_.isUndefined(this._intervalIdIfExists)) {
|
|
||||||
callback(null, logEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,9 +1,23 @@
|
|||||||
|
const networkNameToId: { [networkName: string]: number } = {
|
||||||
|
mainnet: 1,
|
||||||
|
ropsten: 3,
|
||||||
|
rinkeby: 4,
|
||||||
|
kovan: 42,
|
||||||
|
ganache: 50,
|
||||||
|
};
|
||||||
|
|
||||||
export const zeroExPublicNetworkConfigSchema = {
|
export const zeroExPublicNetworkConfigSchema = {
|
||||||
id: '/ZeroExPublicNetworkConfig',
|
id: '/ZeroExPublicNetworkConfig',
|
||||||
properties: {
|
properties: {
|
||||||
networkId: {
|
networkId: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
enum: [1, 3, 4, 42, 50],
|
enum: [
|
||||||
|
networkNameToId.mainnet,
|
||||||
|
networkNameToId.ropsten,
|
||||||
|
networkNameToId.rinkeby,
|
||||||
|
networkNameToId.kovan,
|
||||||
|
networkNameToId.ganache,
|
||||||
|
],
|
||||||
},
|
},
|
||||||
gasPrice: { $ref: '/Number' },
|
gasPrice: { $ref: '/Number' },
|
||||||
zrxContractAddress: { $ref: '/Address' },
|
zrxContractAddress: { $ref: '/Address' },
|
||||||
|
@@ -1,277 +1,20 @@
|
|||||||
import { BigNumber } from '@0xproject/utils';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BlockParam,
|
BlockParam,
|
||||||
BlockParamLiteral,
|
BlockParamLiteral,
|
||||||
ContractAbi,
|
ContractAbi,
|
||||||
ContractEventArg,
|
ContractEventArg,
|
||||||
|
ExchangeContractErrs,
|
||||||
FilterObject,
|
FilterObject,
|
||||||
LogEntryEvent,
|
|
||||||
LogWithDecodedArgs,
|
LogWithDecodedArgs,
|
||||||
Order,
|
Order,
|
||||||
|
OrderState,
|
||||||
SignedOrder,
|
SignedOrder,
|
||||||
} from '@0xproject/types';
|
} from '@0xproject/types';
|
||||||
|
|
||||||
import * as Web3 from 'web3';
|
|
||||||
|
|
||||||
import { EtherTokenContractEventArgs, EtherTokenEvents } from './contract_wrappers/generated/ether_token';
|
|
||||||
import { ExchangeContractEventArgs, ExchangeEvents } from './contract_wrappers/generated/exchange';
|
|
||||||
import { TokenContractEventArgs, TokenEvents } from './contract_wrappers/generated/token';
|
|
||||||
|
|
||||||
export enum ZeroExError {
|
|
||||||
ExchangeContractDoesNotExist = 'EXCHANGE_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
ZRXContractDoesNotExist = 'ZRX_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
EtherTokenContractDoesNotExist = 'ETHER_TOKEN_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
TokenTransferProxyContractDoesNotExist = 'TOKEN_TRANSFER_PROXY_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
TokenRegistryContractDoesNotExist = 'TOKEN_REGISTRY_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
TokenContractDoesNotExist = 'TOKEN_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
UnhandledError = 'UNHANDLED_ERROR',
|
|
||||||
UserHasNoAssociatedAddress = 'USER_HAS_NO_ASSOCIATED_ADDRESSES',
|
|
||||||
InvalidSignature = 'INVALID_SIGNATURE',
|
|
||||||
ContractNotDeployedOnNetwork = 'CONTRACT_NOT_DEPLOYED_ON_NETWORK',
|
|
||||||
InsufficientAllowanceForTransfer = 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER',
|
|
||||||
InsufficientBalanceForTransfer = 'INSUFFICIENT_BALANCE_FOR_TRANSFER',
|
|
||||||
InsufficientEthBalanceForDeposit = 'INSUFFICIENT_ETH_BALANCE_FOR_DEPOSIT',
|
|
||||||
InsufficientWEthBalanceForWithdrawal = 'INSUFFICIENT_WETH_BALANCE_FOR_WITHDRAWAL',
|
|
||||||
InvalidJump = 'INVALID_JUMP',
|
|
||||||
OutOfGas = 'OUT_OF_GAS',
|
|
||||||
NoNetworkId = 'NO_NETWORK_ID',
|
|
||||||
SubscriptionNotFound = 'SUBSCRIPTION_NOT_FOUND',
|
|
||||||
SubscriptionAlreadyPresent = 'SUBSCRIPTION_ALREADY_PRESENT',
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum InternalZeroExError {
|
export enum InternalZeroExError {
|
||||||
NoAbiDecoder = 'NO_ABI_DECODER',
|
NoAbiDecoder = 'NO_ABI_DECODER',
|
||||||
ZrxNotInTokenRegistry = 'ZRX_NOT_IN_TOKEN_REGISTRY',
|
ZrxNotInTokenRegistry = 'ZRX_NOT_IN_TOKEN_REGISTRY',
|
||||||
WethNotInTokenRegistry = 'WETH_NOT_IN_TOKEN_REGISTRY',
|
WethNotInTokenRegistry = 'WETH_NOT_IN_TOKEN_REGISTRY',
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OrderAddresses = [string, string, string, string, string];
|
|
||||||
|
|
||||||
export type OrderValues = [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber];
|
|
||||||
|
|
||||||
export type LogEvent = LogEntryEvent;
|
|
||||||
export interface DecodedLogEvent<ArgsType> {
|
|
||||||
isRemoved: boolean;
|
|
||||||
log: LogWithDecodedArgs<ArgsType>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type EventCallback<ArgsType> = (err: null | Error, log?: DecodedLogEvent<ArgsType>) => void;
|
|
||||||
export type EventWatcherCallback = (err: null | Error, log?: LogEvent) => void;
|
|
||||||
|
|
||||||
export enum ExchangeContractErrCodes {
|
|
||||||
ERROR_FILL_EXPIRED, // Order has already expired
|
|
||||||
ERROR_FILL_NO_VALUE, // Order has already been fully filled or cancelled
|
|
||||||
ERROR_FILL_TRUNCATION, // Rounding error too large
|
|
||||||
ERROR_FILL_BALANCE_ALLOWANCE, // Insufficient balance or allowance for token transfer
|
|
||||||
ERROR_CANCEL_EXPIRED, // Order has already expired
|
|
||||||
ERROR_CANCEL_NO_VALUE, // Order has already been fully filled or cancelled
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum ExchangeContractErrs {
|
|
||||||
OrderFillExpired = 'ORDER_FILL_EXPIRED',
|
|
||||||
OrderCancelExpired = 'ORDER_CANCEL_EXPIRED',
|
|
||||||
OrderCancelAmountZero = 'ORDER_CANCEL_AMOUNT_ZERO',
|
|
||||||
OrderAlreadyCancelledOrFilled = 'ORDER_ALREADY_CANCELLED_OR_FILLED',
|
|
||||||
OrderFillAmountZero = 'ORDER_FILL_AMOUNT_ZERO',
|
|
||||||
OrderRemainingFillAmountZero = 'ORDER_REMAINING_FILL_AMOUNT_ZERO',
|
|
||||||
OrderFillRoundingError = 'ORDER_FILL_ROUNDING_ERROR',
|
|
||||||
FillBalanceAllowanceError = 'FILL_BALANCE_ALLOWANCE_ERROR',
|
|
||||||
InsufficientTakerBalance = 'INSUFFICIENT_TAKER_BALANCE',
|
|
||||||
InsufficientTakerAllowance = 'INSUFFICIENT_TAKER_ALLOWANCE',
|
|
||||||
InsufficientMakerBalance = 'INSUFFICIENT_MAKER_BALANCE',
|
|
||||||
InsufficientMakerAllowance = 'INSUFFICIENT_MAKER_ALLOWANCE',
|
|
||||||
InsufficientTakerFeeBalance = 'INSUFFICIENT_TAKER_FEE_BALANCE',
|
|
||||||
InsufficientTakerFeeAllowance = 'INSUFFICIENT_TAKER_FEE_ALLOWANCE',
|
|
||||||
InsufficientMakerFeeBalance = 'INSUFFICIENT_MAKER_FEE_BALANCE',
|
|
||||||
InsufficientMakerFeeAllowance = 'INSUFFICIENT_MAKER_FEE_ALLOWANCE',
|
|
||||||
TransactionSenderIsNotFillOrderTaker = 'TRANSACTION_SENDER_IS_NOT_FILL_ORDER_TAKER',
|
|
||||||
MultipleMakersInSingleCancelBatchDisallowed = 'MULTIPLE_MAKERS_IN_SINGLE_CANCEL_BATCH_DISALLOWED',
|
|
||||||
InsufficientRemainingFillAmount = 'INSUFFICIENT_REMAINING_FILL_AMOUNT',
|
|
||||||
MultipleTakerTokensInFillUpToDisallowed = 'MULTIPLE_TAKER_TOKENS_IN_FILL_UP_TO_DISALLOWED',
|
|
||||||
BatchOrdersMustHaveSameExchangeAddress = 'BATCH_ORDERS_MUST_HAVE_SAME_EXCHANGE_ADDRESS',
|
|
||||||
BatchOrdersMustHaveAtLeastOneItem = 'BATCH_ORDERS_MUST_HAVE_AT_LEAST_ONE_ITEM',
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ContractEvent {
|
|
||||||
logIndex: number;
|
|
||||||
transactionIndex: number;
|
|
||||||
transactionHash: string;
|
|
||||||
blockHash: string;
|
|
||||||
blockNumber: number;
|
|
||||||
address: string;
|
|
||||||
type: string;
|
|
||||||
event: string;
|
|
||||||
args: ContractEventArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ContractEventArgs = ExchangeContractEventArgs | TokenContractEventArgs | EtherTokenContractEventArgs;
|
|
||||||
|
|
||||||
// [address, name, symbol, decimals, ipfsHash, swarmHash]
|
|
||||||
export type TokenMetadata = [string, string, string, number, string, string];
|
|
||||||
|
|
||||||
export interface Token {
|
|
||||||
name: string;
|
|
||||||
address: string;
|
|
||||||
symbol: string;
|
|
||||||
decimals: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TxOpts {
|
|
||||||
from: string;
|
|
||||||
gas?: number;
|
|
||||||
value?: BigNumber;
|
|
||||||
gasPrice?: BigNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TokenAddressBySymbol {
|
|
||||||
[symbol: string]: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ContractEvents = TokenEvents | ExchangeEvents | EtherTokenEvents;
|
|
||||||
|
|
||||||
export interface IndexedFilterValues {
|
|
||||||
[index: string]: ContractEventArg;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BlockRange {
|
|
||||||
fromBlock: BlockParam;
|
|
||||||
toBlock: BlockParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type DoneCallback = (err?: Error) => void;
|
|
||||||
|
|
||||||
export interface OrderCancellationRequest {
|
|
||||||
order: Order | SignedOrder;
|
|
||||||
takerTokenCancelAmount: BigNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OrderFillRequest {
|
|
||||||
signedOrder: SignedOrder;
|
|
||||||
takerTokenFillAmount: BigNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type AsyncMethod = (...args: any[]) => Promise<any>;
|
|
||||||
export type SyncMethod = (...args: any[]) => any;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* orderExpirationCheckingIntervalMs: How often to check for expired orders. Default: 50
|
|
||||||
* eventPollingIntervalMs: How often to poll the Ethereum node for new events. Default: 200
|
|
||||||
* expirationMarginMs: Amount of time before order expiry that you'd like to be notified
|
|
||||||
* of an orders expiration. Default: 0
|
|
||||||
* cleanupJobIntervalMs: How often to run a cleanup job which revalidates all the orders. Defaults: 1h
|
|
||||||
* stateLayer: Optional blockchain state layer OrderWatcher will monitor for new events. Default: latest
|
|
||||||
*/
|
|
||||||
export interface OrderStateWatcherConfig {
|
|
||||||
orderExpirationCheckingIntervalMs?: number;
|
|
||||||
eventPollingIntervalMs?: number;
|
|
||||||
expirationMarginMs?: number;
|
|
||||||
cleanupJobIntervalMs?: number;
|
|
||||||
stateLayer: BlockParamLiteral;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* networkId: The id of the underlying ethereum network your provider is connected to. (1-mainnet, 3-ropsten, 4-rinkeby, 42-kovan, 50-testrpc)
|
|
||||||
* gasPrice: Gas price to use with every transaction
|
|
||||||
* exchangeContractAddress: The address of an exchange contract to use
|
|
||||||
* zrxContractAddress: The address of the ZRX contract to use
|
|
||||||
* tokenRegistryContractAddress: The address of a token registry contract to use
|
|
||||||
* tokenTransferProxyContractAddress: The address of the token transfer proxy contract to use
|
|
||||||
* orderWatcherConfig: All the configs related to the orderWatcher
|
|
||||||
*/
|
|
||||||
export interface ZeroExConfig {
|
|
||||||
networkId: number;
|
|
||||||
gasPrice?: BigNumber;
|
|
||||||
exchangeContractAddress?: string;
|
|
||||||
zrxContractAddress?: string;
|
|
||||||
tokenRegistryContractAddress?: string;
|
|
||||||
tokenTransferProxyContractAddress?: string;
|
|
||||||
orderWatcherConfig?: OrderStateWatcherConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ArtifactContractName = 'ZRX' | 'TokenTransferProxy' | 'TokenRegistry' | 'Token' | 'Exchange' | 'EtherToken';
|
|
||||||
|
|
||||||
export interface Artifact {
|
|
||||||
contract_name: ArtifactContractName;
|
|
||||||
abi: ContractAbi;
|
|
||||||
networks: {
|
|
||||||
[networkId: number]: {
|
|
||||||
address: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* expectedFillTakerTokenAmount: If specified, the validation method will ensure that the
|
|
||||||
* supplied order maker has a sufficient allowance/balance to fill this amount of the order's
|
|
||||||
* takerTokenAmount. If not specified, the validation method ensures that the maker has a sufficient
|
|
||||||
* allowance/balance to fill the entire remaining order amount.
|
|
||||||
*/
|
|
||||||
export interface ValidateOrderFillableOpts {
|
|
||||||
expectedFillTakerTokenAmount?: BigNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* defaultBlock: The block up to which to query the blockchain state. Setting this to a historical block number
|
|
||||||
* let's the user query the blockchain's state at an arbitrary point in time. In order for this to work, the
|
|
||||||
* backing Ethereum node must keep the entire historical state of the chain (e.g setting `--pruning=archive`
|
|
||||||
* flag when running Parity).
|
|
||||||
*/
|
|
||||||
export interface MethodOpts {
|
|
||||||
defaultBlock?: BlockParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* gasPrice: Gas price in Wei to use for a transaction
|
|
||||||
* gasLimit: The amount of gas to send with a transaction
|
|
||||||
*/
|
|
||||||
export interface TransactionOpts {
|
|
||||||
gasPrice?: BigNumber;
|
|
||||||
gasLimit?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before
|
|
||||||
* broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default: true
|
|
||||||
*/
|
|
||||||
export interface OrderTransactionOpts extends TransactionOpts {
|
|
||||||
shouldValidate?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum TradeSide {
|
|
||||||
Maker = 'maker',
|
|
||||||
Taker = 'taker',
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum TransferType {
|
|
||||||
Trade = 'trade',
|
|
||||||
Fee = 'fee',
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OrderRelevantState {
|
|
||||||
makerBalance: BigNumber;
|
|
||||||
makerProxyAllowance: BigNumber;
|
|
||||||
makerFeeBalance: BigNumber;
|
|
||||||
makerFeeProxyAllowance: BigNumber;
|
|
||||||
filledTakerTokenAmount: BigNumber;
|
|
||||||
cancelledTakerTokenAmount: BigNumber;
|
|
||||||
remainingFillableMakerTokenAmount: BigNumber;
|
|
||||||
remainingFillableTakerTokenAmount: BigNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OrderStateValid {
|
|
||||||
isValid: true;
|
|
||||||
orderHash: string;
|
|
||||||
orderRelevantState: OrderRelevantState;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OrderStateInvalid {
|
|
||||||
isValid: false;
|
|
||||||
orderHash: string;
|
|
||||||
error: ExchangeContractErrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type OrderState = OrderStateValid | OrderStateInvalid;
|
|
||||||
|
|
||||||
export type OnOrderStateChangeCallback = (err: Error | null, orderState?: OrderState) => void;
|
|
||||||
// tslint:disable:max-file-line-count
|
// tslint:disable:max-file-line-count
|
||||||
|
@@ -3,10 +3,4 @@ import { BigNumber } from '@0xproject/utils';
|
|||||||
export const constants = {
|
export const constants = {
|
||||||
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
|
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
|
||||||
TESTRPC_NETWORK_ID: 50,
|
TESTRPC_NETWORK_ID: 50,
|
||||||
MAX_DIGITS_IN_UNSIGNED_256_INT: 78,
|
|
||||||
INVALID_JUMP_PATTERN: 'invalid JUMP at',
|
|
||||||
OUT_OF_GAS_PATTERN: 'out of gas',
|
|
||||||
INVALID_TAKER_FORMAT: 'instance.taker is not of a type(s) string',
|
|
||||||
UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1),
|
|
||||||
DEFAULT_BLOCK_POLLING_INTERVAL: 1000,
|
|
||||||
};
|
};
|
||||||
|
@@ -1,45 +0,0 @@
|
|||||||
import { ECSignature } from '@0xproject/types';
|
|
||||||
import * as ethUtil from 'ethereumjs-util';
|
|
||||||
|
|
||||||
export const signatureUtils = {
|
|
||||||
isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean {
|
|
||||||
const dataBuff = ethUtil.toBuffer(data);
|
|
||||||
const msgHashBuff = ethUtil.hashPersonalMessage(dataBuff);
|
|
||||||
try {
|
|
||||||
const pubKey = ethUtil.ecrecover(
|
|
||||||
msgHashBuff,
|
|
||||||
signature.v,
|
|
||||||
ethUtil.toBuffer(signature.r),
|
|
||||||
ethUtil.toBuffer(signature.s),
|
|
||||||
);
|
|
||||||
const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey));
|
|
||||||
return retrievedAddress === signerAddress;
|
|
||||||
} catch (err) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
parseSignatureHexAsVRS(signatureHex: string): ECSignature {
|
|
||||||
const signatureBuffer = ethUtil.toBuffer(signatureHex);
|
|
||||||
let v = signatureBuffer[0];
|
|
||||||
if (v < 27) {
|
|
||||||
v += 27;
|
|
||||||
}
|
|
||||||
const r = signatureBuffer.slice(1, 33);
|
|
||||||
const s = signatureBuffer.slice(33, 65);
|
|
||||||
const ecSignature: ECSignature = {
|
|
||||||
v,
|
|
||||||
r: ethUtil.bufferToHex(r),
|
|
||||||
s: ethUtil.bufferToHex(s),
|
|
||||||
};
|
|
||||||
return ecSignature;
|
|
||||||
},
|
|
||||||
parseSignatureHexAsRSV(signatureHex: string): ECSignature {
|
|
||||||
const { v, r, s } = ethUtil.fromRpcSig(signatureHex);
|
|
||||||
const ecSignature: ECSignature = {
|
|
||||||
v,
|
|
||||||
r: ethUtil.bufferToHex(r),
|
|
||||||
s: ethUtil.bufferToHex(s),
|
|
||||||
};
|
|
||||||
return ecSignature;
|
|
||||||
},
|
|
||||||
};
|
|
@@ -1,63 +0,0 @@
|
|||||||
import { Order, SignedOrder, SolidityTypes } from '@0xproject/types';
|
|
||||||
import { BigNumber } from '@0xproject/utils';
|
|
||||||
import BN = require('bn.js');
|
|
||||||
import * as ethABI from 'ethereumjs-abi';
|
|
||||||
import * as ethUtil from 'ethereumjs-util';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
export const utils = {
|
|
||||||
/**
|
|
||||||
* Converts BigNumber instance to BN
|
|
||||||
* The only reason we convert to BN is to remain compatible with `ethABI. soliditySHA3` that
|
|
||||||
* expects values of Solidity type `uint` to be passed as type `BN`.
|
|
||||||
* We do not use BN anywhere else in the codebase.
|
|
||||||
*/
|
|
||||||
bigNumberToBN(value: BigNumber) {
|
|
||||||
return new BN(value.toString(), 10);
|
|
||||||
},
|
|
||||||
spawnSwitchErr(name: string, value: any): Error {
|
|
||||||
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
|
|
||||||
},
|
|
||||||
getOrderHashHex(order: Order | SignedOrder): string {
|
|
||||||
const orderParts = [
|
|
||||||
{ value: order.exchangeContractAddress, type: SolidityTypes.Address },
|
|
||||||
{ value: order.maker, type: SolidityTypes.Address },
|
|
||||||
{ value: order.taker, type: SolidityTypes.Address },
|
|
||||||
{ value: order.makerTokenAddress, type: SolidityTypes.Address },
|
|
||||||
{ value: order.takerTokenAddress, type: SolidityTypes.Address },
|
|
||||||
{ value: order.feeRecipient, type: SolidityTypes.Address },
|
|
||||||
{
|
|
||||||
value: utils.bigNumberToBN(order.makerTokenAmount),
|
|
||||||
type: SolidityTypes.Uint256,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: utils.bigNumberToBN(order.takerTokenAmount),
|
|
||||||
type: SolidityTypes.Uint256,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: utils.bigNumberToBN(order.makerFee),
|
|
||||||
type: SolidityTypes.Uint256,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: utils.bigNumberToBN(order.takerFee),
|
|
||||||
type: SolidityTypes.Uint256,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: utils.bigNumberToBN(order.expirationUnixTimestampSec),
|
|
||||||
type: SolidityTypes.Uint256,
|
|
||||||
},
|
|
||||||
{ value: utils.bigNumberToBN(order.salt), type: SolidityTypes.Uint256 },
|
|
||||||
];
|
|
||||||
const types = _.map(orderParts, o => o.type);
|
|
||||||
const values = _.map(orderParts, o => o.value);
|
|
||||||
const hashBuff = ethABI.soliditySHA3(types, values);
|
|
||||||
const hashHex = ethUtil.bufferToHex(hashBuff);
|
|
||||||
return hashHex;
|
|
||||||
},
|
|
||||||
getCurrentUnixTimestampSec(): BigNumber {
|
|
||||||
return new BigNumber(Date.now() / 1000).round();
|
|
||||||
},
|
|
||||||
getCurrentUnixTimestampMs(): BigNumber {
|
|
||||||
return new BigNumber(Date.now());
|
|
||||||
},
|
|
||||||
};
|
|
@@ -1,8 +1,11 @@
|
|||||||
|
import { ContractWrappers } from '@0xproject/contract-wrappers';
|
||||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
import 'make-promises-safe';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
|
import * as path from 'path';
|
||||||
import * as Sinon from 'sinon';
|
import * as Sinon from 'sinon';
|
||||||
|
|
||||||
import { ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx } from '../src';
|
import { ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx } from '../src';
|
||||||
@@ -10,19 +13,20 @@ import { ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, Zero
|
|||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
import { TokenUtils } from './utils/token_utils';
|
import { TokenUtils } from './utils/token_utils';
|
||||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
|
|
||||||
const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false;
|
|
||||||
|
|
||||||
describe('ZeroEx library', () => {
|
describe('ZeroEx library', () => {
|
||||||
const config = {
|
let zeroEx: ZeroEx;
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
before(async () => {
|
||||||
};
|
const config = {
|
||||||
const zeroEx = new ZeroEx(web3.currentProvider, config);
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
};
|
||||||
|
zeroEx = new ZeroEx(provider, config);
|
||||||
|
});
|
||||||
describe('#setProvider', () => {
|
describe('#setProvider', () => {
|
||||||
it('overrides provider in nested web3s and invalidates contractInstances', async () => {
|
it('overrides provider in nested web3s and invalidates contractInstances', async () => {
|
||||||
// Instantiate the contract instances with the current provider
|
// Instantiate the contract instances with the current provider
|
||||||
@@ -31,18 +35,17 @@ describe('ZeroEx library', () => {
|
|||||||
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.not.be.undefined();
|
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.not.be.undefined();
|
||||||
expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.not.be.undefined();
|
expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.not.be.undefined();
|
||||||
|
|
||||||
const newProvider = web3Factory.getRpcProvider();
|
|
||||||
// Add property to newProvider so that we can differentiate it from old provider
|
// Add property to newProvider so that we can differentiate it from old provider
|
||||||
(newProvider as any).zeroExTestId = 1;
|
(provider as any).zeroExTestId = 1;
|
||||||
zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
|
zeroEx.setProvider(provider, constants.TESTRPC_NETWORK_ID);
|
||||||
|
|
||||||
// Check that contractInstances with old provider are removed after provider update
|
// Check that contractInstances with old provider are removed after provider update
|
||||||
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.be.undefined();
|
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.be.undefined();
|
||||||
expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.be.undefined();
|
expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.be.undefined();
|
||||||
|
|
||||||
// Check that all nested web3 wrapper instances return the updated provider
|
// Check that all nested zeroExContract/web3Wrapper instances return the updated provider
|
||||||
const nestedWeb3WrapperProvider = (zeroEx as any)._web3Wrapper.getProvider();
|
const nestedWeb3WrapperProvider = ((zeroEx as any)._contractWrappers as ContractWrappers).getProvider();
|
||||||
expect(nestedWeb3WrapperProvider.zeroExTestId).to.be.a('number');
|
expect((nestedWeb3WrapperProvider as any).zeroExTestId).to.be.a('number');
|
||||||
const exchangeWeb3WrapperProvider = (zeroEx.exchange as any)._web3Wrapper.getProvider();
|
const exchangeWeb3WrapperProvider = (zeroEx.exchange as any)._web3Wrapper.getProvider();
|
||||||
expect(exchangeWeb3WrapperProvider.zeroExTestId).to.be.a('number');
|
expect(exchangeWeb3WrapperProvider.zeroExTestId).to.be.a('number');
|
||||||
const tokenRegistryWeb3WrapperProvider = (zeroEx.tokenRegistry as any)._web3Wrapper.getProvider();
|
const tokenRegistryWeb3WrapperProvider = (zeroEx.tokenRegistry as any)._web3Wrapper.getProvider();
|
||||||
@@ -60,14 +63,12 @@ describe('ZeroEx library', () => {
|
|||||||
};
|
};
|
||||||
const address = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
|
const address = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
|
||||||
it("should return false if the data doesn't pertain to the signature & address", async () => {
|
it("should return false if the data doesn't pertain to the signature & address", async () => {
|
||||||
expect(ZeroEx.isValidSignature('0x0', signature, address)).to.be.false();
|
|
||||||
return expect(
|
return expect(
|
||||||
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync('0x0', signature, address),
|
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync('0x0', signature, address),
|
||||||
).to.become(false);
|
).to.become(false);
|
||||||
});
|
});
|
||||||
it("should return false if the address doesn't pertain to the signature & data", async () => {
|
it("should return false if the address doesn't pertain to the signature & data", async () => {
|
||||||
const validUnrelatedAddress = '0x8b0292b11a196601ed2ce54b665cafeca0347d42';
|
const validUnrelatedAddress = '0x8b0292b11a196601ed2ce54b665cafeca0347d42';
|
||||||
expect(ZeroEx.isValidSignature(dataHex, signature, validUnrelatedAddress)).to.be.false();
|
|
||||||
return expect(
|
return expect(
|
||||||
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(
|
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(
|
||||||
dataHex,
|
dataHex,
|
||||||
@@ -78,45 +79,16 @@ describe('ZeroEx library', () => {
|
|||||||
});
|
});
|
||||||
it("should return false if the signature doesn't pertain to the dataHex & address", async () => {
|
it("should return false if the signature doesn't pertain to the dataHex & address", async () => {
|
||||||
const wrongSignature = _.assign({}, signature, { v: 28 });
|
const wrongSignature = _.assign({}, signature, { v: 28 });
|
||||||
expect(ZeroEx.isValidSignature(dataHex, wrongSignature, address)).to.be.false();
|
|
||||||
return expect(
|
return expect(
|
||||||
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, wrongSignature, address),
|
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, wrongSignature, address),
|
||||||
).to.become(false);
|
).to.become(false);
|
||||||
});
|
});
|
||||||
it('should return true if the signature does pertain to the dataHex & address', async () => {
|
it('should return true if the signature does pertain to the dataHex & address', async () => {
|
||||||
const isValidSignatureLocal = ZeroEx.isValidSignature(dataHex, signature, address);
|
|
||||||
expect(isValidSignatureLocal).to.be.true();
|
|
||||||
return expect(
|
return expect(
|
||||||
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, signature, address),
|
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, signature, address),
|
||||||
).to.become(true);
|
).to.become(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('#generateSalt', () => {
|
|
||||||
it('generates different salts', () => {
|
|
||||||
const equal = ZeroEx.generatePseudoRandomSalt().eq(ZeroEx.generatePseudoRandomSalt());
|
|
||||||
expect(equal).to.be.false();
|
|
||||||
});
|
|
||||||
it('generates salt in range [0..2^256)', () => {
|
|
||||||
const salt = ZeroEx.generatePseudoRandomSalt();
|
|
||||||
expect(salt.greaterThanOrEqualTo(0)).to.be.true();
|
|
||||||
const twoPow256 = new BigNumber(2).pow(256);
|
|
||||||
expect(salt.lessThan(twoPow256)).to.be.true();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('#isValidOrderHash', () => {
|
|
||||||
it('returns false if the value is not a hex string', () => {
|
|
||||||
const isValid = ZeroEx.isValidOrderHash('not a hex');
|
|
||||||
expect(isValid).to.be.false();
|
|
||||||
});
|
|
||||||
it('returns false if the length is wrong', () => {
|
|
||||||
const isValid = ZeroEx.isValidOrderHash('0xdeadbeef');
|
|
||||||
expect(isValid).to.be.false();
|
|
||||||
});
|
|
||||||
it('returns true if order hash is correct', () => {
|
|
||||||
const isValid = ZeroEx.isValidOrderHash('0x' + Array(65).join('0'));
|
|
||||||
expect(isValid).to.be.true();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('#toUnitAmount', () => {
|
describe('#toUnitAmount', () => {
|
||||||
it('should throw if invalid baseUnit amount supplied as argument', () => {
|
it('should throw if invalid baseUnit amount supplied as argument', () => {
|
||||||
const invalidBaseUnitAmount = new BigNumber(1000000000.4);
|
const invalidBaseUnitAmount = new BigNumber(1000000000.4);
|
||||||
@@ -149,106 +121,6 @@ describe('ZeroEx library', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('#getOrderHashHex', () => {
|
|
||||||
const expectedOrderHash = '0x39da987067a3c9e5f1617694f1301326ba8c8b0498ebef5df4863bed394e3c83';
|
|
||||||
const fakeExchangeContractAddress = '0xb69e673309512a9d726f87304c6984054f87a93b';
|
|
||||||
const order: Order = {
|
|
||||||
maker: constants.NULL_ADDRESS,
|
|
||||||
taker: constants.NULL_ADDRESS,
|
|
||||||
feeRecipient: constants.NULL_ADDRESS,
|
|
||||||
makerTokenAddress: constants.NULL_ADDRESS,
|
|
||||||
takerTokenAddress: constants.NULL_ADDRESS,
|
|
||||||
exchangeContractAddress: fakeExchangeContractAddress,
|
|
||||||
salt: new BigNumber(0),
|
|
||||||
makerFee: new BigNumber(0),
|
|
||||||
takerFee: new BigNumber(0),
|
|
||||||
makerTokenAmount: new BigNumber(0),
|
|
||||||
takerTokenAmount: new BigNumber(0),
|
|
||||||
expirationUnixTimestampSec: new BigNumber(0),
|
|
||||||
};
|
|
||||||
it('calculates the order hash', async () => {
|
|
||||||
const orderHash = ZeroEx.getOrderHashHex(order);
|
|
||||||
expect(orderHash).to.be.equal(expectedOrderHash);
|
|
||||||
});
|
|
||||||
it('throws a readable error message if taker format is invalid', async () => {
|
|
||||||
const orderWithInvalidtakerFormat = {
|
|
||||||
...order,
|
|
||||||
taker: (null as any) as string,
|
|
||||||
};
|
|
||||||
const expectedErrorMessage =
|
|
||||||
'Order taker must be of type string. If you want anyone to be able to fill an order - pass ZeroEx.NULL_ADDRESS';
|
|
||||||
expect(() => ZeroEx.getOrderHashHex(orderWithInvalidtakerFormat)).to.throw(expectedErrorMessage);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('#signOrderHashAsync', () => {
|
|
||||||
let stubs: Sinon.SinonStub[] = [];
|
|
||||||
let makerAddress: string;
|
|
||||||
before(async () => {
|
|
||||||
const availableAddreses = await zeroEx.getAvailableAddressesAsync();
|
|
||||||
makerAddress = availableAddreses[0];
|
|
||||||
});
|
|
||||||
afterEach(() => {
|
|
||||||
// clean up any stubs after the test has completed
|
|
||||||
_.each(stubs, s => s.restore());
|
|
||||||
stubs = [];
|
|
||||||
});
|
|
||||||
it('Should return the correct ECSignature', async () => {
|
|
||||||
const orderHash = '0x6927e990021d23b1eb7b8789f6a6feaf98fe104bb0cf8259421b79f9a34222b0';
|
|
||||||
const expectedECSignature = {
|
|
||||||
v: 27,
|
|
||||||
r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
|
||||||
s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
|
|
||||||
};
|
|
||||||
const ecSignature = await zeroEx.signOrderHashAsync(
|
|
||||||
orderHash,
|
|
||||||
makerAddress,
|
|
||||||
SHOULD_ADD_PERSONAL_MESSAGE_PREFIX,
|
|
||||||
);
|
|
||||||
expect(ecSignature).to.deep.equal(expectedECSignature);
|
|
||||||
});
|
|
||||||
it('should return the correct ECSignature for signatureHex concatenated as R + S + V', async () => {
|
|
||||||
const orderHash = '0x34decbedc118904df65f379a175bb39ca18209d6ce41d5ed549d54e6e0a95004';
|
|
||||||
const signature =
|
|
||||||
'0x22109d11d79cb8bf96ed88625e1cd9558800c4073332a9a02857499883ee5ce3050aa3cc1f2c435e67e114cdce54b9527b4f50548342401bc5d2b77adbdacb021b';
|
|
||||||
const expectedECSignature = {
|
|
||||||
v: 27,
|
|
||||||
r: '0x22109d11d79cb8bf96ed88625e1cd9558800c4073332a9a02857499883ee5ce3',
|
|
||||||
s: '0x050aa3cc1f2c435e67e114cdce54b9527b4f50548342401bc5d2b77adbdacb02',
|
|
||||||
};
|
|
||||||
stubs = [
|
|
||||||
Sinon.stub((zeroEx as any)._web3Wrapper, 'signMessageAsync').returns(Promise.resolve(signature)),
|
|
||||||
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
|
|
||||||
];
|
|
||||||
|
|
||||||
const ecSignature = await zeroEx.signOrderHashAsync(
|
|
||||||
orderHash,
|
|
||||||
makerAddress,
|
|
||||||
SHOULD_ADD_PERSONAL_MESSAGE_PREFIX,
|
|
||||||
);
|
|
||||||
expect(ecSignature).to.deep.equal(expectedECSignature);
|
|
||||||
});
|
|
||||||
it('should return the correct ECSignature for signatureHex concatenated as V + R + S', async () => {
|
|
||||||
const orderHash = '0xc793e33ffded933b76f2f48d9aa3339fc090399d5e7f5dec8d3660f5480793f7';
|
|
||||||
const signature =
|
|
||||||
'0x1bc80bedc6756722672753413efdd749b5adbd4fd552595f59c13427407ee9aee02dea66f25a608bbae457e020fb6decb763deb8b7192abab624997242da248960';
|
|
||||||
const expectedECSignature = {
|
|
||||||
v: 27,
|
|
||||||
r: '0xc80bedc6756722672753413efdd749b5adbd4fd552595f59c13427407ee9aee0',
|
|
||||||
s: '0x2dea66f25a608bbae457e020fb6decb763deb8b7192abab624997242da248960',
|
|
||||||
};
|
|
||||||
stubs = [
|
|
||||||
Sinon.stub((zeroEx as any)._web3Wrapper, 'signMessageAsync').returns(Promise.resolve(signature)),
|
|
||||||
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
|
|
||||||
];
|
|
||||||
|
|
||||||
const ecSignature = await zeroEx.signOrderHashAsync(
|
|
||||||
orderHash,
|
|
||||||
makerAddress,
|
|
||||||
SHOULD_ADD_PERSONAL_MESSAGE_PREFIX,
|
|
||||||
);
|
|
||||||
expect(ecSignature).to.deep.equal(expectedECSignature);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('#awaitTransactionMinedAsync', () => {
|
describe('#awaitTransactionMinedAsync', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
@@ -278,7 +150,7 @@ describe('ZeroEx library', () => {
|
|||||||
exchangeContractAddress: ZeroEx.NULL_ADDRESS,
|
exchangeContractAddress: ZeroEx.NULL_ADDRESS,
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
};
|
};
|
||||||
const zeroExWithWrongExchangeAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
|
const zeroExWithWrongExchangeAddress = new ZeroEx(provider, zeroExConfig);
|
||||||
expect(zeroExWithWrongExchangeAddress.exchange.getContractAddress()).to.be.equal(ZeroEx.NULL_ADDRESS);
|
expect(zeroExWithWrongExchangeAddress.exchange.getContractAddress()).to.be.equal(ZeroEx.NULL_ADDRESS);
|
||||||
});
|
});
|
||||||
it('allows to specify token registry token contract address', async () => {
|
it('allows to specify token registry token contract address', async () => {
|
||||||
@@ -286,7 +158,7 @@ describe('ZeroEx library', () => {
|
|||||||
tokenRegistryContractAddress: ZeroEx.NULL_ADDRESS,
|
tokenRegistryContractAddress: ZeroEx.NULL_ADDRESS,
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
};
|
};
|
||||||
const zeroExWithWrongTokenRegistryAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
|
const zeroExWithWrongTokenRegistryAddress = new ZeroEx(provider, zeroExConfig);
|
||||||
expect(zeroExWithWrongTokenRegistryAddress.tokenRegistry.getContractAddress()).to.be.equal(
|
expect(zeroExWithWrongTokenRegistryAddress.tokenRegistry.getContractAddress()).to.be.equal(
|
||||||
ZeroEx.NULL_ADDRESS,
|
ZeroEx.NULL_ADDRESS,
|
||||||
);
|
);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
|
import { web3Factory } from '@0xproject/dev-utils';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import HDWalletProvider = require('truffle-hdwallet-provider');
|
import 'make-promises-safe';
|
||||||
|
|
||||||
import { ZeroEx } from '../src';
|
import { ZeroEx } from '../src';
|
||||||
|
|
||||||
@@ -14,14 +15,11 @@ const TIMEOUT = 10000;
|
|||||||
describe('Artifacts', () => {
|
describe('Artifacts', () => {
|
||||||
describe('contracts are deployed on kovan', () => {
|
describe('contracts are deployed on kovan', () => {
|
||||||
const kovanRpcUrl = constants.KOVAN_RPC_URL;
|
const kovanRpcUrl = constants.KOVAN_RPC_URL;
|
||||||
const packageJSONContent = fs.readFileSync('package.json', 'utf-8');
|
const provider = web3Factory.create({ rpcUrl: kovanRpcUrl }).currentProvider;
|
||||||
const packageJSON = JSON.parse(packageJSONContent);
|
|
||||||
const mnemonic = packageJSON.config.mnemonic;
|
|
||||||
const web3Provider = new HDWalletProvider(mnemonic, kovanRpcUrl);
|
|
||||||
const config = {
|
const config = {
|
||||||
networkId: constants.KOVAN_NETWORK_ID,
|
networkId: constants.KOVAN_NETWORK_ID,
|
||||||
};
|
};
|
||||||
const zeroEx = new ZeroEx(web3Provider, config);
|
const zeroEx = new ZeroEx(provider, config);
|
||||||
it('token registry contract is deployed', async () => {
|
it('token registry contract is deployed', async () => {
|
||||||
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
||||||
}).timeout(TIMEOUT);
|
}).timeout(TIMEOUT);
|
||||||
@@ -34,14 +32,11 @@ describe('Artifacts', () => {
|
|||||||
});
|
});
|
||||||
describe('contracts are deployed on ropsten', () => {
|
describe('contracts are deployed on ropsten', () => {
|
||||||
const ropstenRpcUrl = constants.ROPSTEN_RPC_URL;
|
const ropstenRpcUrl = constants.ROPSTEN_RPC_URL;
|
||||||
const packageJSONContent = fs.readFileSync('package.json', 'utf-8');
|
const provider = web3Factory.create({ rpcUrl: ropstenRpcUrl }).currentProvider;
|
||||||
const packageJSON = JSON.parse(packageJSONContent);
|
|
||||||
const mnemonic = packageJSON.config.mnemonic;
|
|
||||||
const web3Provider = new HDWalletProvider(mnemonic, ropstenRpcUrl);
|
|
||||||
const config = {
|
const config = {
|
||||||
networkId: constants.ROPSTEN_NETWORK_ID,
|
networkId: constants.ROPSTEN_NETWORK_ID,
|
||||||
};
|
};
|
||||||
const zeroEx = new ZeroEx(web3Provider, config);
|
const zeroEx = new ZeroEx(provider, config);
|
||||||
it('token registry contract is deployed', async () => {
|
it('token registry contract is deployed', async () => {
|
||||||
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
||||||
}).timeout(TIMEOUT);
|
}).timeout(TIMEOUT);
|
||||||
|
@@ -1,43 +0,0 @@
|
|||||||
import { web3Factory } from '@0xproject/dev-utils';
|
|
||||||
import * as chai from 'chai';
|
|
||||||
import 'mocha';
|
|
||||||
|
|
||||||
import { ZeroEx } from '../src';
|
|
||||||
import { assert } from '../src/utils/assert';
|
|
||||||
|
|
||||||
import { constants } from './utils/constants';
|
|
||||||
|
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
describe('Assertion library', () => {
|
|
||||||
const web3 = web3Factory.create();
|
|
||||||
const config = {
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
};
|
|
||||||
const zeroEx = new ZeroEx(web3.currentProvider, config);
|
|
||||||
describe('#isSenderAddressHexAsync', () => {
|
|
||||||
it('throws when address is invalid', async () => {
|
|
||||||
const address = '0xdeadbeef';
|
|
||||||
const varName = 'address';
|
|
||||||
return expect(
|
|
||||||
assert.isSenderAddressAsync(varName, address, (zeroEx as any)._web3Wrapper),
|
|
||||||
).to.be.rejectedWith(`Expected ${varName} to be of type ETHAddressHex, encountered: ${address}`);
|
|
||||||
});
|
|
||||||
it('throws when address is unavailable', async () => {
|
|
||||||
const validUnrelatedAddress = '0x8b0292b11a196601eddce54b665cafeca0347d42';
|
|
||||||
const varName = 'address';
|
|
||||||
return expect(
|
|
||||||
assert.isSenderAddressAsync(varName, validUnrelatedAddress, (zeroEx as any)._web3Wrapper),
|
|
||||||
).to.be.rejectedWith(
|
|
||||||
`Specified ${varName} ${validUnrelatedAddress} isn't available through the supplied web3 provider`,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it("doesn't throw if address is available", async () => {
|
|
||||||
const availableAddress = (await zeroEx.getAvailableAddressesAsync())[0];
|
|
||||||
const varName = 'address';
|
|
||||||
return expect(
|
|
||||||
assert.isSenderAddressAsync(varName, availableAddress, (zeroEx as any)._web3Wrapper),
|
|
||||||
).to.become(undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,127 +0,0 @@
|
|||||||
import { web3Factory } from '@0xproject/dev-utils';
|
|
||||||
import { LogEntry } from '@0xproject/types';
|
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|
||||||
import * as chai from 'chai';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
import 'mocha';
|
|
||||||
import * as Sinon from 'sinon';
|
|
||||||
import * as Web3 from 'web3';
|
|
||||||
|
|
||||||
import { LogEvent } from '../src';
|
|
||||||
import { EventWatcher } from '../src/order_watcher/event_watcher';
|
|
||||||
import { DoneCallback } from '../src/types';
|
|
||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
|
||||||
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
|
||||||
|
|
||||||
chaiSetup.configure();
|
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
describe('EventWatcher', () => {
|
|
||||||
let web3: Web3;
|
|
||||||
let stubs: Sinon.SinonStub[] = [];
|
|
||||||
let eventWatcher: EventWatcher;
|
|
||||||
let web3Wrapper: Web3Wrapper;
|
|
||||||
const logA: LogEntry = {
|
|
||||||
address: '0x71d271f8b14adef568f8f28f1587ce7271ac4ca5',
|
|
||||||
blockHash: null,
|
|
||||||
blockNumber: null,
|
|
||||||
data: '',
|
|
||||||
logIndex: null,
|
|
||||||
topics: [],
|
|
||||||
transactionHash: '0x004881d38cd4a8f72f1a0d68c8b9b8124504706041ff37019c1d1ed6bfda8e17',
|
|
||||||
transactionIndex: 0,
|
|
||||||
};
|
|
||||||
const logB: LogEntry = {
|
|
||||||
address: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
|
|
||||||
blockHash: null,
|
|
||||||
blockNumber: null,
|
|
||||||
data: '',
|
|
||||||
logIndex: null,
|
|
||||||
topics: ['0xf341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb567'],
|
|
||||||
transactionHash: '0x01ef3c048b18d9b09ea195b4ed94cf8dd5f3d857a1905ff886b152cfb1166f25',
|
|
||||||
transactionIndex: 0,
|
|
||||||
};
|
|
||||||
const logC: LogEntry = {
|
|
||||||
address: '0x1d271f8b174adef58f1587ce68f8f27271ac4ca5',
|
|
||||||
blockHash: null,
|
|
||||||
blockNumber: null,
|
|
||||||
data: '',
|
|
||||||
logIndex: null,
|
|
||||||
topics: ['0xf341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb567'],
|
|
||||||
transactionHash: '0x01ef3c048b18d9b09ea195b4ed94cf8dd5f3d857a1905ff886b152cfb1166f25',
|
|
||||||
transactionIndex: 0,
|
|
||||||
};
|
|
||||||
before(async () => {
|
|
||||||
web3 = web3Factory.create();
|
|
||||||
const pollingIntervalMs = 10;
|
|
||||||
web3Wrapper = new Web3Wrapper(web3.currentProvider);
|
|
||||||
eventWatcher = new EventWatcher(web3Wrapper, pollingIntervalMs);
|
|
||||||
});
|
|
||||||
afterEach(() => {
|
|
||||||
// clean up any stubs after the test has completed
|
|
||||||
_.each(stubs, s => s.restore());
|
|
||||||
stubs = [];
|
|
||||||
eventWatcher.unsubscribe();
|
|
||||||
});
|
|
||||||
it('correctly emits initial log events', (done: DoneCallback) => {
|
|
||||||
const logs: LogEntry[] = [logA, logB];
|
|
||||||
const expectedLogEvents = [
|
|
||||||
{
|
|
||||||
removed: false,
|
|
||||||
...logA,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
removed: false,
|
|
||||||
...logB,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const getLogsStub = Sinon.stub(web3Wrapper, 'getLogsAsync');
|
|
||||||
getLogsStub.onCall(0).returns(logs);
|
|
||||||
stubs.push(getLogsStub);
|
|
||||||
const expectedToBeCalledOnce = false;
|
|
||||||
const callback = reportNodeCallbackErrors(done, expectedToBeCalledOnce)((event: LogEvent) => {
|
|
||||||
const expectedLogEvent = expectedLogEvents.shift();
|
|
||||||
expect(event).to.be.deep.equal(expectedLogEvent);
|
|
||||||
if (_.isEmpty(expectedLogEvents)) {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
eventWatcher.subscribe(callback);
|
|
||||||
});
|
|
||||||
it('correctly computes the difference and emits only changes', (done: DoneCallback) => {
|
|
||||||
const initialLogs: LogEntry[] = [logA, logB];
|
|
||||||
const changedLogs: LogEntry[] = [logA, logC];
|
|
||||||
const expectedLogEvents = [
|
|
||||||
{
|
|
||||||
removed: false,
|
|
||||||
...logA,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
removed: false,
|
|
||||||
...logB,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
removed: true,
|
|
||||||
...logB,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
removed: false,
|
|
||||||
...logC,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const getLogsStub = Sinon.stub(web3Wrapper, 'getLogsAsync');
|
|
||||||
getLogsStub.onCall(0).returns(initialLogs);
|
|
||||||
getLogsStub.onCall(1).returns(changedLogs);
|
|
||||||
stubs.push(getLogsStub);
|
|
||||||
const expectedToBeCalledOnce = false;
|
|
||||||
const callback = reportNodeCallbackErrors(done, expectedToBeCalledOnce)((event: LogEvent) => {
|
|
||||||
const expectedLogEvent = expectedLogEvents.shift();
|
|
||||||
expect(event).to.be.deep.equal(expectedLogEvent);
|
|
||||||
if (_.isEmpty(expectedLogEvents)) {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
eventWatcher.subscribe(callback);
|
|
||||||
});
|
|
||||||
});
|
|
19
packages/0x.js/test/global_hooks.ts
Normal file
19
packages/0x.js/test/global_hooks.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { devConstants } from '@0xproject/dev-utils';
|
||||||
|
import { runMigrationsAsync } from '@0xproject/migrations';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
import { constants } from './utils/constants';
|
||||||
|
import { provider } from './utils/web3_wrapper';
|
||||||
|
|
||||||
|
before('migrate contracts', async function(): Promise<void> {
|
||||||
|
// HACK: Since the migrations take longer then our global mocha timeout limit
|
||||||
|
// we manually increase it for this before hook.
|
||||||
|
const mochaTestTimeoutMs = 20000;
|
||||||
|
this.timeout(mochaTestTimeoutMs);
|
||||||
|
const txDefaults = {
|
||||||
|
gas: devConstants.GAS_ESTIMATE,
|
||||||
|
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
||||||
|
};
|
||||||
|
const artifactsDir = `../migrations/artifacts/1.0.0`;
|
||||||
|
await runMigrationsAsync(provider, artifactsDir, txDefaults);
|
||||||
|
});
|
@@ -1,83 +0,0 @@
|
|||||||
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
|
||||||
import { BigNumber } from '@0xproject/utils';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
import 'mocha';
|
|
||||||
import * as Sinon from 'sinon';
|
|
||||||
import * as Web3 from 'web3';
|
|
||||||
|
|
||||||
import { ApprovalContractEventArgs, DecodedLogEvent, Token, TokenEvents, ZeroEx } from '../src';
|
|
||||||
import { DoneCallback } from '../src/types';
|
|
||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
|
||||||
import { constants } from './utils/constants';
|
|
||||||
import { assertNodeCallbackError } from './utils/report_callback_errors';
|
|
||||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
|
||||||
|
|
||||||
chaiSetup.configure();
|
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
|
||||||
|
|
||||||
describe('SubscriptionTest', () => {
|
|
||||||
let zeroEx: ZeroEx;
|
|
||||||
let userAddresses: string[];
|
|
||||||
let tokens: Token[];
|
|
||||||
let coinbase: string;
|
|
||||||
let addressWithoutFunds: string;
|
|
||||||
const config = {
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
};
|
|
||||||
before(async () => {
|
|
||||||
zeroEx = new ZeroEx(web3.currentProvider, config);
|
|
||||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
|
||||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
|
||||||
coinbase = userAddresses[0];
|
|
||||||
addressWithoutFunds = userAddresses[1];
|
|
||||||
});
|
|
||||||
beforeEach(async () => {
|
|
||||||
await blockchainLifecycle.startAsync();
|
|
||||||
});
|
|
||||||
afterEach(async () => {
|
|
||||||
await blockchainLifecycle.revertAsync();
|
|
||||||
});
|
|
||||||
describe('#subscribe', () => {
|
|
||||||
const indexFilterValues = {};
|
|
||||||
let tokenAddress: string;
|
|
||||||
const allowanceAmount = new BigNumber(42);
|
|
||||||
let stubs: Sinon.SinonStub[] = [];
|
|
||||||
before(() => {
|
|
||||||
const token = tokens[0];
|
|
||||||
tokenAddress = token.address;
|
|
||||||
});
|
|
||||||
afterEach(() => {
|
|
||||||
zeroEx.token.unsubscribeAll();
|
|
||||||
_.each(stubs, s => s.restore());
|
|
||||||
stubs = [];
|
|
||||||
});
|
|
||||||
it('Should receive the Error when an error occurs while fetching the block', (done: DoneCallback) => {
|
|
||||||
(async () => {
|
|
||||||
const errMsg = 'Error fetching block';
|
|
||||||
const callback = assertNodeCallbackError(done, errMsg);
|
|
||||||
stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error(errMsg))];
|
|
||||||
zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
|
|
||||||
await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount);
|
|
||||||
})().catch(done);
|
|
||||||
});
|
|
||||||
it('Should receive the Error when an error occurs while reconciling the new block', (done: DoneCallback) => {
|
|
||||||
(async () => {
|
|
||||||
const errMsg = 'Error fetching logs';
|
|
||||||
const callback = assertNodeCallbackError(done, errMsg);
|
|
||||||
stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getLogsAsync').throws(new Error(errMsg))];
|
|
||||||
zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
|
|
||||||
await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount);
|
|
||||||
})().catch(done);
|
|
||||||
});
|
|
||||||
it('Should allow unsubscribeAll to be called successfully after an error', (done: DoneCallback) => {
|
|
||||||
(async () => {
|
|
||||||
const callback = (err: Error | null, logEvent?: DecodedLogEvent<ApprovalContractEventArgs>) => _.noop;
|
|
||||||
zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
|
|
||||||
stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error('JSON RPC error'))];
|
|
||||||
zeroEx.token.unsubscribeAll();
|
|
||||||
done();
|
|
||||||
})().catch(done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -4,7 +4,7 @@ import ChaiBigNumber = require('chai-bignumber');
|
|||||||
import * as dirtyChai from 'dirty-chai';
|
import * as dirtyChai from 'dirty-chai';
|
||||||
|
|
||||||
export const chaiSetup = {
|
export const chaiSetup = {
|
||||||
configure() {
|
configure(): void {
|
||||||
chai.config.includeStack = true;
|
chai.config.includeStack = true;
|
||||||
chai.use(ChaiBigNumber());
|
chai.use(ChaiBigNumber());
|
||||||
chai.use(dirtyChai);
|
chai.use(dirtyChai);
|
||||||
|
@@ -1,66 +0,0 @@
|
|||||||
import * as chai from 'chai';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
import { DoneCallback } from '../../src/types';
|
|
||||||
|
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
export const reportNoErrorCallbackErrors = (done: DoneCallback, expectToBeCalledOnce = true) => {
|
|
||||||
return <T>(f?: (value: T) => void) => {
|
|
||||||
const wrapped = (value: T) => {
|
|
||||||
if (_.isUndefined(f)) {
|
|
||||||
done();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
f(value);
|
|
||||||
if (expectToBeCalledOnce) {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
done(err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return wrapped;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const reportNodeCallbackErrors = (done: DoneCallback, expectToBeCalledOnce = true) => {
|
|
||||||
return <T>(f?: (value: T) => void) => {
|
|
||||||
const wrapped = (error: Error | null, value: T | undefined) => {
|
|
||||||
if (!_.isNull(error)) {
|
|
||||||
done(error);
|
|
||||||
} else {
|
|
||||||
if (_.isUndefined(f)) {
|
|
||||||
done();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
f(value as T);
|
|
||||||
if (expectToBeCalledOnce) {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
done(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return wrapped;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const assertNodeCallbackError = (done: DoneCallback, errMsg: string) => {
|
|
||||||
const wrapped = <T>(error: Error | null, value: T | undefined) => {
|
|
||||||
if (_.isNull(error)) {
|
|
||||||
done(new Error('Expected callback to receive an error'));
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
expect(error.message).to.be.equal(errMsg);
|
|
||||||
done();
|
|
||||||
} catch (err) {
|
|
||||||
done(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return wrapped;
|
|
||||||
};
|
|
@@ -1,6 +1,7 @@
|
|||||||
|
import { Token } from '@0xproject/types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { InternalZeroExError, Token } from '../../src/types';
|
import { InternalZeroExError } from '../../src/types';
|
||||||
|
|
||||||
const PROTOCOL_TOKEN_SYMBOL = 'ZRX';
|
const PROTOCOL_TOKEN_SYMBOL = 'ZRX';
|
||||||
const WETH_TOKEN_SYMBOL = 'WETH';
|
const WETH_TOKEN_SYMBOL = 'WETH';
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
import { web3Factory } from '@0xproject/dev-utils';
|
import { devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||||
|
import { Provider } from '@0xproject/types';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import * as Web3 from 'web3';
|
|
||||||
|
|
||||||
export const web3 = web3Factory.create();
|
const web3 = web3Factory.create({ shouldUseInProcessGanache: true });
|
||||||
export const web3Wrapper = new Web3Wrapper(web3.currentProvider);
|
const provider: Provider = web3.currentProvider;
|
||||||
|
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
|
||||||
|
|
||||||
|
export { provider, web3Wrapper };
|
||||||
|
@@ -1,4 +1,68 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"timestamp": 1531149657,
|
||||||
|
"version": "0.3.3",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1529397769,
|
||||||
|
"version": "0.3.2",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "0.3.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Incorrect publish that was unpublished"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1527810075
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "0.3.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Properly export the executable binary",
|
||||||
|
"pr": 588
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1527008270
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1525477860,
|
||||||
|
"version": "0.2.13",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1525428773,
|
||||||
|
"version": "0.2.12",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1524044013,
|
||||||
|
"version": "0.2.11",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1523462196,
|
"timestamp": 1523462196,
|
||||||
"version": "0.2.10",
|
"version": "0.2.10",
|
||||||
|
@@ -5,6 +5,34 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v0.3.3 - _July 9, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.3.2 - _June 19, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.3.1 - _June 1, 2018_
|
||||||
|
|
||||||
|
* Incorrect publish that was unpublished
|
||||||
|
|
||||||
|
## v0.3.0 - _May 22, 2018_
|
||||||
|
|
||||||
|
* Properly export the executable binary (#588)
|
||||||
|
|
||||||
|
## v0.2.13 - _May 5, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.2.12 - _May 4, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.2.11 - _April 18, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
## v0.2.10 - _April 11, 2018_
|
## v0.2.10 - _April 11, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -80,28 +80,16 @@ yarn install
|
|||||||
|
|
||||||
### Build
|
### Build
|
||||||
|
|
||||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn lerna:rebuild
|
PKG=@0xproject/abi-gen yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
Or continuously rebuild on change:
|
Or continuously rebuild on change:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn dev
|
PKG=@0xproject/abi-gen yarn watch
|
||||||
```
|
|
||||||
|
|
||||||
You can also build this specific package by running the following from within its directory:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
or continuously rebuild on change:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn build:watch
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Clean
|
### Clean
|
||||||
|
2
packages/abi-gen/bin/abi-gen.js
Executable file
2
packages/abi-gen/bin/abi-gen.js
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
require('../lib/index.js')
|
@@ -1,18 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/abi-gen",
|
"name": "@0xproject/abi-gen",
|
||||||
"version": "0.2.10",
|
"version": "0.3.3",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.12"
|
||||||
|
},
|
||||||
"description": "Generate contract wrappers from ABI and handlebars templates",
|
"description": "Generate contract wrappers from ABI and handlebars templates",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:watch": "tsc -w",
|
"watch": "tsc -w",
|
||||||
"lint": "tslint --project . 'src/**/*.ts'",
|
"lint": "tslint --project .",
|
||||||
"clean": "shx rm -rf lib scripts",
|
"clean": "shx rm -rf lib scripts",
|
||||||
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
||||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"abi-gen": "lib/index.js"
|
"abi-gen": "bin/abi-gen.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -24,28 +27,29 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/types": "^0.6.0",
|
"@0xproject/types": "^0.8.2",
|
||||||
"@0xproject/typescript-typings": "^0.1.0",
|
"@0xproject/typescript-typings": "^0.4.2",
|
||||||
"@0xproject/utils": "^0.5.1",
|
"@0xproject/utils": "^0.7.2",
|
||||||
"chalk": "^2.3.0",
|
"chalk": "2.3.2",
|
||||||
"glob": "^7.1.2",
|
"glob": "7.1.1",
|
||||||
"handlebars": "^4.0.11",
|
"handlebars": "4.0.11",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "4.17.10",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "0.5.1",
|
||||||
"to-snake-case": "^1.0.0",
|
"to-snake-case": "1.0.0",
|
||||||
"yargs": "^10.0.3"
|
"yargs": "11.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||||
"@0xproject/tslint-config": "^0.4.15",
|
"@0xproject/tslint-config": "^0.4.21",
|
||||||
"@types/glob": "^5.0.33",
|
"@types/glob": "5.0.35",
|
||||||
"@types/handlebars": "^4.0.36",
|
"@types/handlebars": "4.0.36",
|
||||||
"@types/mkdirp": "^0.5.1",
|
"@types/mkdirp": "0.5.2",
|
||||||
"@types/node": "^8.0.53",
|
"@types/node": "9.6.0",
|
||||||
"@types/yargs": "^10.0.0",
|
"@types/yargs": "10.0.2",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "1.2.0",
|
||||||
"npm-run-all": "^4.1.2",
|
"make-promises-safe": "1.1.0",
|
||||||
"shx": "^0.2.2",
|
"npm-run-all": "4.1.2",
|
||||||
|
"shx": "0.2.2",
|
||||||
"tslint": "5.8.0",
|
"tslint": "5.8.0",
|
||||||
"typescript": "2.7.1"
|
"typescript": "2.7.1"
|
||||||
},
|
},
|
||||||
|
@@ -61,14 +61,13 @@ const args = yargs
|
|||||||
'Full usage example',
|
'Full usage example',
|
||||||
).argv;
|
).argv;
|
||||||
|
|
||||||
function registerPartials(partialsGlob: string) {
|
function registerPartials(partialsGlob: string): void {
|
||||||
const partialTemplateFileNames = globSync(partialsGlob);
|
const partialTemplateFileNames = globSync(partialsGlob);
|
||||||
logUtils.log(`Found ${chalk.green(`${partialTemplateFileNames.length}`)} ${chalk.bold('partial')} templates`);
|
logUtils.log(`Found ${chalk.green(`${partialTemplateFileNames.length}`)} ${chalk.bold('partial')} templates`);
|
||||||
for (const partialTemplateFileName of partialTemplateFileNames) {
|
for (const partialTemplateFileName of partialTemplateFileNames) {
|
||||||
const namedContent = utils.getNamedContent(partialTemplateFileName);
|
const namedContent = utils.getNamedContent(partialTemplateFileName);
|
||||||
Handlebars.registerPartial(namedContent.name, namedContent.content);
|
Handlebars.registerPartial(namedContent.name, namedContent.content);
|
||||||
}
|
}
|
||||||
return partialsGlob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeOutputFile(name: string, renderedTsCode: string): void {
|
function writeOutputFile(name: string, renderedTsCode: string): void {
|
||||||
@@ -108,13 +107,13 @@ for (const abiFileName of abiFileNames) {
|
|||||||
ABI = parsedContent; // ABI file
|
ABI = parsedContent; // ABI file
|
||||||
} else if (!_.isUndefined(parsedContent.abi)) {
|
} else if (!_.isUndefined(parsedContent.abi)) {
|
||||||
ABI = parsedContent.abi; // Truffle artifact
|
ABI = parsedContent.abi; // Truffle artifact
|
||||||
} else if (!_.isUndefined(parsedContent.networks) && !_.isUndefined(parsedContent.networks[args.networkId])) {
|
} else if (!_.isUndefined(parsedContent.compilerOutput.abi)) {
|
||||||
ABI = parsedContent.networks[args.networkId].abi; // 0x contracts package artifact
|
ABI = parsedContent.compilerOutput.abi; // 0x artifact
|
||||||
}
|
}
|
||||||
if (_.isUndefined(ABI)) {
|
if (_.isUndefined(ABI)) {
|
||||||
logUtils.log(`${chalk.red(`ABI not found in ${abiFileName}.`)}`);
|
logUtils.log(`${chalk.red(`ABI not found in ${abiFileName}.`)}`);
|
||||||
logUtils.log(
|
logUtils.log(
|
||||||
`Please make sure your ABI file is either an array with ABI entries or a truffle artifact or 0x deployer artifact`,
|
`Please make sure your ABI file is either an array with ABI entries or a truffle artifact or 0x sol-compiler artifact`,
|
||||||
);
|
);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,67 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"timestamp": 1531149657,
|
||||||
|
"version": "0.2.13",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1529397769,
|
||||||
|
"version": "0.2.12",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "0.2.11",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Incorrect publish that was unpublished"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1527810075
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1527008270,
|
||||||
|
"version": "0.2.10",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1525477860,
|
||||||
|
"version": "0.2.9",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1525428773,
|
||||||
|
"version": "0.2.8",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1524044013,
|
||||||
|
"version": "0.2.7",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1523462196,
|
"timestamp": 1523462196,
|
||||||
"version": "0.2.6",
|
"version": "0.2.6",
|
||||||
|
@@ -5,6 +5,34 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v0.2.13 - _July 9, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.2.12 - _June 19, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.2.11 - _June 1, 2018_
|
||||||
|
|
||||||
|
* Incorrect publish that was unpublished
|
||||||
|
|
||||||
|
## v0.2.10 - _May 22, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.2.9 - _May 5, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.2.8 - _May 4, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.2.7 - _April 18, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
## v0.2.6 - _April 11, 2018_
|
## v0.2.6 - _April 11, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -46,28 +46,16 @@ yarn install
|
|||||||
|
|
||||||
### Build
|
### Build
|
||||||
|
|
||||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn lerna:rebuild
|
PKG=@0xproject/assert yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
Or continuously rebuild on change:
|
Or continuously rebuild on change:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn dev
|
PKG=@0xproject/assert yarn watch
|
||||||
```
|
|
||||||
|
|
||||||
You can also build this specific package by running the following from within its directory:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
or continuously rebuild on change:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn build:watch
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Clean
|
### Clean
|
||||||
|
@@ -1,15 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/assert",
|
"name": "@0xproject/assert",
|
||||||
"version": "0.2.6",
|
"version": "0.2.13",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.12"
|
||||||
|
},
|
||||||
"description": "Provides a standard way of performing type and schema validation across 0x projects",
|
"description": "Provides a standard way of performing type and schema validation across 0x projects",
|
||||||
"main": "lib/src/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:watch": "tsc -w",
|
"watch": "tsc -w",
|
||||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||||
"clean": "shx rm -rf lib test_temp scripts",
|
"clean": "shx rm -rf lib test_temp scripts",
|
||||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
"lint": "tslint --project .",
|
||||||
"run_mocha": "mocha lib/test/**/*_test.js",
|
"run_mocha": "mocha lib/test/**/*_test.js --exit",
|
||||||
"prepublishOnly": "run-p build",
|
"prepublishOnly": "run-p build",
|
||||||
"test": "run-s clean build run_mocha",
|
"test": "run-s clean build run_mocha",
|
||||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||||
@@ -27,27 +30,28 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||||
"@0xproject/tslint-config": "^0.4.15",
|
"@0xproject/tslint-config": "^0.4.21",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/mocha": "^2.2.42",
|
"@types/mocha": "2.2.48",
|
||||||
"@types/valid-url": "^1.0.2",
|
"@types/valid-url": "1.0.2",
|
||||||
"chai": "^4.0.1",
|
"chai": "4.1.2",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "1.2.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "2.0.1",
|
||||||
"mocha": "^4.0.1",
|
"make-promises-safe": "1.1.0",
|
||||||
"npm-run-all": "^4.1.2",
|
"mocha": "4.1.0",
|
||||||
"nyc": "^11.0.1",
|
"npm-run-all": "4.1.2",
|
||||||
"shx": "^0.2.2",
|
"nyc": "11.6.0",
|
||||||
|
"shx": "0.2.2",
|
||||||
"tslint": "5.8.0",
|
"tslint": "5.8.0",
|
||||||
"typescript": "2.7.1"
|
"typescript": "2.7.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/json-schemas": "^0.7.20",
|
"@0xproject/json-schemas": "^0.8.2",
|
||||||
"@0xproject/typescript-typings": "^0.1.0",
|
"@0xproject/typescript-typings": "^0.4.2",
|
||||||
"@0xproject/utils": "^0.5.1",
|
"@0xproject/utils": "^0.7.2",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "4.17.10",
|
||||||
"valid-url": "^1.0.9"
|
"valid-url": "1.0.9"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
@@ -10,7 +10,7 @@ export const assert = {
|
|||||||
const isBigNumber = _.isObject(value) && (value as any).isBigNumber;
|
const isBigNumber = _.isObject(value) && (value as any).isBigNumber;
|
||||||
this.assert(isBigNumber, this.typeAssertionMessage(variableName, 'BigNumber', value));
|
this.assert(isBigNumber, this.typeAssertionMessage(variableName, 'BigNumber', value));
|
||||||
},
|
},
|
||||||
isValidBaseUnitAmount(variableName: string, value: BigNumber) {
|
isValidBaseUnitAmount(variableName: string, value: BigNumber): void {
|
||||||
assert.isBigNumber(variableName, value);
|
assert.isBigNumber(variableName, value);
|
||||||
const isNegative = value.lessThan(0);
|
const isNegative = value.lessThan(0);
|
||||||
this.assert(!isNegative, `${variableName} cannot be a negative number, found value: ${value.toNumber()}`);
|
this.assert(!isNegative, `${variableName} cannot be a negative number, found value: ${value.toNumber()}`);
|
||||||
|
@@ -2,6 +2,7 @@ import { schemas } from '@0xproject/json-schemas';
|
|||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as dirtyChai from 'dirty-chai';
|
import * as dirtyChai from 'dirty-chai';
|
||||||
|
import 'make-promises-safe';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
|
|
||||||
import { assert } from '../src/index';
|
import { assert } from '../src/index';
|
||||||
@@ -10,6 +11,7 @@ chai.config.includeStack = true;
|
|||||||
chai.use(dirtyChai);
|
chai.use(dirtyChai);
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
|
|
||||||
|
// tslint:disable:custom-no-magic-numbers
|
||||||
describe('Assertions', () => {
|
describe('Assertions', () => {
|
||||||
const variableName = 'variable';
|
const variableName = 'variable';
|
||||||
describe('#isBigNumber', () => {
|
describe('#isBigNumber', () => {
|
||||||
@@ -251,3 +253,4 @@ describe('Assertions', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// tslint:enable:custom-no-magic-numbers
|
||||||
|
@@ -1,4 +1,69 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"timestamp": 1531149657,
|
||||||
|
"version": "0.3.5",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "0.3.4",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Update EthersJs to fix the `value.toLowerCase()` is not a function bug caused by `ethers.js` breaking patch version https://github.com/ethers-io/ethers.js/issues/201"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1529397769
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1527810075,
|
||||||
|
"version": "0.3.3",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Incorrect publish that was unpublished"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1527008270,
|
||||||
|
"version": "0.3.2",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1525477860,
|
||||||
|
"version": "0.3.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "0.3.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Update ethers-contracts to ethers.js",
|
||||||
|
"pr": 540
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1525428773
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1524044013,
|
||||||
|
"version": "0.2.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@@ -5,6 +5,34 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v0.3.5 - _July 9, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.3.4 - _June 19, 2018_
|
||||||
|
|
||||||
|
* Update EthersJs to fix the `value.toLowerCase()` is not a function bug caused by `ethers.js` breaking patch version https://github.com/ethers-io/ethers.js/issues/201
|
||||||
|
|
||||||
|
## v0.3.3 - _June 1, 2018_
|
||||||
|
|
||||||
|
* Incorrect publish that was unpublished
|
||||||
|
|
||||||
|
## v0.3.2 - _May 22, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.3.1 - _May 5, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.3.0 - _May 4, 2018_
|
||||||
|
|
||||||
|
* Update ethers-contracts to ethers.js (#540)
|
||||||
|
|
||||||
|
## v0.2.1 - _April 18, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
## v0.2.0 - _April 11, 2018_
|
## v0.2.0 - _April 11, 2018_
|
||||||
|
|
||||||
* Contract wrappers now accept Provider and defaults instead of Web3Wrapper (#501)
|
* Contract wrappers now accept Provider and defaults instead of Web3Wrapper (#501)
|
||||||
|
@@ -44,14 +44,16 @@ yarn install
|
|||||||
|
|
||||||
### Build
|
### Build
|
||||||
|
|
||||||
|
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn build
|
PKG=@0xproject/base-contract yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
Or continuously rebuild on change:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn build:watch
|
PKG=@0xproject/base-contract yarn watch
|
||||||
```
|
```
|
||||||
|
|
||||||
### Lint
|
### Lint
|
||||||
|
@@ -1,11 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/base-contract",
|
"name": "@0xproject/base-contract",
|
||||||
"version": "0.2.0",
|
"version": "0.3.5",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.12"
|
||||||
|
},
|
||||||
"description": "0x Base TS contract",
|
"description": "0x Base TS contract",
|
||||||
"main": "lib/src/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:watch": "tsc -w",
|
"watch": "tsc -w",
|
||||||
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
||||||
"clean": "shx rm -rf lib scripts",
|
"clean": "shx rm -rf lib scripts",
|
||||||
"test": "run-s clean build run_mocha",
|
"test": "run-s clean build run_mocha",
|
||||||
@@ -26,24 +29,25 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||||
"@0xproject/tslint-config": "^0.4.15",
|
"@0xproject/tslint-config": "^0.4.21",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"chai": "^4.0.1",
|
"chai": "4.1.2",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "1.2.0",
|
||||||
"mocha": "^4.0.1",
|
"make-promises-safe": "1.1.0",
|
||||||
"npm-run-all": "^4.1.2",
|
"mocha": "4.1.0",
|
||||||
"shx": "^0.2.2",
|
"npm-run-all": "4.1.2",
|
||||||
|
"shx": "0.2.2",
|
||||||
"tslint": "5.8.0",
|
"tslint": "5.8.0",
|
||||||
"typescript": "2.7.1"
|
"typescript": "2.7.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/types": "^0.6.0",
|
"@0xproject/types": "^0.8.2",
|
||||||
"@0xproject/typescript-typings": "^0.1.0",
|
"@0xproject/typescript-typings": "^0.4.2",
|
||||||
"@0xproject/utils": "^0.5.1",
|
"@0xproject/utils": "^0.7.2",
|
||||||
"@0xproject/web3-wrapper": "^0.6.0",
|
"@0xproject/web3-wrapper": "^0.7.2",
|
||||||
"ethers-contracts": "^2.2.1",
|
"ethers": "3.0.22",
|
||||||
"lodash": "^4.17.4"
|
"lodash": "4.17.10"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
AbiDefinition,
|
AbiDefinition,
|
||||||
AbiType,
|
AbiType,
|
||||||
|
ConstructorAbi,
|
||||||
ContractAbi,
|
ContractAbi,
|
||||||
DataItem,
|
DataItem,
|
||||||
MethodAbi,
|
MethodAbi,
|
||||||
@@ -10,13 +11,13 @@ import {
|
|||||||
} from '@0xproject/types';
|
} from '@0xproject/types';
|
||||||
import { abiUtils, BigNumber } from '@0xproject/utils';
|
import { abiUtils, BigNumber } from '@0xproject/utils';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import * as ethersContracts from 'ethers-contracts';
|
import * as ethers from 'ethers';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { formatABIDataItem } from './utils';
|
import { formatABIDataItem } from './utils';
|
||||||
|
|
||||||
export interface EthersInterfaceByFunctionSignature {
|
export interface EthersInterfaceByFunctionSignature {
|
||||||
[key: string]: ethersContracts.Interface;
|
[key: string]: ethers.Interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BaseContract {
|
export class BaseContract {
|
||||||
@@ -24,6 +25,8 @@ export class BaseContract {
|
|||||||
protected _web3Wrapper: Web3Wrapper;
|
protected _web3Wrapper: Web3Wrapper;
|
||||||
public abi: ContractAbi;
|
public abi: ContractAbi;
|
||||||
public address: string;
|
public address: string;
|
||||||
|
public contractName: string;
|
||||||
|
public constructorArgs: any[] = [];
|
||||||
protected static _formatABIDataItemList(
|
protected static _formatABIDataItemList(
|
||||||
abis: DataItem[],
|
abis: DataItem[],
|
||||||
values: any[],
|
values: any[],
|
||||||
@@ -37,11 +40,31 @@ export class BaseContract {
|
|||||||
protected static _bigNumberToString(type: string, value: any): any {
|
protected static _bigNumberToString(type: string, value: any): any {
|
||||||
return _.isObject(value) && value.isBigNumber ? value.toString() : value;
|
return _.isObject(value) && value.isBigNumber ? value.toString() : value;
|
||||||
}
|
}
|
||||||
|
protected static _lookupConstructorAbi(abi: ContractAbi): ConstructorAbi {
|
||||||
|
const constructorAbiIfExists = _.find(
|
||||||
|
abi,
|
||||||
|
(abiDefinition: AbiDefinition) => abiDefinition.type === AbiType.Constructor,
|
||||||
|
) as ConstructorAbi | undefined;
|
||||||
|
if (!_.isUndefined(constructorAbiIfExists)) {
|
||||||
|
return constructorAbiIfExists;
|
||||||
|
} else {
|
||||||
|
// If the constructor is not explicitly defined, it won't be included in the ABI. It is
|
||||||
|
// still callable however, so we construct what the ABI would look like were it to exist.
|
||||||
|
const defaultConstructorAbi: ConstructorAbi = {
|
||||||
|
type: AbiType.Constructor,
|
||||||
|
stateMutability: 'nonpayable',
|
||||||
|
payable: false,
|
||||||
|
inputs: [],
|
||||||
|
};
|
||||||
|
return defaultConstructorAbi;
|
||||||
|
}
|
||||||
|
}
|
||||||
protected static _bnToBigNumber(type: string, value: any): any {
|
protected static _bnToBigNumber(type: string, value: any): any {
|
||||||
return _.isObject(value) && value._bn ? new BigNumber(value.toString()) : value;
|
return _.isObject(value) && value._bn ? new BigNumber(value.toString()) : value;
|
||||||
}
|
}
|
||||||
protected async _applyDefaultsToTxDataAsync<T extends Partial<TxData | TxDataPayable>>(
|
protected static async _applyDefaultsToTxDataAsync<T extends Partial<TxData | TxDataPayable>>(
|
||||||
txData: T,
|
txData: T,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
estimateGasAsync?: (txData: T) => Promise<number>,
|
estimateGasAsync?: (txData: T) => Promise<number>,
|
||||||
): Promise<TxData> {
|
): Promise<TxData> {
|
||||||
// Gas amount sourced with the following priorities:
|
// Gas amount sourced with the following priorities:
|
||||||
@@ -49,20 +72,19 @@ export class BaseContract {
|
|||||||
// 2. Global config passed in at library instantiation
|
// 2. Global config passed in at library instantiation
|
||||||
// 3. Gas estimate calculation + safety margin
|
// 3. Gas estimate calculation + safety margin
|
||||||
const removeUndefinedProperties = _.pickBy;
|
const removeUndefinedProperties = _.pickBy;
|
||||||
const txDataWithDefaults = ({
|
const txDataWithDefaults: TxData = {
|
||||||
to: this.address,
|
...removeUndefinedProperties(txDefaults),
|
||||||
...removeUndefinedProperties(this._web3Wrapper.getContractDefaults()),
|
|
||||||
...removeUndefinedProperties(txData as any),
|
...removeUndefinedProperties(txData as any),
|
||||||
// HACK: TS can't prove that T is spreadable.
|
// HACK: TS can't prove that T is spreadable.
|
||||||
// Awaiting https://github.com/Microsoft/TypeScript/pull/13288 to be merged
|
// Awaiting https://github.com/Microsoft/TypeScript/pull/13288 to be merged
|
||||||
} as any) as TxData;
|
} as any;
|
||||||
if (_.isUndefined(txDataWithDefaults.gas) && !_.isUndefined(estimateGasAsync)) {
|
if (_.isUndefined(txDataWithDefaults.gas) && !_.isUndefined(estimateGasAsync)) {
|
||||||
const estimatedGas = await estimateGasAsync(txData);
|
const estimatedGas = await estimateGasAsync(txData);
|
||||||
txDataWithDefaults.gas = estimatedGas;
|
txDataWithDefaults.gas = estimatedGas;
|
||||||
}
|
}
|
||||||
return txDataWithDefaults;
|
return txDataWithDefaults;
|
||||||
}
|
}
|
||||||
protected _lookupEthersInterface(functionSignature: string): ethersContracts.Interface {
|
protected _lookupEthersInterface(functionSignature: string): ethers.Interface {
|
||||||
const ethersInterface = this._ethersInterfacesByFunctionSignature[functionSignature];
|
const ethersInterface = this._ethersInterfacesByFunctionSignature[functionSignature];
|
||||||
if (_.isUndefined(ethersInterface)) {
|
if (_.isUndefined(ethersInterface)) {
|
||||||
throw new Error(`Failed to lookup method with function signature '${functionSignature}'`);
|
throw new Error(`Failed to lookup method with function signature '${functionSignature}'`);
|
||||||
@@ -82,8 +104,15 @@ export class BaseContract {
|
|||||||
}) as MethodAbi;
|
}) as MethodAbi;
|
||||||
return methodAbi;
|
return methodAbi;
|
||||||
}
|
}
|
||||||
constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial<TxData>) {
|
constructor(
|
||||||
this._web3Wrapper = new Web3Wrapper(provider, defaults);
|
contractName: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
address: string,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults?: Partial<TxData>,
|
||||||
|
) {
|
||||||
|
this.contractName = contractName;
|
||||||
|
this._web3Wrapper = new Web3Wrapper(provider, txDefaults);
|
||||||
this.abi = abi;
|
this.abi = abi;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
const methodAbis = this.abi.filter(
|
const methodAbis = this.abi.filter(
|
||||||
@@ -92,7 +121,7 @@ export class BaseContract {
|
|||||||
this._ethersInterfacesByFunctionSignature = {};
|
this._ethersInterfacesByFunctionSignature = {};
|
||||||
_.each(methodAbis, methodAbi => {
|
_.each(methodAbis, methodAbi => {
|
||||||
const functionSignature = abiUtils.getFunctionSignature(methodAbi);
|
const functionSignature = abiUtils.getFunctionSignature(methodAbi);
|
||||||
this._ethersInterfacesByFunctionSignature[functionSignature] = new ethersContracts.Interface([methodAbi]);
|
this._ethersInterfacesByFunctionSignature[functionSignature] = new ethers.Interface([methodAbi]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
|
import 'make-promises-safe';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
|
|
||||||
import { formatABIDataItem } from '../src/utils';
|
import { formatABIDataItem } from '../src/utils';
|
||||||
|
@@ -1,4 +1,67 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"timestamp": 1531149657,
|
||||||
|
"version": "0.6.16",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1529397769,
|
||||||
|
"version": "0.6.15",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1527616612,
|
||||||
|
"version": "0.6.14",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1527008270,
|
||||||
|
"version": "0.6.13",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1525477860,
|
||||||
|
"version": "0.6.12",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1525428773,
|
||||||
|
"version": "0.6.11",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1524044013,
|
||||||
|
"version": "0.6.10",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1523462196,
|
"timestamp": 1523462196,
|
||||||
"version": "0.6.9",
|
"version": "0.6.9",
|
||||||
|
@@ -5,6 +5,34 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
## v0.6.16 - _July 9, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.6.15 - _June 19, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.6.14 - _May 29, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.6.13 - _May 22, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.6.12 - _May 5, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.6.11 - _May 4, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.6.10 - _April 18, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
## v0.6.9 - _April 11, 2018_
|
## v0.6.9 - _April 11, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
@@ -43,28 +43,16 @@ yarn install
|
|||||||
|
|
||||||
### Build
|
### Build
|
||||||
|
|
||||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn lerna:rebuild
|
PKG=@0xproject/connect yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
Or continuously rebuild on change:
|
Or continuously rebuild on change:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn dev
|
PKG=@0xproject/connect yarn watch
|
||||||
```
|
|
||||||
|
|
||||||
You can also build this specific package by running the following from within its directory:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
or continuously rebuild on change:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn build:watch
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Clean
|
### Clean
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/connect",
|
"name": "@0xproject/connect",
|
||||||
"version": "0.6.9",
|
"version": "0.6.16",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.12"
|
||||||
|
},
|
||||||
"description": "A javascript library for interacting with the standard relayer api",
|
"description": "A javascript library for interacting with the standard relayer api",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"connect",
|
"connect",
|
||||||
@@ -12,18 +15,18 @@
|
|||||||
"main": "lib/src/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:watch": "tsc -w",
|
"watch": "tsc -w",
|
||||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||||
"clean": "shx rm -rf lib test_temp scripts",
|
"clean": "shx rm -rf lib test_temp scripts",
|
||||||
"copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
|
"copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
|
||||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
"lint": "tslint --project .",
|
||||||
"run_mocha": "mocha lib/test/**/*_test.js",
|
"run_mocha": "mocha lib/test/**/*_test.js --exit",
|
||||||
"test": "run-s clean build copy_test_fixtures run_mocha",
|
"test": "run-s clean build copy_test_fixtures run_mocha",
|
||||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||||
"test:circleci": "yarn test:coverage",
|
"test:circleci": "yarn test:coverage",
|
||||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
|
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
|
||||||
"docs:stage": "yarn build && node ./scripts/stage_docs.js",
|
"docs:stage": "node scripts/stage_docs.js",
|
||||||
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
|
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
|
||||||
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
|
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
|
||||||
},
|
},
|
||||||
@@ -42,44 +45,42 @@
|
|||||||
},
|
},
|
||||||
"author": "Brandon Millman",
|
"author": "Brandon Millman",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"engines": {
|
|
||||||
"node": ">=6.0.0"
|
|
||||||
},
|
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/0xProject/0x-monorepo/issues"
|
"url": "https://github.com/0xProject/0x-monorepo/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/assert": "^0.2.6",
|
"@0xproject/assert": "^0.2.13",
|
||||||
"@0xproject/json-schemas": "^0.7.20",
|
"@0xproject/json-schemas": "^0.8.2",
|
||||||
"@0xproject/types": "^0.6.0",
|
"@0xproject/types": "^0.8.2",
|
||||||
"@0xproject/typescript-typings": "^0.1.0",
|
"@0xproject/typescript-typings": "^0.4.2",
|
||||||
"@0xproject/utils": "^0.5.1",
|
"@0xproject/utils": "^0.7.2",
|
||||||
"isomorphic-fetch": "^2.2.1",
|
"isomorphic-fetch": "2.2.1",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "4.17.10",
|
||||||
"query-string": "^5.0.1",
|
"query-string": "4.3.4",
|
||||||
"websocket": "^1.0.25"
|
"websocket": "1.0.25"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||||
"@0xproject/tslint-config": "^0.4.15",
|
"@0xproject/tslint-config": "^0.4.21",
|
||||||
"@types/fetch-mock": "^5.12.1",
|
"@types/fetch-mock": "5.12.2",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/mocha": "^2.2.42",
|
"@types/mocha": "2.2.48",
|
||||||
"@types/query-string": "^5.0.1",
|
"@types/query-string": "5.1.0",
|
||||||
"@types/websocket": "^0.0.34",
|
"@types/websocket": "0.0.34",
|
||||||
"async-child-process": "^1.1.1",
|
"async-child-process": "1.1.1",
|
||||||
"chai": "^4.0.1",
|
"chai": "4.1.2",
|
||||||
"chai-as-promised": "^7.1.0",
|
"chai-as-promised": "7.1.1",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "1.2.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "2.0.1",
|
||||||
"fetch-mock": "^5.13.1",
|
"fetch-mock": "5.13.1",
|
||||||
"mocha": "^4.0.1",
|
"make-promises-safe": "1.1.0",
|
||||||
"npm-run-all": "^4.1.2",
|
"mocha": "4.1.0",
|
||||||
"nyc": "^11.0.1",
|
"npm-run-all": "4.1.2",
|
||||||
"shx": "^0.2.2",
|
"nyc": "11.6.0",
|
||||||
|
"shx": "0.2.2",
|
||||||
"tslint": "5.8.0",
|
"tslint": "5.8.0",
|
||||||
"typedoc": "~0.8.0",
|
"typedoc": "0.8.0",
|
||||||
"typescript": "2.7.1"
|
"typescript": "2.7.1"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
@@ -15,14 +15,14 @@ export interface OrderbookChannel {
|
|||||||
close: () => void;
|
close: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* heartbeatInterval: Interval in milliseconds that the orderbook channel should ping the underlying websocket. Default: 15000
|
* heartbeatIntervalMs: Interval in milliseconds that the orderbook channel should ping the underlying websocket. Default: 15000
|
||||||
*/
|
*/
|
||||||
export interface WebSocketOrderbookChannelConfig {
|
export interface WebSocketOrderbookChannelConfig {
|
||||||
heartbeatIntervalMs?: number;
|
heartbeatIntervalMs?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* baseTokenAddress: The address of token designated as the baseToken in the currency pair calculation of price
|
* baseTokenAddress: The address of token designated as the baseToken in the currency pair calculation of price
|
||||||
* quoteTokenAddress: The address of token designated as the quoteToken in the currency pair calculation of price
|
* quoteTokenAddress: The address of token designated as the quoteToken in the currency pair calculation of price
|
||||||
* snapshot: If true, a snapshot of the orderbook will be sent before the updates to the orderbook
|
* snapshot: If true, a snapshot of the orderbook will be sent before the updates to the orderbook
|
||||||
|
@@ -91,7 +91,7 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
|
|||||||
/**
|
/**
|
||||||
* Close the websocket and stop receiving updates
|
* Close the websocket and stop receiving updates
|
||||||
*/
|
*/
|
||||||
public close() {
|
public close(): void {
|
||||||
if (!_.isUndefined(this._connectionIfExists)) {
|
if (!_.isUndefined(this._connectionIfExists)) {
|
||||||
this._connectionIfExists.close();
|
this._connectionIfExists.close();
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
|
|||||||
clearInterval(this._heartbeatTimerIfExists);
|
clearInterval(this._heartbeatTimerIfExists);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private _getConnection(callback: (error?: Error, connection?: WebSocket.connection) => void) {
|
private _getConnection(callback: (error?: Error, connection?: WebSocket.connection) => void): void {
|
||||||
if (!_.isUndefined(this._connectionIfExists) && this._connectionIfExists.connected) {
|
if (!_.isUndefined(this._connectionIfExists) && this._connectionIfExists.connected) {
|
||||||
callback(undefined, this._connectionIfExists);
|
callback(undefined, this._connectionIfExists);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -3,6 +3,7 @@ import * as chai from 'chai';
|
|||||||
import * as chaiAsPromised from 'chai-as-promised';
|
import * as chaiAsPromised from 'chai-as-promised';
|
||||||
import * as dirtyChai from 'dirty-chai';
|
import * as dirtyChai from 'dirty-chai';
|
||||||
import * as fetchMock from 'fetch-mock';
|
import * as fetchMock from 'fetch-mock';
|
||||||
|
import 'make-promises-safe';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
|
|
||||||
import { HttpClient } from '../src/index';
|
import { HttpClient } from '../src/index';
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as dirtyChai from 'dirty-chai';
|
import * as dirtyChai from 'dirty-chai';
|
||||||
|
import 'make-promises-safe';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
|
|
||||||
import { orderbookChannelMessageParser } from '../src/utils/orderbook_channel_message_parser';
|
import { orderbookChannelMessageParser } from '../src/utils/orderbook_channel_message_parser';
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as dirtyChai from 'dirty-chai';
|
import * as dirtyChai from 'dirty-chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
import 'make-promises-safe';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
|
|
||||||
import { WebSocketOrderbookChannel } from '../src/ws_orderbook_channel';
|
import { WebSocketOrderbookChannel } from '../src/ws_orderbook_channel';
|
||||||
|
11
packages/contract-wrappers/.npmignore
Normal file
11
packages/contract-wrappers/.npmignore
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
.*
|
||||||
|
tsconfig.json
|
||||||
|
webpack.config.js
|
||||||
|
yarn-error.log
|
||||||
|
test/
|
||||||
|
/src/
|
||||||
|
/_bundles/
|
||||||
|
/contract_templates/
|
||||||
|
/generated_docs/
|
||||||
|
/scripts/
|
||||||
|
/lib/src/monorepo_scripts/
|
58
packages/contract-wrappers/CHANGELOG.json
Normal file
58
packages/contract-wrappers/CHANGELOG.json
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"version": "0.1.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Update Blockstream dep. to V5.0 and no longer force unsubscribe on blockstream error (which are not recoverable)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1531149657
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1529397769,
|
||||||
|
"version": "0.0.5",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1527617227,
|
||||||
|
"version": "0.0.4",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1527616612,
|
||||||
|
"version": "0.0.3",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "0.0.2",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1527008544
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1527008270,
|
||||||
|
"version": "0.0.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Moved contractWrappers out of 0x.js",
|
||||||
|
"pr": 579
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
30
packages/contract-wrappers/CHANGELOG.md
Normal file
30
packages/contract-wrappers/CHANGELOG.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<!--
|
||||||
|
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||||
|
Edit the package's CHANGELOG.json file only.
|
||||||
|
-->
|
||||||
|
|
||||||
|
CHANGELOG
|
||||||
|
|
||||||
|
## v0.1.0 - _July 9, 2018_
|
||||||
|
|
||||||
|
* Update Blockstream dep. to V5.0 and no longer force unsubscribe on blockstream error (which are not recoverable)
|
||||||
|
|
||||||
|
## v0.0.5 - _June 19, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.0.4 - _May 29, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.0.3 - _May 29, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.0.2 - _May 22, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v0.0.1 - _May 22, 2018_
|
||||||
|
|
||||||
|
* Moved contractWrappers out of 0x.js (#579)
|
89
packages/contract-wrappers/README.md
Normal file
89
packages/contract-wrappers/README.md
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
## @0xproject/contract-wrappers
|
||||||
|
|
||||||
|
Smart TS wrappers for 0x smart contracts. The wrappers have simplified interfaces, perform client-side validation on transactions and throw helpful error messages.
|
||||||
|
|
||||||
|
### Read the [Documentation](https://0xproject.com/docs/0x.js).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
**Install**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install @0xproject/contract-wrappers --save
|
||||||
|
```
|
||||||
|
|
||||||
|
**Import**
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import { ContractWrappers } from '@0xproject/contract-wrappers';
|
||||||
|
```
|
||||||
|
|
||||||
|
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"compilerOptions": {
|
||||||
|
"typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
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=@0xproject/contract-wrappers yarn build
|
||||||
|
```
|
||||||
|
|
||||||
|
Or continuously rebuild on change:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PKG=@0xproject/contract-wrappers yarn watch
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn build
|
||||||
|
```
|
||||||
|
|
||||||
|
or continuously rebuild on change:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn watch
|
||||||
|
```
|
||||||
|
|
||||||
|
### Clean
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn clean
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lint
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn lint
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn test
|
||||||
|
```
|
92
packages/contract-wrappers/package.json
Normal file
92
packages/contract-wrappers/package.json
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
{
|
||||||
|
"name": "@0xproject/contract-wrappers",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Smart TS wrappers for 0x smart contracts",
|
||||||
|
"keywords": [
|
||||||
|
"0xproject",
|
||||||
|
"ethereum",
|
||||||
|
"tokens",
|
||||||
|
"exchange"
|
||||||
|
],
|
||||||
|
"main": "lib/src/index.js",
|
||||||
|
"types": "lib/src/index.d.ts",
|
||||||
|
"scripts": {
|
||||||
|
"watch": "tsc -w",
|
||||||
|
"prebuild": "run-s clean generate_contract_wrappers",
|
||||||
|
"generate_contract_wrappers": "abi-gen --abis 'src/compact_artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
|
||||||
|
"lint": "tslint --project .",
|
||||||
|
"test:circleci": "run-s test:coverage",
|
||||||
|
"test": "run-s clean build run_mocha",
|
||||||
|
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||||
|
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||||
|
"update_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/artifacts/1.0.0/$i.json test/artifacts; done;",
|
||||||
|
"clean": "shx rm -rf _bundles lib test_temp scripts test/artifacts src/contract_wrappers/generated",
|
||||||
|
"build": "tsc && yarn update_artifacts && copyfiles -u 2 './src/compact_artifacts/**/*.json' ./lib/src/compact_artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||||
|
"run_mocha": "mocha lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
|
||||||
|
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"compact_artifacts": "Exchange DummyToken ZRXToken Token EtherToken TokenTransferProxy TokenRegistry",
|
||||||
|
"contracts": "Exchange DummyToken ZRXToken Token WETH9 TokenTransferProxy MultiSigWallet MultiSigWalletWithTimeLock MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress MaliciousToken TokenRegistry Arbitrage EtherDelta AccountLevels"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/0xProject/0x-monorepo"
|
||||||
|
},
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@0xproject/abi-gen": "^0.3.3",
|
||||||
|
"@0xproject/dev-utils": "^0.4.5",
|
||||||
|
"@0xproject/migrations": "^0.0.9",
|
||||||
|
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||||
|
"@0xproject/sol-compiler": "^0.5.3",
|
||||||
|
"@0xproject/subproviders": "^0.10.5",
|
||||||
|
"@0xproject/tslint-config": "^0.4.21",
|
||||||
|
"@types/lodash": "4.14.104",
|
||||||
|
"@types/mocha": "2.2.48",
|
||||||
|
"@types/node": "9.6.0",
|
||||||
|
"@types/sinon": "2.3.7",
|
||||||
|
"@types/uuid": "3.4.3",
|
||||||
|
"awesome-typescript-loader": "3.5.0",
|
||||||
|
"chai": "4.1.2",
|
||||||
|
"chai-as-promised": "7.1.1",
|
||||||
|
"chai-bignumber": "2.0.1",
|
||||||
|
"copyfiles": "1.2.0",
|
||||||
|
"dirty-chai": "2.0.1",
|
||||||
|
"make-promises-safe": "1.1.0",
|
||||||
|
"mocha": "4.1.0",
|
||||||
|
"npm-run-all": "4.1.2",
|
||||||
|
"nyc": "11.6.0",
|
||||||
|
"opn-cli": "3.1.0",
|
||||||
|
"prettier": "1.12.1",
|
||||||
|
"shx": "0.2.2",
|
||||||
|
"sinon": "4.4.9",
|
||||||
|
"source-map-support": "0.5.4",
|
||||||
|
"tslint": "5.8.0",
|
||||||
|
"typescript": "2.7.1",
|
||||||
|
"web3-provider-engine": "13.8.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@0xproject/assert": "^0.2.13",
|
||||||
|
"@0xproject/base-contract": "^0.3.5",
|
||||||
|
"@0xproject/fill-scenarios": "^0.0.5",
|
||||||
|
"@0xproject/json-schemas": "^0.8.2",
|
||||||
|
"@0xproject/order-utils": "^0.0.8",
|
||||||
|
"@0xproject/types": "^0.8.2",
|
||||||
|
"@0xproject/typescript-typings": "^0.4.2",
|
||||||
|
"@0xproject/utils": "^0.7.2",
|
||||||
|
"@0xproject/web3-wrapper": "^0.7.2",
|
||||||
|
"ethereumjs-blockstream": "5.0.0",
|
||||||
|
"ethereumjs-util": "5.1.5",
|
||||||
|
"ethers": "3.0.22",
|
||||||
|
"js-sha3": "0.7.0",
|
||||||
|
"lodash": "4.17.10",
|
||||||
|
"uuid": "3.2.1"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
}
|
||||||
|
}
|
18
packages/contract-wrappers/src/artifacts.ts
Normal file
18
packages/contract-wrappers/src/artifacts.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { Artifact } from '@0xproject/types';
|
||||||
|
|
||||||
|
import * as DummyToken from './compact_artifacts/DummyToken.json';
|
||||||
|
import * as EtherToken from './compact_artifacts/EtherToken.json';
|
||||||
|
import * as Exchange from './compact_artifacts/Exchange.json';
|
||||||
|
import * as Token from './compact_artifacts/Token.json';
|
||||||
|
import * as TokenRegistry from './compact_artifacts/TokenRegistry.json';
|
||||||
|
import * as TokenTransferProxy from './compact_artifacts/TokenTransferProxy.json';
|
||||||
|
import * as ZRX from './compact_artifacts/ZRX.json';
|
||||||
|
export const artifacts = {
|
||||||
|
ZRX: (ZRX as any) as Artifact,
|
||||||
|
DummyToken: (DummyToken as any) as Artifact,
|
||||||
|
Token: (Token as any) as Artifact,
|
||||||
|
Exchange: (Exchange as any) as Artifact,
|
||||||
|
EtherToken: (EtherToken as any) as Artifact,
|
||||||
|
TokenRegistry: (TokenRegistry as any) as Artifact,
|
||||||
|
TokenTransferProxy: (TokenTransferProxy as any) as Artifact,
|
||||||
|
};
|
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"contract_name": "DummyToken",
|
||||||
|
"abi": [
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_target",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "setBalance",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
287
packages/contract-wrappers/src/compact_artifacts/EtherToken.json
Normal file
287
packages/contract-wrappers/src/compact_artifacts/EtherToken.json
Normal file
@@ -0,0 +1,287 @@
|
|||||||
|
{
|
||||||
|
"contract_name": "EtherToken",
|
||||||
|
"abi": [
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "name",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "approve",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "totalSupply",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_from",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transferFrom",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "amount",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "withdraw",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "decimals",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint8"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "balanceOf",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "symbol",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transfer",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "deposit",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": true,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "allowance",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"payable": true,
|
||||||
|
"type": "fallback"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_from",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Transfer",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Approval",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Deposit",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Withdrawal",
|
||||||
|
"type": "event"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"networks": {
|
||||||
|
"1": {
|
||||||
|
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
||||||
|
},
|
||||||
|
"3": {
|
||||||
|
"address": "0xc00fd9820cd2898cc4c054b7bf142de637ad129a"
|
||||||
|
},
|
||||||
|
"4": {
|
||||||
|
"address": "0xc778417e063141139fce010982780140aa0cd5ab"
|
||||||
|
},
|
||||||
|
"42": {
|
||||||
|
"address": "0x653e49e301e508a13237c0ddc98ae7d4cd2667a1"
|
||||||
|
},
|
||||||
|
"50": {
|
||||||
|
"address": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
610
packages/contract-wrappers/src/compact_artifacts/Exchange.json
Normal file
610
packages/contract-wrappers/src/compact_artifacts/Exchange.json
Normal file
@@ -0,0 +1,610 @@
|
|||||||
|
{
|
||||||
|
"contract_name": "Exchange",
|
||||||
|
"abi": [
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "numerator",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "denominator",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "target",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "isRoundingError",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "filled",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "cancelled",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "orderAddresses",
|
||||||
|
"type": "address[5][]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "orderValues",
|
||||||
|
"type": "uint256[6][]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fillTakerTokenAmount",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "shouldThrowOnInsufficientBalanceOrAllowance",
|
||||||
|
"type": "bool"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v",
|
||||||
|
"type": "uint8[]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "r",
|
||||||
|
"type": "bytes32[]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "s",
|
||||||
|
"type": "bytes32[]"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "fillOrdersUpTo",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "orderAddresses",
|
||||||
|
"type": "address[5]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "orderValues",
|
||||||
|
"type": "uint256[6]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cancelTakerTokenAmount",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "cancelOrder",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "ZRX_TOKEN_CONTRACT",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "orderAddresses",
|
||||||
|
"type": "address[5][]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "orderValues",
|
||||||
|
"type": "uint256[6][]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fillTakerTokenAmounts",
|
||||||
|
"type": "uint256[]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v",
|
||||||
|
"type": "uint8[]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "r",
|
||||||
|
"type": "bytes32[]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "s",
|
||||||
|
"type": "bytes32[]"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "batchFillOrKillOrders",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "orderAddresses",
|
||||||
|
"type": "address[5]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "orderValues",
|
||||||
|
"type": "uint256[6]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fillTakerTokenAmount",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v",
|
||||||
|
"type": "uint8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "r",
|
||||||
|
"type": "bytes32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "s",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "fillOrKillOrder",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "orderHash",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "getUnavailableTakerTokenAmount",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "signer",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "hash",
|
||||||
|
"type": "bytes32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v",
|
||||||
|
"type": "uint8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "r",
|
||||||
|
"type": "bytes32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "s",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "isValidSignature",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "numerator",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "denominator",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "target",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "getPartialAmount",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "TOKEN_TRANSFER_PROXY_CONTRACT",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "orderAddresses",
|
||||||
|
"type": "address[5][]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "orderValues",
|
||||||
|
"type": "uint256[6][]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fillTakerTokenAmounts",
|
||||||
|
"type": "uint256[]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "shouldThrowOnInsufficientBalanceOrAllowance",
|
||||||
|
"type": "bool"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v",
|
||||||
|
"type": "uint8[]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "r",
|
||||||
|
"type": "bytes32[]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "s",
|
||||||
|
"type": "bytes32[]"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "batchFillOrders",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "orderAddresses",
|
||||||
|
"type": "address[5][]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "orderValues",
|
||||||
|
"type": "uint256[6][]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cancelTakerTokenAmounts",
|
||||||
|
"type": "uint256[]"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "batchCancelOrders",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "orderAddresses",
|
||||||
|
"type": "address[5]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "orderValues",
|
||||||
|
"type": "uint256[6]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fillTakerTokenAmount",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "shouldThrowOnInsufficientBalanceOrAllowance",
|
||||||
|
"type": "bool"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "v",
|
||||||
|
"type": "uint8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "r",
|
||||||
|
"type": "bytes32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "s",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "fillOrder",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "filledTakerTokenAmount",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "orderAddresses",
|
||||||
|
"type": "address[5]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "orderValues",
|
||||||
|
"type": "uint256[6]"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "getOrderHash",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "EXTERNAL_QUERY_GAS_LIMIT",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint16"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "VERSION",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_zrxToken",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_tokenTransferProxy",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "constructor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "maker",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "taker",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "feeRecipient",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "makerToken",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "takerToken",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "filledMakerTokenAmount",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "filledTakerTokenAmount",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "paidMakerFee",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "paidTakerFee",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "tokens",
|
||||||
|
"type": "bytes32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "orderHash",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "LogFill",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "maker",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "feeRecipient",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "makerToken",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "takerToken",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "cancelledMakerTokenAmount",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "cancelledTakerTokenAmount",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "tokens",
|
||||||
|
"type": "bytes32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "orderHash",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "LogCancel",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "errorId",
|
||||||
|
"type": "uint8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "orderHash",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "LogError",
|
||||||
|
"type": "event"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"networks": {
|
||||||
|
"1": {
|
||||||
|
"address": "0x12459c951127e0c374ff9105dda097662a027093"
|
||||||
|
},
|
||||||
|
"3": {
|
||||||
|
"address": "0x479cc461fecd078f766ecc58533d6f69580cf3ac"
|
||||||
|
},
|
||||||
|
"4": {
|
||||||
|
"address": "0x1d16ef40fac01cec8adac2ac49427b9384192c05"
|
||||||
|
},
|
||||||
|
"42": {
|
||||||
|
"address": "0x90fe2af704b34e0224bf2299c838e04d4dcf1364"
|
||||||
|
},
|
||||||
|
"50": {
|
||||||
|
"address": "0x48bacb9266a570d521063ef5dd96e61686dbe788"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
172
packages/contract-wrappers/src/compact_artifacts/Token.json
Normal file
172
packages/contract-wrappers/src/compact_artifacts/Token.json
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
{
|
||||||
|
"contract_name": "Token",
|
||||||
|
"abi": [
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "approve",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "success",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "totalSupply",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "supply",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_from",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transferFrom",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "success",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "balanceOf",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "balance",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transfer",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "success",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "allowance",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "remaining",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_from",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Transfer",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Approval",
|
||||||
|
"type": "event"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -0,0 +1,547 @@
|
|||||||
|
{
|
||||||
|
"contract_name": "TokenRegistry",
|
||||||
|
"abi": [
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_index",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "removeToken",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_name",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "getTokenAddressByName",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_symbol",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "getTokenAddressBySymbol",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_swarmHash",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "setTokenSwarmHash",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_token",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "getTokenMetaData",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bytes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "owner",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_name",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_symbol",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_decimals",
|
||||||
|
"type": "uint8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_ipfsHash",
|
||||||
|
"type": "bytes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_swarmHash",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "addToken",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_name",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "setTokenName",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "tokens",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "symbol",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "decimals",
|
||||||
|
"type": "uint8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ipfsHash",
|
||||||
|
"type": "bytes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "swarmHash",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "tokenAddresses",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_name",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "getTokenByName",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bytes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "getTokenAddresses",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address[]"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_ipfsHash",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "setTokenIpfsHash",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_symbol",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "getTokenBySymbol",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bytes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_symbol",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "setTokenSymbol",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "newOwner",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transferOwnership",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "name",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "symbol",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "decimals",
|
||||||
|
"type": "uint8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "ipfsHash",
|
||||||
|
"type": "bytes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "swarmHash",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "LogAddToken",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "name",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "symbol",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "decimals",
|
||||||
|
"type": "uint8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "ipfsHash",
|
||||||
|
"type": "bytes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "swarmHash",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "LogRemoveToken",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "oldName",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "newName",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "LogTokenNameChange",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "oldSymbol",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "newSymbol",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "LogTokenSymbolChange",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "oldIpfsHash",
|
||||||
|
"type": "bytes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "newIpfsHash",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "LogTokenIpfsHashChange",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "oldSwarmHash",
|
||||||
|
"type": "bytes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "newSwarmHash",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "LogTokenSwarmHashChange",
|
||||||
|
"type": "event"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"networks": {
|
||||||
|
"1": {
|
||||||
|
"address": "0x926a74c5c36adf004c87399e65f75628b0f98d2c"
|
||||||
|
},
|
||||||
|
"3": {
|
||||||
|
"address": "0x6b1a50f0bb5a7995444bd3877b22dc89c62843ed"
|
||||||
|
},
|
||||||
|
"4": {
|
||||||
|
"address": "0x4e9aad8184de8833365fea970cd9149372fdf1e6"
|
||||||
|
},
|
||||||
|
"42": {
|
||||||
|
"address": "0xf18e504561f4347bea557f3d4558f559dddbae7f"
|
||||||
|
},
|
||||||
|
"50": {
|
||||||
|
"address": "0x0b1ba0af832d7c05fd64161e0db78e85978e8082"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,187 @@
|
|||||||
|
{
|
||||||
|
"contract_name": "TokenTransferProxy",
|
||||||
|
"abi": [
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "token",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "from",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transferFrom",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "target",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "addAuthorizedAddress",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "authorities",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "target",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "removeAuthorizedAddress",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "owner",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "authorized",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "getAuthorizedAddresses",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address[]"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "newOwner",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transferOwnership",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "target",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "caller",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "LogAuthorizedAddressAdded",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "target",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "caller",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "LogAuthorizedAddressRemoved",
|
||||||
|
"type": "event"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"networks": {
|
||||||
|
"1": {
|
||||||
|
"address": "0x8da0d80f5007ef1e431dd2127178d224e32c2ef4"
|
||||||
|
},
|
||||||
|
"3": {
|
||||||
|
"address": "0x4e9aad8184de8833365fea970cd9149372fdf1e6"
|
||||||
|
},
|
||||||
|
"4": {
|
||||||
|
"address": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d"
|
||||||
|
},
|
||||||
|
"42": {
|
||||||
|
"address": "0x087eed4bc1ee3de49befbd66c662b434b15d49d4"
|
||||||
|
},
|
||||||
|
"50": {
|
||||||
|
"address": "0x1dc4c1cefef38a777b15aa20260a54e584b16c48"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
packages/contract-wrappers/src/compact_artifacts/ZRX.json
Normal file
20
packages/contract-wrappers/src/compact_artifacts/ZRX.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"contract_name": "ZRX",
|
||||||
|
"networks": {
|
||||||
|
"1": {
|
||||||
|
"address": "0xe41d2489571d322189246dafa5ebde1f4699f498"
|
||||||
|
},
|
||||||
|
"3": {
|
||||||
|
"address": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d"
|
||||||
|
},
|
||||||
|
"4": {
|
||||||
|
"address": "0x00f58d6d585f84b2d7267940cede30ce2fe6eae8"
|
||||||
|
},
|
||||||
|
"42": {
|
||||||
|
"address": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570"
|
||||||
|
},
|
||||||
|
"50": {
|
||||||
|
"address": "0x1d7022f5b17d2f8b695918fb48fa1089c9f85401"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
112
packages/contract-wrappers/src/contract_wrappers.ts
Normal file
112
packages/contract-wrappers/src/contract_wrappers.ts
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
import { Provider } from '@0xproject/types';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
import { artifacts } from './artifacts';
|
||||||
|
import { EtherTokenWrapper } from './contract_wrappers/ether_token_wrapper';
|
||||||
|
import { ExchangeWrapper } from './contract_wrappers/exchange_wrapper';
|
||||||
|
import { TokenRegistryWrapper } from './contract_wrappers/token_registry_wrapper';
|
||||||
|
import { TokenTransferProxyWrapper } from './contract_wrappers/token_transfer_proxy_wrapper';
|
||||||
|
import { TokenWrapper } from './contract_wrappers/token_wrapper';
|
||||||
|
import { ContractWrappersConfigSchema } from './schemas/contract_wrappers_config_schema';
|
||||||
|
import { contractWrappersPrivateNetworkConfigSchema } from './schemas/contract_wrappers_private_network_config_schema';
|
||||||
|
import { contractWrappersPublicNetworkConfigSchema } from './schemas/contract_wrappers_public_network_config_schema';
|
||||||
|
import { ContractWrappersConfig } from './types';
|
||||||
|
import { assert } from './utils/assert';
|
||||||
|
/**
|
||||||
|
* The ContractWrappers class contains smart contract wrappers helpful when building on 0x protocol.
|
||||||
|
*/
|
||||||
|
export class ContractWrappers {
|
||||||
|
/**
|
||||||
|
* An instance of the ExchangeWrapper class containing methods for interacting with the 0x Exchange smart contract.
|
||||||
|
*/
|
||||||
|
public exchange: ExchangeWrapper;
|
||||||
|
/**
|
||||||
|
* An instance of the TokenRegistryWrapper class containing methods for interacting with the 0x
|
||||||
|
* TokenRegistry smart contract.
|
||||||
|
*/
|
||||||
|
public tokenRegistry: TokenRegistryWrapper;
|
||||||
|
/**
|
||||||
|
* An instance of the TokenWrapper class containing methods for interacting with any ERC20 token smart contract.
|
||||||
|
*/
|
||||||
|
public token: TokenWrapper;
|
||||||
|
/**
|
||||||
|
* An instance of the EtherTokenWrapper class containing methods for interacting with the
|
||||||
|
* wrapped ETH ERC20 token smart contract.
|
||||||
|
*/
|
||||||
|
public etherToken: EtherTokenWrapper;
|
||||||
|
/**
|
||||||
|
* An instance of the TokenTransferProxyWrapper class containing methods for interacting with the
|
||||||
|
* tokenTransferProxy smart contract.
|
||||||
|
*/
|
||||||
|
public proxy: TokenTransferProxyWrapper;
|
||||||
|
private _web3Wrapper: Web3Wrapper;
|
||||||
|
/**
|
||||||
|
* Instantiates a new ContractWrappers instance.
|
||||||
|
* @param provider The Provider instance you would like the 0x.js library to use for interacting with
|
||||||
|
* the Ethereum network.
|
||||||
|
* @param config The configuration object. Look up the type for the description.
|
||||||
|
* @return An instance of the ContractWrappers class.
|
||||||
|
*/
|
||||||
|
constructor(provider: Provider, config: ContractWrappersConfig) {
|
||||||
|
assert.isWeb3Provider('provider', provider);
|
||||||
|
assert.doesConformToSchema('config', config, ContractWrappersConfigSchema, [
|
||||||
|
contractWrappersPrivateNetworkConfigSchema,
|
||||||
|
contractWrappersPublicNetworkConfigSchema,
|
||||||
|
]);
|
||||||
|
const artifactJSONs = _.values(artifacts);
|
||||||
|
const abiArrays = _.map(artifactJSONs, artifact => artifact.abi);
|
||||||
|
const txDefaults = {
|
||||||
|
gasPrice: config.gasPrice,
|
||||||
|
};
|
||||||
|
this._web3Wrapper = new Web3Wrapper(provider, txDefaults);
|
||||||
|
_.forEach(abiArrays, abi => {
|
||||||
|
this._web3Wrapper.abiDecoder.addABI(abi);
|
||||||
|
});
|
||||||
|
this.proxy = new TokenTransferProxyWrapper(
|
||||||
|
this._web3Wrapper,
|
||||||
|
config.networkId,
|
||||||
|
config.tokenTransferProxyContractAddress,
|
||||||
|
);
|
||||||
|
this.token = new TokenWrapper(this._web3Wrapper, config.networkId, this.proxy);
|
||||||
|
this.exchange = new ExchangeWrapper(
|
||||||
|
this._web3Wrapper,
|
||||||
|
config.networkId,
|
||||||
|
this.token,
|
||||||
|
config.exchangeContractAddress,
|
||||||
|
config.zrxContractAddress,
|
||||||
|
);
|
||||||
|
this.tokenRegistry = new TokenRegistryWrapper(
|
||||||
|
this._web3Wrapper,
|
||||||
|
config.networkId,
|
||||||
|
config.tokenRegistryContractAddress,
|
||||||
|
);
|
||||||
|
this.etherToken = new EtherTokenWrapper(this._web3Wrapper, config.networkId, this.token);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Sets a new web3 provider for 0x.js. Updating the provider will stop all
|
||||||
|
* subscriptions so you will need to re-subscribe to all events relevant to your app after this call.
|
||||||
|
* @param provider The Web3Provider you would like the 0x.js library to use from now on.
|
||||||
|
* @param networkId The id of the network your provider is connected to
|
||||||
|
*/
|
||||||
|
public setProvider(provider: Provider, networkId: number): void {
|
||||||
|
this._web3Wrapper.setProvider(provider);
|
||||||
|
(this.exchange as any)._invalidateContractInstances();
|
||||||
|
(this.exchange as any)._setNetworkId(networkId);
|
||||||
|
(this.tokenRegistry as any)._invalidateContractInstance();
|
||||||
|
(this.tokenRegistry as any)._setNetworkId(networkId);
|
||||||
|
(this.token as any)._invalidateContractInstances();
|
||||||
|
(this.token as any)._setNetworkId(networkId);
|
||||||
|
(this.proxy as any)._invalidateContractInstance();
|
||||||
|
(this.proxy as any)._setNetworkId(networkId);
|
||||||
|
(this.etherToken as any)._invalidateContractInstance();
|
||||||
|
(this.etherToken as any)._setNetworkId(networkId);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the provider instance currently used by 0x.js
|
||||||
|
* @return Web3 provider instance
|
||||||
|
*/
|
||||||
|
public getProvider(): Provider {
|
||||||
|
return this._web3Wrapper.getProvider();
|
||||||
|
}
|
||||||
|
}
|
@@ -1,38 +1,44 @@
|
|||||||
import { BlockParamLiteral, ContractAbi, FilterObject, LogEntry, LogWithDecodedArgs, RawLog } from '@0xproject/types';
|
|
||||||
import { AbiDecoder, intervalUtils } from '@0xproject/utils';
|
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|
||||||
import { Block, BlockAndLogStreamer } from 'ethereumjs-blockstream';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
import * as Web3 from 'web3';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Artifact,
|
Artifact,
|
||||||
|
BlockParamLiteral,
|
||||||
|
ContractAbi,
|
||||||
|
FilterObject,
|
||||||
|
LogEntry,
|
||||||
|
LogWithDecodedArgs,
|
||||||
|
RawLog,
|
||||||
|
} from '@0xproject/types';
|
||||||
|
import { AbiDecoder, intervalUtils } from '@0xproject/utils';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
import {
|
||||||
BlockRange,
|
BlockRange,
|
||||||
ContractEventArgs,
|
ContractEventArgs,
|
||||||
ContractEvents,
|
ContractEvents,
|
||||||
|
ContractWrappersError,
|
||||||
EventCallback,
|
EventCallback,
|
||||||
IndexedFilterValues,
|
IndexedFilterValues,
|
||||||
InternalZeroExError,
|
InternalContractWrappersError,
|
||||||
ZeroExError,
|
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { constants } from '../utils/constants';
|
import { constants } from '../utils/constants';
|
||||||
import { filterUtils } from '../utils/filter_utils';
|
import { filterUtils } from '../utils/filter_utils';
|
||||||
|
|
||||||
const CONTRACT_NAME_TO_NOT_FOUND_ERROR: {
|
const CONTRACT_NAME_TO_NOT_FOUND_ERROR: {
|
||||||
[contractName: string]: ZeroExError;
|
[contractName: string]: ContractWrappersError;
|
||||||
} = {
|
} = {
|
||||||
ZRX: ZeroExError.ZRXContractDoesNotExist,
|
ZRX: ContractWrappersError.ZRXContractDoesNotExist,
|
||||||
EtherToken: ZeroExError.EtherTokenContractDoesNotExist,
|
EtherToken: ContractWrappersError.EtherTokenContractDoesNotExist,
|
||||||
Token: ZeroExError.TokenContractDoesNotExist,
|
Token: ContractWrappersError.TokenContractDoesNotExist,
|
||||||
TokenRegistry: ZeroExError.TokenRegistryContractDoesNotExist,
|
TokenRegistry: ContractWrappersError.TokenRegistryContractDoesNotExist,
|
||||||
TokenTransferProxy: ZeroExError.TokenTransferProxyContractDoesNotExist,
|
TokenTransferProxy: ContractWrappersError.TokenTransferProxyContractDoesNotExist,
|
||||||
Exchange: ZeroExError.ExchangeContractDoesNotExist,
|
Exchange: ContractWrappersError.ExchangeContractDoesNotExist,
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ContractWrapper {
|
export class ContractWrapper {
|
||||||
protected _web3Wrapper: Web3Wrapper;
|
protected _web3Wrapper: Web3Wrapper;
|
||||||
protected _networkId: number;
|
protected _networkId: number;
|
||||||
private _blockAndLogStreamerIfExists?: BlockAndLogStreamer;
|
private _blockAndLogStreamerIfExists?: BlockAndLogStreamer<Block, Log> | undefined;
|
||||||
private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer;
|
private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer;
|
||||||
private _filters: { [filterToken: string]: FilterObject };
|
private _filters: { [filterToken: string]: FilterObject };
|
||||||
private _filterCallbacks: {
|
private _filterCallbacks: {
|
||||||
@@ -40,6 +46,10 @@ export class ContractWrapper {
|
|||||||
};
|
};
|
||||||
private _onLogAddedSubscriptionToken: string | undefined;
|
private _onLogAddedSubscriptionToken: string | undefined;
|
||||||
private _onLogRemovedSubscriptionToken: string | undefined;
|
private _onLogRemovedSubscriptionToken: string | undefined;
|
||||||
|
private static _onBlockstreamError(err: Error): void {
|
||||||
|
// Noop on blockstream errors since they are automatically
|
||||||
|
// recovered from and don't cause Blockstream to exit.
|
||||||
|
}
|
||||||
constructor(web3Wrapper: Web3Wrapper, networkId: number) {
|
constructor(web3Wrapper: Web3Wrapper, networkId: number) {
|
||||||
this._web3Wrapper = web3Wrapper;
|
this._web3Wrapper = web3Wrapper;
|
||||||
this._networkId = networkId;
|
this._networkId = networkId;
|
||||||
@@ -57,7 +67,7 @@ export class ContractWrapper {
|
|||||||
}
|
}
|
||||||
protected _unsubscribe(filterToken: string, err?: Error): void {
|
protected _unsubscribe(filterToken: string, err?: Error): void {
|
||||||
if (_.isUndefined(this._filters[filterToken])) {
|
if (_.isUndefined(this._filters[filterToken])) {
|
||||||
throw new Error(ZeroExError.SubscriptionNotFound);
|
throw new Error(ContractWrappersError.SubscriptionNotFound);
|
||||||
}
|
}
|
||||||
if (!_.isUndefined(err)) {
|
if (!_.isUndefined(err)) {
|
||||||
const callback = this._filterCallbacks[filterToken];
|
const callback = this._filterCallbacks[filterToken];
|
||||||
@@ -101,7 +111,7 @@ export class ContractWrapper {
|
|||||||
log: LogEntry,
|
log: LogEntry,
|
||||||
): LogWithDecodedArgs<ArgsType> | RawLog {
|
): LogWithDecodedArgs<ArgsType> | RawLog {
|
||||||
if (_.isUndefined(this._web3Wrapper.abiDecoder)) {
|
if (_.isUndefined(this._web3Wrapper.abiDecoder)) {
|
||||||
throw new Error(InternalZeroExError.NoAbiDecoder);
|
throw new Error(InternalContractWrappersError.NoAbiDecoder);
|
||||||
}
|
}
|
||||||
const logWithDecodedArgs = this._web3Wrapper.abiDecoder.tryToDecodeLogOrNoop(log);
|
const logWithDecodedArgs = this._web3Wrapper.abiDecoder.tryToDecodeLogOrNoop(log);
|
||||||
return logWithDecodedArgs;
|
return logWithDecodedArgs;
|
||||||
@@ -113,7 +123,7 @@ export class ContractWrapper {
|
|||||||
let contractAddress: string;
|
let contractAddress: string;
|
||||||
if (_.isUndefined(addressIfExists)) {
|
if (_.isUndefined(addressIfExists)) {
|
||||||
if (_.isUndefined(artifact.networks[this._networkId])) {
|
if (_.isUndefined(artifact.networks[this._networkId])) {
|
||||||
throw new Error(ZeroExError.ContractNotDeployedOnNetwork);
|
throw new Error(ContractWrappersError.ContractNotDeployedOnNetwork);
|
||||||
}
|
}
|
||||||
contractAddress = artifact.networks[this._networkId].address.toLowerCase();
|
contractAddress = artifact.networks[this._networkId].address.toLowerCase();
|
||||||
} else {
|
} else {
|
||||||
@@ -130,7 +140,7 @@ export class ContractWrapper {
|
|||||||
if (_.isUndefined(addressIfExists)) {
|
if (_.isUndefined(addressIfExists)) {
|
||||||
const contractAddress = artifact.networks[this._networkId].address;
|
const contractAddress = artifact.networks[this._networkId].address;
|
||||||
if (_.isUndefined(contractAddress)) {
|
if (_.isUndefined(contractAddress)) {
|
||||||
throw new Error(ZeroExError.ExchangeContractDoesNotExist);
|
throw new Error(ContractWrappersError.ExchangeContractDoesNotExist);
|
||||||
}
|
}
|
||||||
return contractAddress;
|
return contractAddress;
|
||||||
} else {
|
} else {
|
||||||
@@ -151,18 +161,19 @@ export class ContractWrapper {
|
|||||||
}
|
}
|
||||||
private _startBlockAndLogStream(): void {
|
private _startBlockAndLogStream(): void {
|
||||||
if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
|
if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
|
||||||
throw new Error(ZeroExError.SubscriptionAlreadyPresent);
|
throw new Error(ContractWrappersError.SubscriptionAlreadyPresent);
|
||||||
}
|
}
|
||||||
this._blockAndLogStreamerIfExists = new BlockAndLogStreamer(
|
this._blockAndLogStreamerIfExists = new BlockAndLogStreamer(
|
||||||
this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper),
|
this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper),
|
||||||
this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper),
|
this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper),
|
||||||
|
ContractWrapper._onBlockstreamError.bind(this),
|
||||||
);
|
);
|
||||||
const catchAllLogFilter = {};
|
const catchAllLogFilter = {};
|
||||||
this._blockAndLogStreamerIfExists.addLogFilter(catchAllLogFilter);
|
this._blockAndLogStreamerIfExists.addLogFilter(catchAllLogFilter);
|
||||||
this._blockAndLogStreamIntervalIfExists = intervalUtils.setAsyncExcludingInterval(
|
this._blockAndLogStreamIntervalIfExists = intervalUtils.setAsyncExcludingInterval(
|
||||||
this._reconcileBlockAsync.bind(this),
|
this._reconcileBlockAsync.bind(this),
|
||||||
constants.DEFAULT_BLOCK_POLLING_INTERVAL,
|
constants.DEFAULT_BLOCK_POLLING_INTERVAL,
|
||||||
this._onReconcileBlockError.bind(this),
|
ContractWrapper._onBlockstreamError.bind(this),
|
||||||
);
|
);
|
||||||
let isRemoved = false;
|
let isRemoved = false;
|
||||||
this._onLogAddedSubscriptionToken = this._blockAndLogStreamerIfExists.subscribeToOnLogAdded(
|
this._onLogAddedSubscriptionToken = this._blockAndLogStreamerIfExists.subscribeToOnLogAdded(
|
||||||
@@ -173,18 +184,12 @@ export class ContractWrapper {
|
|||||||
this._onLogStateChanged.bind(this, isRemoved),
|
this._onLogStateChanged.bind(this, isRemoved),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
private _onReconcileBlockError(err: Error): void {
|
|
||||||
const filterTokens = _.keys(this._filterCallbacks);
|
|
||||||
_.each(filterTokens, filterToken => {
|
|
||||||
this._unsubscribe(filterToken, err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
private _setNetworkId(networkId: number): void {
|
private _setNetworkId(networkId: number): void {
|
||||||
this._networkId = networkId;
|
this._networkId = networkId;
|
||||||
}
|
}
|
||||||
private _stopBlockAndLogStream(): void {
|
private _stopBlockAndLogStream(): void {
|
||||||
if (_.isUndefined(this._blockAndLogStreamerIfExists)) {
|
if (_.isUndefined(this._blockAndLogStreamerIfExists)) {
|
||||||
throw new Error(ZeroExError.SubscriptionNotFound);
|
throw new Error(ContractWrappersError.SubscriptionNotFound);
|
||||||
}
|
}
|
||||||
this._blockAndLogStreamerIfExists.unsubscribeFromOnLogAdded(this._onLogAddedSubscriptionToken as string);
|
this._blockAndLogStreamerIfExists.unsubscribeFromOnLogAdded(this._onLogAddedSubscriptionToken as string);
|
||||||
this._blockAndLogStreamerIfExists.unsubscribeFromOnLogRemoved(this._onLogRemovedSubscriptionToken as string);
|
this._blockAndLogStreamerIfExists.unsubscribeFromOnLogRemoved(this._onLogRemovedSubscriptionToken as string);
|
@@ -5,7 +5,7 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from '../artifacts';
|
import { artifacts } from '../artifacts';
|
||||||
import { BlockRange, EventCallback, IndexedFilterValues, TransactionOpts, ZeroExError } from '../types';
|
import { BlockRange, ContractWrappersError, EventCallback, IndexedFilterValues, TransactionOpts } from '../types';
|
||||||
import { assert } from '../utils/assert';
|
import { assert } from '../utils/assert';
|
||||||
|
|
||||||
import { ContractWrapper } from './contract_wrapper';
|
import { ContractWrapper } from './contract_wrapper';
|
||||||
@@ -48,7 +48,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
|||||||
const normalizedDepositorAddress = depositor.toLowerCase();
|
const normalizedDepositorAddress = depositor.toLowerCase();
|
||||||
|
|
||||||
const ethBalanceInWei = await this._web3Wrapper.getBalanceInWeiAsync(normalizedDepositorAddress);
|
const ethBalanceInWei = await this._web3Wrapper.getBalanceInWeiAsync(normalizedDepositorAddress);
|
||||||
assert.assert(ethBalanceInWei.gte(amountInWei), ZeroExError.InsufficientEthBalanceForDeposit);
|
assert.assert(ethBalanceInWei.gte(amountInWei), ContractWrappersError.InsufficientEthBalanceForDeposit);
|
||||||
|
|
||||||
const wethContract = await this._getEtherTokenContractAsync(normalizedEtherTokenAddress);
|
const wethContract = await this._getEtherTokenContractAsync(normalizedEtherTokenAddress);
|
||||||
const txHash = await wethContract.deposit.sendTransactionAsync({
|
const txHash = await wethContract.deposit.sendTransactionAsync({
|
||||||
@@ -84,7 +84,10 @@ export class EtherTokenWrapper extends ContractWrapper {
|
|||||||
normalizedEtherTokenAddress,
|
normalizedEtherTokenAddress,
|
||||||
normalizedWithdrawerAddress,
|
normalizedWithdrawerAddress,
|
||||||
);
|
);
|
||||||
assert.assert(WETHBalanceInBaseUnits.gte(amountInWei), ZeroExError.InsufficientWEthBalanceForWithdrawal);
|
assert.assert(
|
||||||
|
WETHBalanceInBaseUnits.gte(amountInWei),
|
||||||
|
ContractWrappersError.InsufficientWEthBalanceForWithdrawal,
|
||||||
|
);
|
||||||
|
|
||||||
const wethContract = await this._getEtherTokenContractAsync(normalizedEtherTokenAddress);
|
const wethContract = await this._getEtherTokenContractAsync(normalizedEtherTokenAddress);
|
||||||
const txHash = await wethContract.withdraw.sendTransactionAsync(amountInWei, {
|
const txHash = await wethContract.withdraw.sendTransactionAsync(amountInWei, {
|
||||||
@@ -119,7 +122,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
|||||||
eventName,
|
eventName,
|
||||||
blockRange,
|
blockRange,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.EtherTokenArtifact.abi,
|
artifacts.EtherToken.abi,
|
||||||
);
|
);
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
@@ -147,7 +150,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
|||||||
normalizedEtherTokenAddress,
|
normalizedEtherTokenAddress,
|
||||||
eventName,
|
eventName,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.EtherTokenArtifact.abi,
|
artifacts.EtherToken.abi,
|
||||||
callback,
|
callback,
|
||||||
);
|
);
|
||||||
return subscriptionToken;
|
return subscriptionToken;
|
||||||
@@ -172,7 +175,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
|||||||
* @returns The Ethereum address of the EtherToken contract or undefined.
|
* @returns The Ethereum address of the EtherToken contract or undefined.
|
||||||
*/
|
*/
|
||||||
public getContractAddressIfExists(): string | undefined {
|
public getContractAddressIfExists(): string | undefined {
|
||||||
const networkSpecificArtifact = artifacts.EtherTokenArtifact.networks[this._networkId];
|
const networkSpecificArtifact = artifacts.EtherToken.networks[this._networkId];
|
||||||
const contractAddressIfExists = _.isUndefined(networkSpecificArtifact)
|
const contractAddressIfExists = _.isUndefined(networkSpecificArtifact)
|
||||||
? undefined
|
? undefined
|
||||||
: networkSpecificArtifact.address;
|
: networkSpecificArtifact.address;
|
||||||
@@ -188,7 +191,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
|||||||
return etherTokenContract;
|
return etherTokenContract;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
||||||
artifacts.EtherTokenArtifact,
|
artifacts.EtherToken,
|
||||||
etherTokenAddress,
|
etherTokenAddress,
|
||||||
);
|
);
|
||||||
const contractInstance = new EtherTokenContract(
|
const contractInstance = new EtherTokenContract(
|
@@ -1,11 +1,16 @@
|
|||||||
import { schemas } from '@0xproject/json-schemas';
|
import { schemas } from '@0xproject/json-schemas';
|
||||||
|
import { formatters, getOrderHashHex, OrderStateUtils } from '@0xproject/order-utils';
|
||||||
import {
|
import {
|
||||||
BlockParamLiteral,
|
BlockParamLiteral,
|
||||||
DecodedLogArgs,
|
DecodedLogArgs,
|
||||||
ECSignature,
|
ECSignature,
|
||||||
|
ExchangeContractErrs,
|
||||||
LogEntry,
|
LogEntry,
|
||||||
LogWithDecodedArgs,
|
LogWithDecodedArgs,
|
||||||
Order,
|
Order,
|
||||||
|
OrderAddresses,
|
||||||
|
OrderState,
|
||||||
|
OrderValues,
|
||||||
SignedOrder,
|
SignedOrder,
|
||||||
} from '@0xproject/types';
|
} from '@0xproject/types';
|
||||||
import { AbiDecoder, BigNumber } from '@0xproject/utils';
|
import { AbiDecoder, BigNumber } from '@0xproject/utils';
|
||||||
@@ -13,18 +18,17 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from '../artifacts';
|
import { artifacts } from '../artifacts';
|
||||||
|
import { SimpleBalanceAndProxyAllowanceFetcher } from '../fetchers/simple_balance_and_proxy_allowance_fetcher';
|
||||||
|
import { SimpleOrderFilledCancelledFetcher } from '../fetchers/simple_order_filled_cancelled_fetcher';
|
||||||
import {
|
import {
|
||||||
BlockRange,
|
BlockRange,
|
||||||
EventCallback,
|
EventCallback,
|
||||||
ExchangeContractErrCodes,
|
ExchangeContractErrCodes,
|
||||||
ExchangeContractErrs,
|
|
||||||
IndexedFilterValues,
|
IndexedFilterValues,
|
||||||
MethodOpts,
|
MethodOpts,
|
||||||
OrderAddresses,
|
|
||||||
OrderCancellationRequest,
|
OrderCancellationRequest,
|
||||||
OrderFillRequest,
|
OrderFillRequest,
|
||||||
OrderTransactionOpts,
|
OrderTransactionOpts,
|
||||||
OrderValues,
|
|
||||||
ValidateOrderFillableOpts,
|
ValidateOrderFillableOpts,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { assert } from '../utils/assert';
|
import { assert } from '../utils/assert';
|
||||||
@@ -41,7 +45,6 @@ import {
|
|||||||
LogErrorContractEventArgs,
|
LogErrorContractEventArgs,
|
||||||
} from './generated/exchange';
|
} from './generated/exchange';
|
||||||
import { TokenWrapper } from './token_wrapper';
|
import { TokenWrapper } from './token_wrapper';
|
||||||
|
|
||||||
const SHOULD_VALIDATE_BY_DEFAULT = true;
|
const SHOULD_VALIDATE_BY_DEFAULT = true;
|
||||||
|
|
||||||
interface ExchangeContractErrCodesToMsgs {
|
interface ExchangeContractErrCodesToMsgs {
|
||||||
@@ -66,24 +69,6 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
};
|
};
|
||||||
private _contractAddressIfExists?: string;
|
private _contractAddressIfExists?: string;
|
||||||
private _zrxContractAddressIfExists?: string;
|
private _zrxContractAddressIfExists?: string;
|
||||||
private static _getOrderAddressesAndValues(order: Order): [OrderAddresses, OrderValues] {
|
|
||||||
const orderAddresses: OrderAddresses = [
|
|
||||||
order.maker,
|
|
||||||
order.taker,
|
|
||||||
order.makerTokenAddress,
|
|
||||||
order.takerTokenAddress,
|
|
||||||
order.feeRecipient,
|
|
||||||
];
|
|
||||||
const orderValues: OrderValues = [
|
|
||||||
order.makerTokenAmount,
|
|
||||||
order.takerTokenAmount,
|
|
||||||
order.makerFee,
|
|
||||||
order.takerFee,
|
|
||||||
order.expirationUnixTimestampSec,
|
|
||||||
order.salt,
|
|
||||||
];
|
|
||||||
return [orderAddresses, orderValues];
|
|
||||||
}
|
|
||||||
constructor(
|
constructor(
|
||||||
web3Wrapper: Web3Wrapper,
|
web3Wrapper: Web3Wrapper,
|
||||||
networkId: number,
|
networkId: number,
|
||||||
@@ -205,7 +190,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(signedOrder);
|
const [orderAddresses, orderValues] = formatters.getOrderAddressesAndValues(signedOrder);
|
||||||
|
|
||||||
const txHash: string = await exchangeInstance.fillOrder.sendTransactionAsync(
|
const txHash: string = await exchangeInstance.fillOrder.sendTransactionAsync(
|
||||||
orderAddresses,
|
orderAddresses,
|
||||||
@@ -292,7 +277,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
|
|
||||||
const orderAddressesValuesAndSignatureArray = _.map(signedOrders, signedOrder => {
|
const orderAddressesValuesAndSignatureArray = _.map(signedOrders, signedOrder => {
|
||||||
return [
|
return [
|
||||||
...ExchangeWrapper._getOrderAddressesAndValues(signedOrder),
|
...formatters.getOrderAddressesAndValues(signedOrder),
|
||||||
signedOrder.ecSignature.v,
|
signedOrder.ecSignature.v,
|
||||||
signedOrder.ecSignature.r,
|
signedOrder.ecSignature.r,
|
||||||
signedOrder.ecSignature.s,
|
signedOrder.ecSignature.s,
|
||||||
@@ -380,7 +365,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
|
|
||||||
const orderAddressesValuesAmountsAndSignatureArray = _.map(orderFillRequests, orderFillRequest => {
|
const orderAddressesValuesAmountsAndSignatureArray = _.map(orderFillRequests, orderFillRequest => {
|
||||||
return [
|
return [
|
||||||
...ExchangeWrapper._getOrderAddressesAndValues(orderFillRequest.signedOrder),
|
...formatters.getOrderAddressesAndValues(orderFillRequest.signedOrder),
|
||||||
orderFillRequest.takerTokenFillAmount,
|
orderFillRequest.takerTokenFillAmount,
|
||||||
orderFillRequest.signedOrder.ecSignature.v,
|
orderFillRequest.signedOrder.ecSignature.v,
|
||||||
orderFillRequest.signedOrder.ecSignature.r,
|
orderFillRequest.signedOrder.ecSignature.r,
|
||||||
@@ -449,7 +434,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(signedOrder);
|
const [orderAddresses, orderValues] = formatters.getOrderAddressesAndValues(signedOrder);
|
||||||
const txHash = await exchangeInstance.fillOrKillOrder.sendTransactionAsync(
|
const txHash = await exchangeInstance.fillOrKillOrder.sendTransactionAsync(
|
||||||
orderAddresses,
|
orderAddresses,
|
||||||
orderValues,
|
orderValues,
|
||||||
@@ -515,7 +500,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
|
|
||||||
const orderAddressesValuesAndTakerTokenFillAmounts = _.map(orderFillRequests, request => {
|
const orderAddressesValuesAndTakerTokenFillAmounts = _.map(orderFillRequests, request => {
|
||||||
return [
|
return [
|
||||||
...ExchangeWrapper._getOrderAddressesAndValues(request.signedOrder),
|
...formatters.getOrderAddressesAndValues(request.signedOrder),
|
||||||
request.takerTokenFillAmount,
|
request.takerTokenFillAmount,
|
||||||
request.signedOrder.ecSignature.v,
|
request.signedOrder.ecSignature.v,
|
||||||
request.signedOrder.ecSignature.r,
|
request.signedOrder.ecSignature.r,
|
||||||
@@ -567,7 +552,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
? SHOULD_VALIDATE_BY_DEFAULT
|
? SHOULD_VALIDATE_BY_DEFAULT
|
||||||
: orderTransactionOpts.shouldValidate;
|
: orderTransactionOpts.shouldValidate;
|
||||||
if (shouldValidate) {
|
if (shouldValidate) {
|
||||||
const orderHash = utils.getOrderHashHex(order);
|
const orderHash = getOrderHashHex(order);
|
||||||
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
|
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
|
||||||
OrderValidationUtils.validateCancelOrderThrowIfInvalid(
|
OrderValidationUtils.validateCancelOrderThrowIfInvalid(
|
||||||
order,
|
order,
|
||||||
@@ -576,7 +561,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(order);
|
const [orderAddresses, orderValues] = formatters.getOrderAddressesAndValues(order);
|
||||||
const txHash = await exchangeInstance.cancelOrder.sendTransactionAsync(
|
const txHash = await exchangeInstance.cancelOrder.sendTransactionAsync(
|
||||||
orderAddresses,
|
orderAddresses,
|
||||||
orderValues,
|
orderValues,
|
||||||
@@ -626,7 +611,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
: orderTransactionOpts.shouldValidate;
|
: orderTransactionOpts.shouldValidate;
|
||||||
if (shouldValidate) {
|
if (shouldValidate) {
|
||||||
for (const orderCancellationRequest of orderCancellationRequests) {
|
for (const orderCancellationRequest of orderCancellationRequests) {
|
||||||
const orderHash = utils.getOrderHashHex(orderCancellationRequest.order);
|
const orderHash = getOrderHashHex(orderCancellationRequest.order);
|
||||||
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
|
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
|
||||||
OrderValidationUtils.validateCancelOrderThrowIfInvalid(
|
OrderValidationUtils.validateCancelOrderThrowIfInvalid(
|
||||||
orderCancellationRequest.order,
|
orderCancellationRequest.order,
|
||||||
@@ -641,7 +626,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
const exchangeInstance = await this._getExchangeContractAsync();
|
const exchangeInstance = await this._getExchangeContractAsync();
|
||||||
const orderAddressesValuesAndTakerTokenCancelAmounts = _.map(orderCancellationRequests, cancellationRequest => {
|
const orderAddressesValuesAndTakerTokenCancelAmounts = _.map(orderCancellationRequests, cancellationRequest => {
|
||||||
return [
|
return [
|
||||||
...ExchangeWrapper._getOrderAddressesAndValues(cancellationRequest.order),
|
...formatters.getOrderAddressesAndValues(cancellationRequest.order),
|
||||||
cancellationRequest.takerTokenCancelAmount,
|
cancellationRequest.takerTokenCancelAmount,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
@@ -682,7 +667,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
exchangeContractAddress,
|
exchangeContractAddress,
|
||||||
eventName,
|
eventName,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.ExchangeArtifact.abi,
|
artifacts.Exchange.abi,
|
||||||
callback,
|
callback,
|
||||||
);
|
);
|
||||||
return subscriptionToken;
|
return subscriptionToken;
|
||||||
@@ -722,7 +707,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
eventName,
|
eventName,
|
||||||
blockRange,
|
blockRange,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.ExchangeArtifact.abi,
|
artifacts.Exchange.abi,
|
||||||
);
|
);
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
@@ -732,7 +717,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
* @returns The Ethereum address of the Exchange contract being used.
|
* @returns The Ethereum address of the Exchange contract being used.
|
||||||
*/
|
*/
|
||||||
public getContractAddress(): string {
|
public getContractAddress(): string {
|
||||||
const contractAddress = this._getContractAddress(artifacts.ExchangeArtifact, this._contractAddressIfExists);
|
const contractAddress = this._getContractAddress(artifacts.Exchange, this._contractAddressIfExists);
|
||||||
return contractAddress;
|
return contractAddress;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -798,7 +783,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
assert.doesConformToSchema('order', order, schemas.orderSchema);
|
assert.doesConformToSchema('order', order, schemas.orderSchema);
|
||||||
assert.isValidBaseUnitAmount('cancelTakerTokenAmount', cancelTakerTokenAmount);
|
assert.isValidBaseUnitAmount('cancelTakerTokenAmount', cancelTakerTokenAmount);
|
||||||
const orderHash = utils.getOrderHashHex(order);
|
const orderHash = getOrderHashHex(order);
|
||||||
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
|
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
|
||||||
OrderValidationUtils.validateCancelOrderThrowIfInvalid(
|
OrderValidationUtils.validateCancelOrderThrowIfInvalid(
|
||||||
order,
|
order,
|
||||||
@@ -873,12 +858,34 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
throw new Error(errMessage);
|
throw new Error(errMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Gets the latest OrderState of a signedOrder
|
||||||
|
* @param signedOrder The signedOrder
|
||||||
|
* @param stateLayer Optional, desired blockchain state layer (defaults to latest).
|
||||||
|
* @return OrderState of the signedOrder
|
||||||
|
*/
|
||||||
|
public async getOrderStateAsync(
|
||||||
|
signedOrder: SignedOrder,
|
||||||
|
stateLayer: BlockParamLiteral = BlockParamLiteral.Latest,
|
||||||
|
): Promise<OrderState> {
|
||||||
|
const simpleBalanceAndProxyAllowanceFetcher = new SimpleBalanceAndProxyAllowanceFetcher(
|
||||||
|
this._tokenWrapper,
|
||||||
|
stateLayer,
|
||||||
|
);
|
||||||
|
const simpleOrderFilledCancelledFetcher = new SimpleOrderFilledCancelledFetcher(this, stateLayer);
|
||||||
|
const orderStateUtils = new OrderStateUtils(
|
||||||
|
simpleBalanceAndProxyAllowanceFetcher,
|
||||||
|
simpleOrderFilledCancelledFetcher,
|
||||||
|
);
|
||||||
|
const orderState = orderStateUtils.getOrderStateAsync(signedOrder);
|
||||||
|
return orderState;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the ZRX token address used by the exchange contract.
|
* Returns the ZRX token address used by the exchange contract.
|
||||||
* @return Address of ZRX token
|
* @return Address of ZRX token
|
||||||
*/
|
*/
|
||||||
public getZRXTokenAddress(): string {
|
public getZRXTokenAddress(): string {
|
||||||
const contractAddress = this._getContractAddress(artifacts.ZRXArtifact, this._zrxContractAddressIfExists);
|
const contractAddress = this._getContractAddress(artifacts.ZRX, this._zrxContractAddressIfExists);
|
||||||
return contractAddress;
|
return contractAddress;
|
||||||
}
|
}
|
||||||
private _invalidateContractInstances(): void {
|
private _invalidateContractInstances(): void {
|
||||||
@@ -908,7 +915,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
}
|
}
|
||||||
private async _getOrderHashHexUsingContractCallAsync(order: Order | SignedOrder): Promise<string> {
|
private async _getOrderHashHexUsingContractCallAsync(order: Order | SignedOrder): Promise<string> {
|
||||||
const exchangeInstance = await this._getExchangeContractAsync();
|
const exchangeInstance = await this._getExchangeContractAsync();
|
||||||
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(order);
|
const [orderAddresses, orderValues] = formatters.getOrderAddressesAndValues(order);
|
||||||
const orderHashHex = await exchangeInstance.getOrderHash.callAsync(orderAddresses, orderValues);
|
const orderHashHex = await exchangeInstance.getOrderHash.callAsync(orderAddresses, orderValues);
|
||||||
return orderHashHex;
|
return orderHashHex;
|
||||||
}
|
}
|
||||||
@@ -917,7 +924,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
return this._exchangeContractIfExists;
|
return this._exchangeContractIfExists;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
||||||
artifacts.ExchangeArtifact,
|
artifacts.Exchange,
|
||||||
this._contractAddressIfExists,
|
this._contractAddressIfExists,
|
||||||
);
|
);
|
||||||
const contractInstance = new ExchangeContract(
|
const contractInstance = new ExchangeContract(
|
||||||
@@ -929,10 +936,4 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
this._exchangeContractIfExists = contractInstance;
|
this._exchangeContractIfExists = contractInstance;
|
||||||
return this._exchangeContractIfExists;
|
return this._exchangeContractIfExists;
|
||||||
}
|
}
|
||||||
private async _getTokenTransferProxyAddressAsync(): Promise<string> {
|
|
||||||
const exchangeInstance = await this._getExchangeContractAsync();
|
|
||||||
const tokenTransferProxyAddress = await exchangeInstance.TOKEN_TRANSFER_PROXY_CONTRACT.callAsync();
|
|
||||||
const tokenTransferProxyAddressLowerCase = tokenTransferProxyAddress.toLowerCase();
|
|
||||||
return tokenTransferProxyAddressLowerCase;
|
|
||||||
}
|
|
||||||
} // tslint:disable:max-file-line-count
|
} // tslint:disable:max-file-line-count
|
@@ -1,8 +1,9 @@
|
|||||||
|
import { Token } from '@0xproject/types';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from '../artifacts';
|
import { artifacts } from '../artifacts';
|
||||||
import { Token, TokenMetadata } from '../types';
|
import { TokenMetadata } from '../types';
|
||||||
import { assert } from '../utils/assert';
|
import { assert } from '../utils/assert';
|
||||||
import { constants } from '../utils/constants';
|
import { constants } from '../utils/constants';
|
||||||
|
|
||||||
@@ -104,10 +105,7 @@ export class TokenRegistryWrapper extends ContractWrapper {
|
|||||||
* @returns The Ethereum address of the TokenRegistry contract being used.
|
* @returns The Ethereum address of the TokenRegistry contract being used.
|
||||||
*/
|
*/
|
||||||
public getContractAddress(): string {
|
public getContractAddress(): string {
|
||||||
const contractAddress = this._getContractAddress(
|
const contractAddress = this._getContractAddress(artifacts.TokenRegistry, this._contractAddressIfExists);
|
||||||
artifacts.TokenRegistryArtifact,
|
|
||||||
this._contractAddressIfExists,
|
|
||||||
);
|
|
||||||
return contractAddress;
|
return contractAddress;
|
||||||
}
|
}
|
||||||
private _invalidateContractInstance(): void {
|
private _invalidateContractInstance(): void {
|
||||||
@@ -118,7 +116,7 @@ export class TokenRegistryWrapper extends ContractWrapper {
|
|||||||
return this._tokenRegistryContractIfExists;
|
return this._tokenRegistryContractIfExists;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
||||||
artifacts.TokenRegistryArtifact,
|
artifacts.TokenRegistry,
|
||||||
this._contractAddressIfExists,
|
this._contractAddressIfExists,
|
||||||
);
|
);
|
||||||
const contractInstance = new TokenRegistryContract(
|
const contractInstance = new TokenRegistryContract(
|
@@ -46,10 +46,7 @@ export class TokenTransferProxyWrapper extends ContractWrapper {
|
|||||||
* @returns The Ethereum address of the TokenTransferProxy contract being used.
|
* @returns The Ethereum address of the TokenTransferProxy contract being used.
|
||||||
*/
|
*/
|
||||||
public getContractAddress(): string {
|
public getContractAddress(): string {
|
||||||
const contractAddress = this._getContractAddress(
|
const contractAddress = this._getContractAddress(artifacts.TokenTransferProxy, this._contractAddressIfExists);
|
||||||
artifacts.TokenTransferProxyArtifact,
|
|
||||||
this._contractAddressIfExists,
|
|
||||||
);
|
|
||||||
return contractAddress;
|
return contractAddress;
|
||||||
}
|
}
|
||||||
private _invalidateContractInstance(): void {
|
private _invalidateContractInstance(): void {
|
||||||
@@ -60,7 +57,7 @@ export class TokenTransferProxyWrapper extends ContractWrapper {
|
|||||||
return this._tokenTransferProxyContractIfExists;
|
return this._tokenTransferProxyContractIfExists;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
||||||
artifacts.TokenTransferProxyArtifact,
|
artifacts.TokenTransferProxy,
|
||||||
this._contractAddressIfExists,
|
this._contractAddressIfExists,
|
||||||
);
|
);
|
||||||
const contractInstance = new TokenTransferProxyContract(
|
const contractInstance = new TokenTransferProxyContract(
|
@@ -5,7 +5,14 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from '../artifacts';
|
import { artifacts } from '../artifacts';
|
||||||
import { BlockRange, EventCallback, IndexedFilterValues, MethodOpts, TransactionOpts, ZeroExError } from '../types';
|
import {
|
||||||
|
BlockRange,
|
||||||
|
ContractWrappersError,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
MethodOpts,
|
||||||
|
TransactionOpts,
|
||||||
|
} from '../types';
|
||||||
import { assert } from '../utils/assert';
|
import { assert } from '../utils/assert';
|
||||||
import { constants } from '../utils/constants';
|
import { constants } from '../utils/constants';
|
||||||
|
|
||||||
@@ -266,7 +273,7 @@ export class TokenWrapper extends ContractWrapper {
|
|||||||
|
|
||||||
const fromAddressBalance = await this.getBalanceAsync(normalizedTokenAddress, normalizedFromAddress);
|
const fromAddressBalance = await this.getBalanceAsync(normalizedTokenAddress, normalizedFromAddress);
|
||||||
if (fromAddressBalance.lessThan(amountInBaseUnits)) {
|
if (fromAddressBalance.lessThan(amountInBaseUnits)) {
|
||||||
throw new Error(ZeroExError.InsufficientBalanceForTransfer);
|
throw new Error(ContractWrappersError.InsufficientBalanceForTransfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
const txHash = await tokenContract.transfer.sendTransactionAsync(normalizedToAddress, amountInBaseUnits, {
|
const txHash = await tokenContract.transfer.sendTransactionAsync(normalizedToAddress, amountInBaseUnits, {
|
||||||
@@ -316,12 +323,12 @@ export class TokenWrapper extends ContractWrapper {
|
|||||||
normalizedSenderAddress,
|
normalizedSenderAddress,
|
||||||
);
|
);
|
||||||
if (fromAddressAllowance.lessThan(amountInBaseUnits)) {
|
if (fromAddressAllowance.lessThan(amountInBaseUnits)) {
|
||||||
throw new Error(ZeroExError.InsufficientAllowanceForTransfer);
|
throw new Error(ContractWrappersError.InsufficientAllowanceForTransfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fromAddressBalance = await this.getBalanceAsync(normalizedTokenAddress, normalizedFromAddress);
|
const fromAddressBalance = await this.getBalanceAsync(normalizedTokenAddress, normalizedFromAddress);
|
||||||
if (fromAddressBalance.lessThan(amountInBaseUnits)) {
|
if (fromAddressBalance.lessThan(amountInBaseUnits)) {
|
||||||
throw new Error(ZeroExError.InsufficientBalanceForTransfer);
|
throw new Error(ContractWrappersError.InsufficientBalanceForTransfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
const txHash = await tokenContract.transferFrom.sendTransactionAsync(
|
const txHash = await tokenContract.transferFrom.sendTransactionAsync(
|
||||||
@@ -360,7 +367,7 @@ export class TokenWrapper extends ContractWrapper {
|
|||||||
normalizedTokenAddress,
|
normalizedTokenAddress,
|
||||||
eventName,
|
eventName,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.TokenArtifact.abi,
|
artifacts.Token.abi,
|
||||||
callback,
|
callback,
|
||||||
);
|
);
|
||||||
return subscriptionToken;
|
return subscriptionToken;
|
||||||
@@ -403,7 +410,7 @@ export class TokenWrapper extends ContractWrapper {
|
|||||||
eventName,
|
eventName,
|
||||||
blockRange,
|
blockRange,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.TokenArtifact.abi,
|
artifacts.Token.abi,
|
||||||
);
|
);
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
@@ -418,7 +425,7 @@ export class TokenWrapper extends ContractWrapper {
|
|||||||
return tokenContract;
|
return tokenContract;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
||||||
artifacts.TokenArtifact,
|
artifacts.Token,
|
||||||
normalizedTokenAddress,
|
normalizedTokenAddress,
|
||||||
);
|
);
|
||||||
const contractInstance = new TokenContract(
|
const contractInstance = new TokenContract(
|
@@ -0,0 +1,28 @@
|
|||||||
|
import { AbstractBalanceAndProxyAllowanceFetcher } from '@0xproject/order-utils';
|
||||||
|
import { BlockParamLiteral } from '@0xproject/types';
|
||||||
|
import { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
|
import { TokenWrapper } from '../contract_wrappers/token_wrapper';
|
||||||
|
|
||||||
|
export class SimpleBalanceAndProxyAllowanceFetcher implements AbstractBalanceAndProxyAllowanceFetcher {
|
||||||
|
private _tokenWrapper: TokenWrapper;
|
||||||
|
private _defaultBlock: BlockParamLiteral;
|
||||||
|
constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) {
|
||||||
|
this._tokenWrapper = token;
|
||||||
|
this._defaultBlock = defaultBlock;
|
||||||
|
}
|
||||||
|
public async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
|
||||||
|
const methodOpts = {
|
||||||
|
defaultBlock: this._defaultBlock,
|
||||||
|
};
|
||||||
|
const balance = this._tokenWrapper.getBalanceAsync(tokenAddress, userAddress, methodOpts);
|
||||||
|
return balance;
|
||||||
|
}
|
||||||
|
public async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
|
||||||
|
const methodOpts = {
|
||||||
|
defaultBlock: this._defaultBlock,
|
||||||
|
};
|
||||||
|
const proxyAllowance = this._tokenWrapper.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts);
|
||||||
|
return proxyAllowance;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,36 @@
|
|||||||
|
import { AbstractOrderFilledCancelledFetcher } from '@0xproject/order-utils';
|
||||||
|
import { BlockParamLiteral } from '@0xproject/types';
|
||||||
|
import { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
|
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
|
||||||
|
|
||||||
|
export class SimpleOrderFilledCancelledFetcher implements AbstractOrderFilledCancelledFetcher {
|
||||||
|
private _exchangeWrapper: ExchangeWrapper;
|
||||||
|
private _defaultBlock: BlockParamLiteral;
|
||||||
|
constructor(exchange: ExchangeWrapper, defaultBlock: BlockParamLiteral) {
|
||||||
|
this._exchangeWrapper = exchange;
|
||||||
|
this._defaultBlock = defaultBlock;
|
||||||
|
}
|
||||||
|
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||||
|
const methodOpts = {
|
||||||
|
defaultBlock: this._defaultBlock,
|
||||||
|
};
|
||||||
|
const filledTakerAmount = this._exchangeWrapper.getFilledTakerAmountAsync(orderHash, methodOpts);
|
||||||
|
return filledTakerAmount;
|
||||||
|
}
|
||||||
|
public async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||||
|
const methodOpts = {
|
||||||
|
defaultBlock: this._defaultBlock,
|
||||||
|
};
|
||||||
|
const cancelledTakerAmount = this._exchangeWrapper.getCancelledTakerAmountAsync(orderHash, methodOpts);
|
||||||
|
return cancelledTakerAmount;
|
||||||
|
}
|
||||||
|
public async getUnavailableTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||||
|
const unavailableTakerAmount = await this._exchangeWrapper.getUnavailableTakerAmountAsync(orderHash);
|
||||||
|
return unavailableTakerAmount;
|
||||||
|
}
|
||||||
|
public getZRXTokenAddress(): string {
|
||||||
|
const zrxToken = this._exchangeWrapper.getZRXTokenAddress();
|
||||||
|
return zrxToken;
|
||||||
|
}
|
||||||
|
}
|
68
packages/contract-wrappers/src/index.ts
Normal file
68
packages/contract-wrappers/src/index.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
export { ContractWrappers } from './contract_wrappers';
|
||||||
|
export { ExchangeWrapper } from './contract_wrappers/exchange_wrapper';
|
||||||
|
export { TokenWrapper } from './contract_wrappers/token_wrapper';
|
||||||
|
export { TokenRegistryWrapper } from './contract_wrappers/token_registry_wrapper';
|
||||||
|
export { EtherTokenWrapper } from './contract_wrappers/ether_token_wrapper';
|
||||||
|
export { TokenTransferProxyWrapper } from './contract_wrappers/token_transfer_proxy_wrapper';
|
||||||
|
|
||||||
|
export {
|
||||||
|
ContractWrappersError,
|
||||||
|
EventCallback,
|
||||||
|
ContractEvent,
|
||||||
|
Token,
|
||||||
|
IndexedFilterValues,
|
||||||
|
BlockRange,
|
||||||
|
OrderCancellationRequest,
|
||||||
|
OrderFillRequest,
|
||||||
|
ContractEventArgs,
|
||||||
|
ContractWrappersConfig,
|
||||||
|
MethodOpts,
|
||||||
|
OrderTransactionOpts,
|
||||||
|
TransactionOpts,
|
||||||
|
LogEvent,
|
||||||
|
DecodedLogEvent,
|
||||||
|
OnOrderStateChangeCallback,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
|
export {
|
||||||
|
BlockParamLiteral,
|
||||||
|
FilterObject,
|
||||||
|
BlockParam,
|
||||||
|
ContractEventArg,
|
||||||
|
ExchangeContractErrs,
|
||||||
|
LogWithDecodedArgs,
|
||||||
|
Order,
|
||||||
|
Provider,
|
||||||
|
SignedOrder,
|
||||||
|
ECSignature,
|
||||||
|
OrderStateValid,
|
||||||
|
OrderStateInvalid,
|
||||||
|
OrderState,
|
||||||
|
TransactionReceipt,
|
||||||
|
TransactionReceiptWithDecodedLogs,
|
||||||
|
} from '@0xproject/types';
|
||||||
|
|
||||||
|
export {
|
||||||
|
EtherTokenContractEventArgs,
|
||||||
|
WithdrawalContractEventArgs,
|
||||||
|
DepositContractEventArgs,
|
||||||
|
EtherTokenEvents,
|
||||||
|
} from './contract_wrappers/generated/ether_token';
|
||||||
|
|
||||||
|
export {
|
||||||
|
TransferContractEventArgs,
|
||||||
|
ApprovalContractEventArgs,
|
||||||
|
TokenContractEventArgs,
|
||||||
|
TokenEvents,
|
||||||
|
} from './contract_wrappers/generated/token';
|
||||||
|
|
||||||
|
export {
|
||||||
|
LogErrorContractEventArgs,
|
||||||
|
LogCancelContractEventArgs,
|
||||||
|
LogFillContractEventArgs,
|
||||||
|
ExchangeContractEventArgs,
|
||||||
|
ExchangeEvents,
|
||||||
|
} from './contract_wrappers/generated/exchange';
|
||||||
|
|
||||||
|
export { BalanceAndProxyAllowanceLazyStore } from './stores/balance_proxy_allowance_lazy_store';
|
||||||
|
export { OrderFilledCancelledLazyStore } from './stores/order_filled_cancelled_lazy_store';
|
@@ -0,0 +1,5 @@
|
|||||||
|
export const ContractWrappersConfigSchema = {
|
||||||
|
id: '/ContractWrappersConfig',
|
||||||
|
oneOf: [{ $ref: '/ZeroExContractPrivateNetworkConfig' }, { $ref: '/ZeroExContractPublicNetworkConfig' }],
|
||||||
|
type: 'object',
|
||||||
|
};
|
@@ -0,0 +1,35 @@
|
|||||||
|
export const contractWrappersPrivateNetworkConfigSchema = {
|
||||||
|
id: '/ZeroExContractPrivateNetworkConfig',
|
||||||
|
properties: {
|
||||||
|
networkId: {
|
||||||
|
type: 'number',
|
||||||
|
minimum: 1,
|
||||||
|
},
|
||||||
|
gasPrice: { $ref: '/Number' },
|
||||||
|
zrxContractAddress: { $ref: '/Address' },
|
||||||
|
exchangeContractAddress: { $ref: '/Address' },
|
||||||
|
tokenRegistryContractAddress: { $ref: '/Address' },
|
||||||
|
tokenTransferProxyContractAddress: { $ref: '/Address' },
|
||||||
|
orderWatcherConfig: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
pollingIntervalMs: {
|
||||||
|
type: 'number',
|
||||||
|
minimum: 0,
|
||||||
|
},
|
||||||
|
numConfirmations: {
|
||||||
|
type: 'number',
|
||||||
|
minimum: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
type: 'object',
|
||||||
|
required: [
|
||||||
|
'networkId',
|
||||||
|
'zrxContractAddress',
|
||||||
|
'exchangeContractAddress',
|
||||||
|
'tokenRegistryContractAddress',
|
||||||
|
'tokenTransferProxyContractAddress',
|
||||||
|
],
|
||||||
|
};
|
@@ -0,0 +1,43 @@
|
|||||||
|
const networkNameToId: { [networkName: string]: number } = {
|
||||||
|
mainnet: 1,
|
||||||
|
ropsten: 3,
|
||||||
|
rinkeby: 4,
|
||||||
|
kovan: 42,
|
||||||
|
ganache: 50,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const contractWrappersPublicNetworkConfigSchema = {
|
||||||
|
id: '/ZeroExContractPublicNetworkConfig',
|
||||||
|
properties: {
|
||||||
|
networkId: {
|
||||||
|
type: 'number',
|
||||||
|
enum: [
|
||||||
|
networkNameToId.mainnet,
|
||||||
|
networkNameToId.kovan,
|
||||||
|
networkNameToId.ropsten,
|
||||||
|
networkNameToId.rinkeby,
|
||||||
|
networkNameToId.ganache,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
gasPrice: { $ref: '/Number' },
|
||||||
|
zrxContractAddress: { $ref: '/Address' },
|
||||||
|
exchangeContractAddress: { $ref: '/Address' },
|
||||||
|
tokenRegistryContractAddress: { $ref: '/Address' },
|
||||||
|
tokenTransferProxyContractAddress: { $ref: '/Address' },
|
||||||
|
orderWatcherConfig: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
pollingIntervalMs: {
|
||||||
|
type: 'number',
|
||||||
|
minimum: 0,
|
||||||
|
},
|
||||||
|
numConfirmations: {
|
||||||
|
type: 'number',
|
||||||
|
minimum: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
type: 'object',
|
||||||
|
required: ['networkId'],
|
||||||
|
};
|
@@ -1,3 +1,4 @@
|
|||||||
|
import { AbstractBalanceAndProxyAllowanceFetcher } from '@0xproject/order-utils';
|
||||||
import { BlockParamLiteral } from '@0xproject/types';
|
import { BlockParamLiteral } from '@0xproject/types';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
@@ -7,8 +8,8 @@ import { TokenWrapper } from '../contract_wrappers/token_wrapper';
|
|||||||
/**
|
/**
|
||||||
* Copy on read store for balances/proxyAllowances of tokens/accounts
|
* Copy on read store for balances/proxyAllowances of tokens/accounts
|
||||||
*/
|
*/
|
||||||
export class BalanceAndProxyAllowanceLazyStore {
|
export class BalanceAndProxyAllowanceLazyStore implements AbstractBalanceAndProxyAllowanceFetcher {
|
||||||
private _token: TokenWrapper;
|
private _tokenWrapper: TokenWrapper;
|
||||||
private _defaultBlock: BlockParamLiteral;
|
private _defaultBlock: BlockParamLiteral;
|
||||||
private _balance: {
|
private _balance: {
|
||||||
[tokenAddress: string]: {
|
[tokenAddress: string]: {
|
||||||
@@ -21,7 +22,7 @@ export class BalanceAndProxyAllowanceLazyStore {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) {
|
constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) {
|
||||||
this._token = token;
|
this._tokenWrapper = token;
|
||||||
this._defaultBlock = defaultBlock;
|
this._defaultBlock = defaultBlock;
|
||||||
this._balance = {};
|
this._balance = {};
|
||||||
this._proxyAllowance = {};
|
this._proxyAllowance = {};
|
||||||
@@ -31,7 +32,7 @@ export class BalanceAndProxyAllowanceLazyStore {
|
|||||||
const methodOpts = {
|
const methodOpts = {
|
||||||
defaultBlock: this._defaultBlock,
|
defaultBlock: this._defaultBlock,
|
||||||
};
|
};
|
||||||
const balance = await this._token.getBalanceAsync(tokenAddress, userAddress, methodOpts);
|
const balance = await this._tokenWrapper.getBalanceAsync(tokenAddress, userAddress, methodOpts);
|
||||||
this.setBalance(tokenAddress, userAddress, balance);
|
this.setBalance(tokenAddress, userAddress, balance);
|
||||||
}
|
}
|
||||||
const cachedBalance = this._balance[tokenAddress][userAddress];
|
const cachedBalance = this._balance[tokenAddress][userAddress];
|
||||||
@@ -59,7 +60,11 @@ export class BalanceAndProxyAllowanceLazyStore {
|
|||||||
const methodOpts = {
|
const methodOpts = {
|
||||||
defaultBlock: this._defaultBlock,
|
defaultBlock: this._defaultBlock,
|
||||||
};
|
};
|
||||||
const proxyAllowance = await this._token.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts);
|
const proxyAllowance = await this._tokenWrapper.getProxyAllowanceAsync(
|
||||||
|
tokenAddress,
|
||||||
|
userAddress,
|
||||||
|
methodOpts,
|
||||||
|
);
|
||||||
this.setProxyAllowance(tokenAddress, userAddress, proxyAllowance);
|
this.setProxyAllowance(tokenAddress, userAddress, proxyAllowance);
|
||||||
}
|
}
|
||||||
const cachedProxyAllowance = this._proxyAllowance[tokenAddress][userAddress];
|
const cachedProxyAllowance = this._proxyAllowance[tokenAddress][userAddress];
|
@@ -1,3 +1,4 @@
|
|||||||
|
import { AbstractOrderFilledCancelledFetcher } from '@0xproject/order-utils';
|
||||||
import { BlockParamLiteral } from '@0xproject/types';
|
import { BlockParamLiteral } from '@0xproject/types';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
@@ -7,25 +8,27 @@ import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
|
|||||||
/**
|
/**
|
||||||
* Copy on read store for filled/cancelled taker amounts
|
* Copy on read store for filled/cancelled taker amounts
|
||||||
*/
|
*/
|
||||||
export class OrderFilledCancelledLazyStore {
|
export class OrderFilledCancelledLazyStore implements AbstractOrderFilledCancelledFetcher {
|
||||||
private _exchange: ExchangeWrapper;
|
private _exchangeWrapper: ExchangeWrapper;
|
||||||
|
private _defaultBlock: BlockParamLiteral;
|
||||||
private _filledTakerAmount: {
|
private _filledTakerAmount: {
|
||||||
[orderHash: string]: BigNumber;
|
[orderHash: string]: BigNumber;
|
||||||
};
|
};
|
||||||
private _cancelledTakerAmount: {
|
private _cancelledTakerAmount: {
|
||||||
[orderHash: string]: BigNumber;
|
[orderHash: string]: BigNumber;
|
||||||
};
|
};
|
||||||
constructor(exchange: ExchangeWrapper) {
|
constructor(exchange: ExchangeWrapper, defaultBlock: BlockParamLiteral) {
|
||||||
this._exchange = exchange;
|
this._exchangeWrapper = exchange;
|
||||||
|
this._defaultBlock = defaultBlock;
|
||||||
this._filledTakerAmount = {};
|
this._filledTakerAmount = {};
|
||||||
this._cancelledTakerAmount = {};
|
this._cancelledTakerAmount = {};
|
||||||
}
|
}
|
||||||
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||||
if (_.isUndefined(this._filledTakerAmount[orderHash])) {
|
if (_.isUndefined(this._filledTakerAmount[orderHash])) {
|
||||||
const methodOpts = {
|
const methodOpts = {
|
||||||
defaultBlock: BlockParamLiteral.Pending,
|
defaultBlock: this._defaultBlock,
|
||||||
};
|
};
|
||||||
const filledTakerAmount = await this._exchange.getFilledTakerAmountAsync(orderHash, methodOpts);
|
const filledTakerAmount = await this._exchangeWrapper.getFilledTakerAmountAsync(orderHash, methodOpts);
|
||||||
this.setFilledTakerAmount(orderHash, filledTakerAmount);
|
this.setFilledTakerAmount(orderHash, filledTakerAmount);
|
||||||
}
|
}
|
||||||
const cachedFilled = this._filledTakerAmount[orderHash];
|
const cachedFilled = this._filledTakerAmount[orderHash];
|
||||||
@@ -40,9 +43,12 @@ export class OrderFilledCancelledLazyStore {
|
|||||||
public async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
public async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||||
if (_.isUndefined(this._cancelledTakerAmount[orderHash])) {
|
if (_.isUndefined(this._cancelledTakerAmount[orderHash])) {
|
||||||
const methodOpts = {
|
const methodOpts = {
|
||||||
defaultBlock: BlockParamLiteral.Pending,
|
defaultBlock: this._defaultBlock,
|
||||||
};
|
};
|
||||||
const cancelledTakerAmount = await this._exchange.getCancelledTakerAmountAsync(orderHash, methodOpts);
|
const cancelledTakerAmount = await this._exchangeWrapper.getCancelledTakerAmountAsync(
|
||||||
|
orderHash,
|
||||||
|
methodOpts,
|
||||||
|
);
|
||||||
this.setCancelledTakerAmount(orderHash, cancelledTakerAmount);
|
this.setCancelledTakerAmount(orderHash, cancelledTakerAmount);
|
||||||
}
|
}
|
||||||
const cachedCancelled = this._cancelledTakerAmount[orderHash];
|
const cachedCancelled = this._cancelledTakerAmount[orderHash];
|
||||||
@@ -58,4 +64,12 @@ export class OrderFilledCancelledLazyStore {
|
|||||||
this._filledTakerAmount = {};
|
this._filledTakerAmount = {};
|
||||||
this._cancelledTakerAmount = {};
|
this._cancelledTakerAmount = {};
|
||||||
}
|
}
|
||||||
|
public async getUnavailableTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||||
|
const unavailableTakerAmount = await this._exchangeWrapper.getUnavailableTakerAmountAsync(orderHash);
|
||||||
|
return unavailableTakerAmount;
|
||||||
|
}
|
||||||
|
public getZRXTokenAddress(): string {
|
||||||
|
const zrxToken = this._exchangeWrapper.getZRXTokenAddress();
|
||||||
|
return zrxToken;
|
||||||
|
}
|
||||||
}
|
}
|
186
packages/contract-wrappers/src/types.ts
Normal file
186
packages/contract-wrappers/src/types.ts
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
import { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
|
import {
|
||||||
|
BlockParam,
|
||||||
|
BlockParamLiteral,
|
||||||
|
ContractAbi,
|
||||||
|
ContractEventArg,
|
||||||
|
ExchangeContractErrs,
|
||||||
|
FilterObject,
|
||||||
|
LogEntryEvent,
|
||||||
|
LogWithDecodedArgs,
|
||||||
|
Order,
|
||||||
|
OrderState,
|
||||||
|
SignedOrder,
|
||||||
|
} from '@0xproject/types';
|
||||||
|
|
||||||
|
import { EtherTokenContractEventArgs, EtherTokenEvents } from './contract_wrappers/generated/ether_token';
|
||||||
|
import { ExchangeContractEventArgs, ExchangeEvents } from './contract_wrappers/generated/exchange';
|
||||||
|
import { TokenContractEventArgs, TokenEvents } from './contract_wrappers/generated/token';
|
||||||
|
|
||||||
|
export enum ContractWrappersError {
|
||||||
|
ExchangeContractDoesNotExist = 'EXCHANGE_CONTRACT_DOES_NOT_EXIST',
|
||||||
|
ZRXContractDoesNotExist = 'ZRX_CONTRACT_DOES_NOT_EXIST',
|
||||||
|
EtherTokenContractDoesNotExist = 'ETHER_TOKEN_CONTRACT_DOES_NOT_EXIST',
|
||||||
|
TokenTransferProxyContractDoesNotExist = 'TOKEN_TRANSFER_PROXY_CONTRACT_DOES_NOT_EXIST',
|
||||||
|
TokenRegistryContractDoesNotExist = 'TOKEN_REGISTRY_CONTRACT_DOES_NOT_EXIST',
|
||||||
|
TokenContractDoesNotExist = 'TOKEN_CONTRACT_DOES_NOT_EXIST',
|
||||||
|
ContractNotDeployedOnNetwork = 'CONTRACT_NOT_DEPLOYED_ON_NETWORK',
|
||||||
|
InsufficientAllowanceForTransfer = 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER',
|
||||||
|
InsufficientBalanceForTransfer = 'INSUFFICIENT_BALANCE_FOR_TRANSFER',
|
||||||
|
InsufficientEthBalanceForDeposit = 'INSUFFICIENT_ETH_BALANCE_FOR_DEPOSIT',
|
||||||
|
InsufficientWEthBalanceForWithdrawal = 'INSUFFICIENT_WETH_BALANCE_FOR_WITHDRAWAL',
|
||||||
|
InvalidJump = 'INVALID_JUMP',
|
||||||
|
OutOfGas = 'OUT_OF_GAS',
|
||||||
|
SubscriptionNotFound = 'SUBSCRIPTION_NOT_FOUND',
|
||||||
|
SubscriptionAlreadyPresent = 'SUBSCRIPTION_ALREADY_PRESENT',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum InternalContractWrappersError {
|
||||||
|
NoAbiDecoder = 'NO_ABI_DECODER',
|
||||||
|
ZrxNotInTokenRegistry = 'ZRX_NOT_IN_TOKEN_REGISTRY',
|
||||||
|
WethNotInTokenRegistry = 'WETH_NOT_IN_TOKEN_REGISTRY',
|
||||||
|
}
|
||||||
|
|
||||||
|
export type LogEvent = LogEntryEvent;
|
||||||
|
export interface DecodedLogEvent<ArgsType> {
|
||||||
|
isRemoved: boolean;
|
||||||
|
log: LogWithDecodedArgs<ArgsType>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type EventCallback<ArgsType> = (err: null | Error, log?: DecodedLogEvent<ArgsType>) => void;
|
||||||
|
|
||||||
|
export enum ExchangeContractErrCodes {
|
||||||
|
ERROR_FILL_EXPIRED, // Order has already expired
|
||||||
|
ERROR_FILL_NO_VALUE, // Order has already been fully filled or cancelled
|
||||||
|
ERROR_FILL_TRUNCATION, // Rounding error too large
|
||||||
|
ERROR_FILL_BALANCE_ALLOWANCE, // Insufficient balance or allowance for token transfer
|
||||||
|
ERROR_CANCEL_EXPIRED, // Order has already expired
|
||||||
|
ERROR_CANCEL_NO_VALUE, // Order has already been fully filled or cancelled
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ContractEvent {
|
||||||
|
logIndex: number;
|
||||||
|
transactionIndex: number;
|
||||||
|
transactionHash: string;
|
||||||
|
blockHash: string;
|
||||||
|
blockNumber: number;
|
||||||
|
address: string;
|
||||||
|
type: string;
|
||||||
|
event: string;
|
||||||
|
args: ContractEventArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ContractEventArgs = ExchangeContractEventArgs | TokenContractEventArgs | EtherTokenContractEventArgs;
|
||||||
|
|
||||||
|
// [address, name, symbol, decimals, ipfsHash, swarmHash]
|
||||||
|
export type TokenMetadata = [string, string, string, number, string, string];
|
||||||
|
|
||||||
|
export interface Token {
|
||||||
|
name: string;
|
||||||
|
address: string;
|
||||||
|
symbol: string;
|
||||||
|
decimals: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TxOpts {
|
||||||
|
from: string;
|
||||||
|
gas?: number;
|
||||||
|
value?: BigNumber;
|
||||||
|
gasPrice?: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TokenAddressBySymbol {
|
||||||
|
[symbol: string]: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ContractEvents = TokenEvents | ExchangeEvents | EtherTokenEvents;
|
||||||
|
|
||||||
|
export interface IndexedFilterValues {
|
||||||
|
[index: string]: ContractEventArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BlockRange {
|
||||||
|
fromBlock: BlockParam;
|
||||||
|
toBlock: BlockParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderCancellationRequest {
|
||||||
|
order: Order | SignedOrder;
|
||||||
|
takerTokenCancelAmount: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderFillRequest {
|
||||||
|
signedOrder: SignedOrder;
|
||||||
|
takerTokenFillAmount: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AsyncMethod = (...args: any[]) => Promise<any>;
|
||||||
|
export type SyncMethod = (...args: any[]) => any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* networkId: The id of the underlying ethereum network your provider is connected to. (1-mainnet, 3-ropsten, 4-rinkeby, 42-kovan, 50-testrpc)
|
||||||
|
* gasPrice: Gas price to use with every transaction
|
||||||
|
* exchangeContractAddress: The address of an exchange contract to use
|
||||||
|
* zrxContractAddress: The address of the ZRX contract to use
|
||||||
|
* tokenRegistryContractAddress: The address of a token registry contract to use
|
||||||
|
* tokenTransferProxyContractAddress: The address of the token transfer proxy contract to use
|
||||||
|
* orderWatcherConfig: All the configs related to the orderWatcher
|
||||||
|
*/
|
||||||
|
export interface ContractWrappersConfig {
|
||||||
|
networkId: number;
|
||||||
|
gasPrice?: BigNumber;
|
||||||
|
exchangeContractAddress?: string;
|
||||||
|
zrxContractAddress?: string;
|
||||||
|
tokenRegistryContractAddress?: string;
|
||||||
|
tokenTransferProxyContractAddress?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* expectedFillTakerTokenAmount: If specified, the validation method will ensure that the
|
||||||
|
* supplied order maker has a sufficient allowance/balance to fill this amount of the order's
|
||||||
|
* takerTokenAmount. If not specified, the validation method ensures that the maker has a sufficient
|
||||||
|
* allowance/balance to fill the entire remaining order amount.
|
||||||
|
*/
|
||||||
|
export interface ValidateOrderFillableOpts {
|
||||||
|
expectedFillTakerTokenAmount?: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* defaultBlock: The block up to which to query the blockchain state. Setting this to a historical block number
|
||||||
|
* let's the user query the blockchain's state at an arbitrary point in time. In order for this to work, the
|
||||||
|
* backing Ethereum node must keep the entire historical state of the chain (e.g setting `--pruning=archive`
|
||||||
|
* flag when running Parity).
|
||||||
|
*/
|
||||||
|
export interface MethodOpts {
|
||||||
|
defaultBlock?: BlockParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gasPrice: Gas price in Wei to use for a transaction
|
||||||
|
* gasLimit: The amount of gas to send with a transaction
|
||||||
|
*/
|
||||||
|
export interface TransactionOpts {
|
||||||
|
gasPrice?: BigNumber;
|
||||||
|
gasLimit?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before
|
||||||
|
* broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true.
|
||||||
|
*/
|
||||||
|
export interface OrderTransactionOpts extends TransactionOpts {
|
||||||
|
shouldValidate?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum TradeSide {
|
||||||
|
Maker = 'maker',
|
||||||
|
Taker = 'taker',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum TransferType {
|
||||||
|
Trade = 'trade',
|
||||||
|
Fee = 'fee',
|
||||||
|
}
|
||||||
|
|
||||||
|
export type OnOrderStateChangeCallback = (err: Error | null, orderState?: OrderState) => void;
|
@@ -8,13 +8,13 @@ import { BigNumber } from '@0xproject/utils';
|
|||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { signatureUtils } from '../utils/signature_utils';
|
import { isValidSignature } from '@0xproject/order-utils';
|
||||||
|
|
||||||
export const assert = {
|
export const assert = {
|
||||||
...sharedAssert,
|
...sharedAssert,
|
||||||
isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
|
isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string): void {
|
||||||
const isValidSignature = signatureUtils.isValidSignature(orderHash, ecSignature, signerAddress);
|
const isValid = isValidSignature(orderHash, ecSignature, signerAddress);
|
||||||
this.assert(isValidSignature, `Expected order with hash '${orderHash}' to have a valid signature`);
|
this.assert(isValid, `Expected order with hash '${orderHash}' to have a valid signature`);
|
||||||
},
|
},
|
||||||
async isSenderAddressAsync(
|
async isSenderAddressAsync(
|
||||||
variableName: string,
|
variableName: string,
|
||||||
@@ -28,8 +28,4 @@ export const assert = {
|
|||||||
`Specified ${variableName} ${senderAddressHex} isn't available through the supplied web3 provider`,
|
`Specified ${variableName} ${senderAddressHex} isn't available through the supplied web3 provider`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
async isUserAddressAvailableAsync(web3Wrapper: Web3Wrapper): Promise<void> {
|
|
||||||
const availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
|
||||||
this.assert(!_.isEmpty(availableAddresses), 'No addresses were available on the provided web3 provider');
|
|
||||||
},
|
|
||||||
};
|
};
|
12
packages/contract-wrappers/src/utils/constants.ts
Normal file
12
packages/contract-wrappers/src/utils/constants.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
|
export const constants = {
|
||||||
|
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
|
||||||
|
TESTRPC_NETWORK_ID: 50,
|
||||||
|
INVALID_JUMP_PATTERN: 'invalid JUMP at',
|
||||||
|
OUT_OF_GAS_PATTERN: 'out of gas',
|
||||||
|
INVALID_TAKER_FORMAT: 'instance.taker is not of a type(s) string',
|
||||||
|
// tslint:disable-next-line:custom-no-magic-numbers
|
||||||
|
UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1),
|
||||||
|
DEFAULT_BLOCK_POLLING_INTERVAL: 1000,
|
||||||
|
};
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user