Compare commits
525 Commits
@0xproject
...
@0xproject
Author | SHA1 | Date | |
---|---|---|---|
|
00a4fa5f7c | ||
|
4475fefd07 | ||
|
cd08a9c121 | ||
|
b0c4eb8333 | ||
|
368dbda8f0 | ||
|
bc4149683e | ||
|
6174d9ebb7 | ||
|
e4fc8a8414 | ||
|
907972c466 | ||
|
49f5fe635f | ||
|
77290c1efa | ||
|
4ac43a9fd2 | ||
|
cc77d1dd49 | ||
|
51161784e8 | ||
|
cb7660fbe7 | ||
|
82e51b8787 | ||
|
fffa96bba7 | ||
|
e6cb2e0fcd | ||
|
38abeaed9c | ||
|
90c9e3496a | ||
|
9fc8a6e214 | ||
|
9df87a199a | ||
|
7e9ba50502 | ||
|
41559c39b9 | ||
|
6a6b424c86 | ||
|
3a5c6ed00f | ||
|
db54588d05 | ||
|
52fde551e4 | ||
|
40cf805e5e | ||
|
09d6496135 | ||
|
c4dadf4bfd | ||
|
35ba3e6f7c | ||
|
3ac182ee91 | ||
|
00e7c70b4d | ||
|
0aa9ed3839 | ||
|
d652deea23 | ||
|
878db3b849 | ||
|
ec2e726be0 | ||
|
287830d6e0 | ||
|
c7a7ae7e18 | ||
|
1c7ba6a315 | ||
|
0a6f107243 | ||
|
a93f95c55e | ||
|
6833e243b7 | ||
|
81dc893d1d | ||
|
f8e565bc06 | ||
|
ba15fb6a06 | ||
|
1e6b83719a | ||
|
9fcb2dda73 | ||
|
9a5ec8d030 | ||
|
ac872e5181 | ||
|
70863cca08 | ||
|
5a1dce15be | ||
|
d291256158 | ||
|
8c706ac639 | ||
|
f697814849 | ||
|
ca5c9e77c0 | ||
|
a32b201afe | ||
|
0ecdf1e213 | ||
|
057891b342 | ||
|
407f63ef20 | ||
|
f938c989e3 | ||
|
c8500cab10 | ||
|
c28c3db63f | ||
|
a09ee90739 | ||
|
7d5a23969d | ||
|
56c3c29feb | ||
|
c75212bef0 | ||
|
6d0dedc62c | ||
|
cf12daea2f | ||
|
6f88e9bdbd | ||
|
d8cb56caa3 | ||
|
044415e23d | ||
|
6b866d6053 | ||
|
74ce893f52 | ||
|
cc1fac9bbe | ||
|
94e01be9ed | ||
|
e215992859 | ||
|
e6f5cac878 | ||
|
29971f36cf | ||
|
3e4493b389 | ||
|
749c6ecc30 | ||
|
e6e7bae445 | ||
|
a1d8943552 | ||
|
07e56b3cc7 | ||
|
b16f5f55fb | ||
|
d92fd43791 | ||
|
e706fa76ac | ||
|
11328bd93d | ||
|
bc686fcbf3 | ||
|
80291caf7c | ||
|
cd5e9a5115 | ||
|
82b51db17e | ||
|
3557cd93fc | ||
|
0629a7d143 | ||
|
a27112cbef | ||
|
d039a1adda | ||
|
bb4d449e92 | ||
|
241534a63d | ||
|
1932aff35c | ||
|
4f27991959 | ||
|
8ce4f9c784 | ||
|
7351bf0b14 | ||
|
f6080367fe | ||
|
7f78d7da9d | ||
|
6734f2f1bc | ||
|
0fb7617a78 | ||
|
4219af1430 | ||
|
c109d1f545 | ||
|
50fab9feb3 | ||
|
3dad6ee55e | ||
|
5d70df771b | ||
|
ab5df342e1 | ||
|
6a9669a409 | ||
|
e68942ee78 | ||
|
4159e45aff | ||
|
92497d7df4 | ||
|
070eff6f3a | ||
|
681ed822ec | ||
|
0a1ae2c311 | ||
|
c5f8b9c2d2 | ||
|
7f36574a57 | ||
|
b637ca105a | ||
|
9ffddb47b8 | ||
|
7bcaac4e10 | ||
|
7f585a15f5 | ||
|
b38ef579fb | ||
|
8427db36e9 | ||
|
2d1c88c20d | ||
|
029ea52979 | ||
|
a2b6255f40 | ||
|
d4592c0a60 | ||
|
fb6d511811 | ||
|
c1b4fe999c | ||
|
1354f794a1 | ||
|
8f6a96740e | ||
|
1d6699585e | ||
|
e96f36751a | ||
|
a75c298de0 | ||
|
d603d8da47 | ||
|
1040826b8b | ||
|
a551d0a6dd | ||
|
21c37ba62f | ||
|
2c660e62d3 | ||
|
6b667f8eca | ||
|
d52c1310b2 | ||
|
6338b5bd3c | ||
|
2713cca6ac | ||
|
57c104119c | ||
|
cd5c73550b | ||
|
68b060cb6a | ||
|
7ad1a18a4a | ||
|
6e27324a34 | ||
|
8eb4b6f917 | ||
|
0ca64e394b | ||
|
c4c47d9665 | ||
|
f9b222c127 | ||
|
28f077b16f | ||
|
3563fabe88 | ||
|
1ca176e992 | ||
|
52e2c60361 | ||
|
ae154f43df | ||
|
610caef73f | ||
|
29a9e1fc4e | ||
|
ae937cfcce | ||
|
6c7dca7d07 | ||
|
aa9efd79db | ||
|
f0f4f873a9 | ||
|
0577ab96b8 | ||
|
15a34dca79 | ||
|
2b38163274 | ||
|
572ad4615a | ||
|
b013cf2e14 | ||
|
3e56990db7 | ||
|
2de7a49000 | ||
|
2a63592994 | ||
|
2cef8d3a3e | ||
|
1417ee2ccb | ||
|
04e4fe251a | ||
|
61255309d2 | ||
|
27d329ff25 | ||
|
cb19623a3a | ||
|
44ca6c4b71 | ||
|
bfabdf6010 | ||
|
cbcf8e8477 | ||
|
b0b3f9e339 | ||
|
a5c7ddcff5 | ||
|
6cef847a27 | ||
|
68dfd1bb22 | ||
|
67d33ec10c | ||
|
05ba049f59 | ||
|
867ff3c5ec | ||
|
c2454d1428 | ||
|
7e0e195c88 | ||
|
e8a1950a74 | ||
|
3c973ba9f6 | ||
|
2ef867f398 | ||
|
90f2813d0e | ||
|
dd9c4b6e5d | ||
|
a6cdc38d53 | ||
|
167c4f8519 | ||
|
799db64541 | ||
|
69b436babe | ||
|
c83f2a070c | ||
|
ba9e31d3c1 | ||
|
e915d72202 | ||
|
74e7fa13d6 | ||
|
b7c119b2aa | ||
|
3c2af2067f | ||
|
7c29cadb17 | ||
|
40b202f8c0 | ||
|
392c00a698 | ||
|
fb4fbc0e13 | ||
|
730226081c | ||
|
1fdd7466b2 | ||
|
00b7620af1 | ||
|
a39d79352d | ||
|
3b5c8a847b | ||
|
4b84081795 | ||
|
27ba218ed7 | ||
|
d907b40378 | ||
|
0248add542 | ||
|
c12f0d04bb | ||
|
22de88035c | ||
|
80e52464a6 | ||
|
3760eb5baf | ||
|
c905b20ce6 | ||
|
301cb296ec | ||
|
1bbd7bf870 | ||
|
da15df2c2d | ||
|
fe43f84abd | ||
|
7fa5b474eb | ||
|
3d25758b1d | ||
|
f1ddbc9387 | ||
|
dafb282432 | ||
|
0918f95421 | ||
|
be67c25b0a | ||
|
f53157414f | ||
|
6b838c034a | ||
|
86cb89feef | ||
|
1ba26ea5e8 | ||
|
8b79868c36 | ||
|
8bb7b5b543 | ||
|
809d301d58 | ||
|
c00c477307 | ||
|
6216714be1 | ||
|
cc90c806b0 | ||
|
04bbd60c11 | ||
|
ad9bb3ea59 | ||
|
1ddac0bc7b | ||
|
a7468eb858 | ||
|
213d82a2c2 | ||
|
7553411fb2 | ||
|
c52c94214f | ||
|
151cf03f5b | ||
|
141c51eaf5 | ||
|
ab7d083aa5 | ||
|
12881e60e3 | ||
|
1f65de60b4 | ||
|
635373febb | ||
|
e7c7af8ef4 | ||
|
cd2bbd850d | ||
|
83a36bc4b6 | ||
|
1c95f685bb | ||
|
e45d320fc5 | ||
|
dd2e54d60d | ||
|
64eac5f37f | ||
|
78ed6e0339 | ||
|
79aff1c57a | ||
|
a21bfc5f2c | ||
|
da3dc7affc | ||
|
254d88ffa0 | ||
|
4ded591624 | ||
|
2af99a1fe2 | ||
|
135fbf67ad | ||
|
6405c70d07 | ||
|
1255570b95 | ||
|
a263e7dfce | ||
|
cbe0ffb3ce | ||
|
67b4ba2a57 | ||
|
ab71f54128 | ||
|
cabce8cb67 | ||
|
44cc5e45cc | ||
|
1ae11ed8ae | ||
|
075e3a41c8 | ||
|
756787c61f | ||
|
b67677f476 | ||
|
b4cf69b021 | ||
|
d149b6cdec | ||
|
f29263c477 | ||
|
61ef6edaa5 | ||
|
fae58ca695 | ||
|
1c68057999 | ||
|
fb637d9234 | ||
|
0f7ced3625 | ||
|
ea4d7f153a | ||
|
f2d1d95355 | ||
|
ddf85112d7 | ||
|
05ce002435 | ||
|
48ec78d3aa | ||
|
e35788e2c8 | ||
|
8bce73dc67 | ||
|
c13f538400 | ||
|
09d3d15db0 | ||
|
633e6c38c8 | ||
|
a4d6bc3190 | ||
|
0b9a9d92af | ||
|
a82e36c1d4 | ||
|
61ba012b1f | ||
|
aeb9ffbf5a | ||
|
6dde6d7cb7 | ||
|
1d70724bcf | ||
|
77c87cd009 | ||
|
4dd59a370d | ||
|
7a6e647386 | ||
|
f5459164d2 | ||
|
2743eee044 | ||
|
bb3c345891 | ||
|
0f3201d72a | ||
|
8131a87046 | ||
|
64a85dfb9c | ||
|
68d7eb5712 | ||
|
f7375fca98 | ||
|
e079790f7f | ||
|
2604d40751 | ||
|
89174cd63f | ||
|
8cb1d2a0af | ||
|
c1ec849554 | ||
|
def575b995 | ||
|
d0d6a6a500 | ||
|
445177bf42 | ||
|
a4c3a0d39f | ||
|
7c08f6d30a | ||
|
0337b5a401 | ||
|
4d81ab679d | ||
|
72752bcb68 | ||
|
e47e9c5b34 | ||
|
402ca27fbf | ||
|
8e3df2b5ae | ||
|
bf9ee82d9f | ||
|
ae7bce7674 | ||
|
7d09a94428 | ||
|
b7079e9616 | ||
|
85427a84df | ||
|
a59f18927d | ||
|
a607a61bde | ||
|
421a7394df | ||
|
acb3c0d0aa | ||
|
11231795cd | ||
|
6b6b368bf6 | ||
|
60f026e6fd | ||
|
36668f9409 | ||
|
480d28ea26 | ||
|
88c99396a2 | ||
|
ca5e52920d | ||
|
30dfb7511d | ||
|
1c87e5f698 | ||
|
badcb35525 | ||
|
c325d638c9 | ||
|
baab0f27b5 | ||
|
9e7657ac5d | ||
|
237bac920a | ||
|
89202b7bdf | ||
|
20ac6936ac | ||
|
976d159e52 | ||
|
e7f19e350e | ||
|
41768617a9 | ||
|
455c78dfb1 | ||
|
ec41e314b0 | ||
|
8959b0993e | ||
|
7c96fa45f8 | ||
|
ad9a7d72ce | ||
|
558286467b | ||
|
f0f94f199e | ||
|
6e74d1519b | ||
|
a8d44ccc48 | ||
|
d744468479 | ||
|
c01810f0d7 | ||
|
622509c508 | ||
|
bb992f8a49 | ||
|
c11d805469 | ||
|
3b8a343711 | ||
|
83e3bb899e | ||
|
bb4558e0be | ||
|
3eeb9ddfa6 | ||
|
cb5d8d75bf | ||
|
267078ed6c | ||
|
80e5127a46 | ||
|
19e17ba128 | ||
|
04e00e0c28 | ||
|
8bebffb147 | ||
|
5c40c466f6 | ||
|
f9f232f5d9 | ||
|
7b7b97dd7b | ||
|
b6cdc00a31 | ||
|
644fe1de8f | ||
|
ce88086e08 | ||
|
1d9408a8e0 | ||
|
c743f010e3 | ||
|
2f2582a0da | ||
|
c1cc92a46f | ||
|
9c3d10d5be | ||
|
3afe405bbe | ||
|
7eff195d61 | ||
|
e79c7632e6 | ||
|
aa27346f93 | ||
|
db6de490b2 | ||
|
014d71d5ae | ||
|
783bc873db | ||
|
478bf14289 | ||
|
d89934954d | ||
|
6baa5ef311 | ||
|
db20ad1c5d | ||
|
56eb444ea4 | ||
|
6a2634d362 | ||
|
a2192e62df | ||
|
66745c5260 | ||
|
c10c4cec1d | ||
|
f2d9dfb56b | ||
|
228387f995 | ||
|
336519a690 | ||
|
10dc3ea81c | ||
|
dd7e03c7d7 | ||
|
fadd292ecf | ||
|
99b744ba52 | ||
|
c320c8742e | ||
|
3a086cae1a | ||
|
b10cba600d | ||
|
d859399841 | ||
|
8169155a65 | ||
|
952367d532 | ||
|
67666446bf | ||
|
3d1c8dfe06 | ||
|
ab64ea7377 | ||
|
b86210332f | ||
|
af52598d32 | ||
|
cbe639866e | ||
|
fcd57d2743 | ||
|
c0924d8067 | ||
|
a1860b076d | ||
|
32ab4dcac7 | ||
|
9f42ceb5a3 | ||
|
386b5bb122 | ||
|
ca67e7d36f | ||
|
d49af66add | ||
|
1a89905ab9 | ||
|
b2b3c24fd2 | ||
|
bc5835229d | ||
|
6182d2c7f6 | ||
|
af90a777c6 | ||
|
fdcb42d8e1 | ||
|
4e6322beb5 | ||
|
6e122691d1 | ||
|
ea5684e054 | ||
|
50bbd793c6 | ||
|
a1a777e715 | ||
|
d234ee12de | ||
|
50e0ddcf79 | ||
|
da304de3fc | ||
|
ff3c77f7c4 | ||
|
4527e9ce00 | ||
|
7759e67a5a | ||
|
4d75689790 | ||
|
6df8746871 | ||
|
c68e183953 | ||
|
f42119c928 | ||
|
30be039570 | ||
|
bcc1ad2086 | ||
|
343cd05363 | ||
|
d9f09b5e1e | ||
|
9337d207a1 | ||
|
c17d6c47c3 | ||
|
a728247d6c | ||
|
36d615318d | ||
|
1588f4ac39 | ||
|
0e82be1bda | ||
|
d85ce6ac75 | ||
|
0d3d9dad84 | ||
|
b8c8258404 | ||
|
3ee3fc2fb3 | ||
|
10f6647ab3 | ||
|
406b7c33f5 | ||
|
13520dbd94 | ||
|
d136df7679 | ||
|
8c96a31152 | ||
|
d4bd4ec441 | ||
|
e4aed98a3d | ||
|
4a2a22a43b | ||
|
47584b18e9 | ||
|
6dd656bdfc | ||
|
b5d98a2803 | ||
|
c7a5b8c776 | ||
|
90ead59d34 | ||
|
faa980ffc3 | ||
|
9a3b630b19 | ||
|
b3473ff89f | ||
|
987971bd59 | ||
|
71a2f2d721 | ||
|
238eef6bae | ||
|
b92b745ab7 | ||
|
0132286cab | ||
|
2494af99aa | ||
|
e5b93d1f02 | ||
|
32e1c2ac97 | ||
|
5e3bbbbb3c | ||
|
3bdf6004ca | ||
|
11869122b4 | ||
|
9b24459108 | ||
|
c5fbc5c991 | ||
|
0413e3e77f | ||
|
92fda0a940 | ||
|
ba00cd916a | ||
|
b4f916d214 | ||
|
79faf7d3cb | ||
|
79b1b6c8e0 | ||
|
b56fc697c4 | ||
|
b7ff1fe5d3 | ||
|
1b24064c9f | ||
|
bb9237b0f4 | ||
|
fe2787fcc1 | ||
|
11778db05a | ||
|
454af2bda3 | ||
|
9f7479711e | ||
|
4579e1637d | ||
|
f4a2e227e1 |
@@ -17,16 +17,19 @@ jobs:
|
|||||||
- yarn-packages-{{ .Branch }}
|
- yarn-packages-{{ .Branch }}
|
||||||
- yarn-packages-master
|
- yarn-packages-master
|
||||||
- yarn-packages-
|
- yarn-packages-
|
||||||
|
- run:
|
||||||
|
name: install-yarn
|
||||||
|
command: sudo npm install --global yarn@1.9.4
|
||||||
- run:
|
- run:
|
||||||
name: yarn
|
name: yarn
|
||||||
command: yarn --frozen-lockfile install
|
command: yarn --frozen-lockfile install || yarn --frozen-lockfile install
|
||||||
- save_cache:
|
- save_cache:
|
||||||
name: Save Yarn Package Cache
|
name: Save Yarn Package Cache
|
||||||
key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
|
key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
|
||||||
paths:
|
paths:
|
||||||
- node_modules/
|
- node_modules/
|
||||||
- run: >
|
- run: >
|
||||||
if [ -z "$(git diff --name-only v2-prototype packages/website)" ]; then
|
if [ -z "$(git diff --name-only development packages/website)" ]; then
|
||||||
yarn build --exclude website
|
yarn build --exclude website
|
||||||
else
|
else
|
||||||
yarn build
|
yarn build
|
||||||
@@ -66,6 +69,15 @@ jobs:
|
|||||||
keys:
|
keys:
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run: yarn test:publish:circleci
|
- run: yarn test:publish:circleci
|
||||||
|
test-doc-generation:
|
||||||
|
docker:
|
||||||
|
- image: circleci/node:9
|
||||||
|
working_directory: ~/repo
|
||||||
|
steps:
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
|
- run: yarn test:generate_docs:circleci
|
||||||
test-rest:
|
test-rest:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:9
|
- image: circleci/node:9
|
||||||
@@ -74,7 +86,6 @@ jobs:
|
|||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run: yarn wsrun test:circleci 0x.js
|
|
||||||
- run: yarn wsrun test:circleci @0xproject/abi-gen
|
- run: yarn wsrun test:circleci @0xproject/abi-gen
|
||||||
- run: yarn wsrun test:circleci @0xproject/assert
|
- run: yarn wsrun test:circleci @0xproject/assert
|
||||||
- run: yarn wsrun test:circleci @0xproject/base-contract
|
- run: yarn wsrun test:circleci @0xproject/base-contract
|
||||||
@@ -91,10 +102,6 @@ jobs:
|
|||||||
- run: yarn wsrun test:circleci @0xproject/subproviders
|
- run: yarn wsrun test:circleci @0xproject/subproviders
|
||||||
- run: yarn wsrun test:circleci @0xproject/web3-wrapper
|
- run: yarn wsrun test:circleci @0xproject/web3-wrapper
|
||||||
- run: yarn wsrun test:circleci @0xproject/utils
|
- run: yarn wsrun test:circleci @0xproject/utils
|
||||||
- save_cache:
|
|
||||||
key: coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/packages/0x.js/coverage/lcov.info
|
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
|
key: coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
@@ -173,9 +180,6 @@ jobs:
|
|||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
|
- coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
@@ -245,6 +249,9 @@ workflows:
|
|||||||
- test-publish:
|
- test-publish:
|
||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
|
- test-doc-generation:
|
||||||
|
requires:
|
||||||
|
- build
|
||||||
- submit-coverage:
|
- submit-coverage:
|
||||||
requires:
|
requires:
|
||||||
- test-rest
|
- test-rest
|
||||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@@ -84,6 +84,11 @@ packages/order-watcher/test/artifacts/
|
|||||||
packages/contract-wrappers/test/artifacts/
|
packages/contract-wrappers/test/artifacts/
|
||||||
packages/contract-wrappers/src/artifacts/
|
packages/contract-wrappers/src/artifacts/
|
||||||
packages/order-watcher/src/artifacts/
|
packages/order-watcher/src/artifacts/
|
||||||
|
packages/0x.js/src/artifacts/
|
||||||
|
packages/order-utils/src/artifacts/
|
||||||
|
|
||||||
|
# unstable generated contract artifacts:
|
||||||
|
packages/migrations/artifacts/2.0.0/
|
||||||
|
|
||||||
# generated contract watcher
|
# generated contract watcher
|
||||||
packages/0x.js/src/generated_contract_wrappers/
|
packages/0x.js/src/generated_contract_wrappers/
|
||||||
|
@@ -15,7 +15,7 @@ lib
|
|||||||
/packages/contract-wrappers/src/artifacts
|
/packages/contract-wrappers/src/artifacts
|
||||||
/packages/order-watcher/src/artifacts
|
/packages/order-watcher/src/artifacts
|
||||||
/packages/metacoin/artifacts
|
/packages/metacoin/artifacts
|
||||||
/packages/sra-api/public/
|
/packages/sra-spec/public/
|
||||||
/packages/contract-wrappers/test/artifacts
|
/packages/contract-wrappers/test/artifacts
|
||||||
/packages/order-watcher/test/artifacts
|
/packages/order-watcher/test/artifacts
|
||||||
/packages/migrations/artifacts/1.0.0
|
/packages/migrations/artifacts/1.0.0
|
||||||
|
8
CODEOWNERS
Normal file
8
CODEOWNERS
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# See https://help.github.com/articles/about-codeowners/
|
||||||
|
# for more info about CODEOWNERS file
|
||||||
|
|
||||||
|
# It uses the same pattern rule for gitignore file
|
||||||
|
# https://git-scm.com/docs/gitignore#_pattern_format
|
||||||
|
|
||||||
|
# Website
|
||||||
|
packages/website/ @BMillman19 @fragosti
|
13
README.md
13
README.md
@@ -8,7 +8,7 @@ This repository is a monorepo including the 0x protocol smart contracts and nume
|
|||||||
|
|
||||||
If you're developing on 0x now or are interested in using 0x infrastructure in the future, please join our [developer mailing list][dev-mailing-list-url] for updates.
|
If you're developing on 0x now or are interested in using 0x infrastructure in the future, please join our [developer mailing list][dev-mailing-list-url] for updates.
|
||||||
|
|
||||||
[website-url]: https://0xproject.com/
|
[website-url]: https://0xproject.com
|
||||||
[whitepaper-url]: https://0xproject.com/pdfs/0x_white_paper.pdf
|
[whitepaper-url]: https://0xproject.com/pdfs/0x_white_paper.pdf
|
||||||
[dev-mailing-list-url]: http://eepurl.com/dx4cPf
|
[dev-mailing-list-url]: http://eepurl.com/dx4cPf
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@ If you're developing on 0x now or are interested in using 0x infrastructure in t
|
|||||||
| [`@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-spec`](/packages/sra-spec) | [](https://www.npmjs.com/package/@0xproject/sra-spec) | OpenAPI specification for the standard relayer API |
|
||||||
| [`@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 |
|
| [`@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) |
|
||||||
@@ -68,7 +69,7 @@ Dedicated documentation pages:
|
|||||||
Node version >= 6.12 is required.
|
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 the `@0xproject/typescript-typings` package to your [`typeRoots`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) config.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
|
"typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
|
||||||
@@ -82,13 +83,7 @@ We strongly recommend that the community help us make improvements and determine
|
|||||||
|
|
||||||
### Install dependencies
|
### Install dependencies
|
||||||
|
|
||||||
Make sure you are using Yarn v1.6. To install using brew:
|
Make sure you are using Yarn v1.9.4. To install using brew:
|
||||||
|
|
||||||
```
|
|
||||||
brew unlink yarn
|
|
||||||
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/76215230de5f7f7bee2cfcdd7185cf49d949862d/Formula/yarn.rb
|
|
||||||
brew switch yarn 1.6.0_1
|
|
||||||
```
|
|
||||||
|
|
||||||
Then install dependencies
|
Then install dependencies
|
||||||
|
|
||||||
|
11
package.json
11
package.json
@@ -15,7 +15,7 @@
|
|||||||
"test:installation": "node ./packages/monorepo-scripts/lib/test_installation.js",
|
"test:installation": "node ./packages/monorepo-scripts/lib/test_installation.js",
|
||||||
"test:installation:local": "IS_LOCAL_PUBLISH=true node ./packages/monorepo-scripts/lib/test_installation.js",
|
"test:installation:local": "IS_LOCAL_PUBLISH=true node ./packages/monorepo-scripts/lib/test_installation.js",
|
||||||
"test:publish:circleci:comment": "HACK(albrow) We need an automated way to login to npm and echo+sleep piped to stdin was the only way I could find to do it.",
|
"test:publish:circleci:comment": "HACK(albrow) We need an automated way to login to npm and echo+sleep piped to stdin was the only way I could find to do it.",
|
||||||
"test:publish:circleci": "{ echo \"test\"; sleep 1; echo \"test\"; sleep 1; echo \"test@example.com\"; } | npm login --registry=http://localhost:4873 && IS_LOCAL_PUBLISH=true run-s script:publish test:installation:local",
|
"test:publish:circleci": "yarn npm-cli-login -u test -p test -e test@example.com -r http://localhost:4873 && IS_LOCAL_PUBLISH=true run-s script:publish test:installation:local",
|
||||||
"run:publish": "run-s install:all build:monorepo_scripts script:prepublish_checks rebuild:no_website script:publish",
|
"run:publish": "run-s install:all build:monorepo_scripts script:prepublish_checks rebuild:no_website script:publish",
|
||||||
"run:publish:local": "IS_LOCAL_PUBLISH=true yarn run:publish",
|
"run:publish:local": "IS_LOCAL_PUBLISH=true yarn run:publish",
|
||||||
"script:prepublish_checks": "node ./packages/monorepo-scripts/lib/prepublish_checks.js",
|
"script:prepublish_checks": "node ./packages/monorepo-scripts/lib/prepublish_checks.js",
|
||||||
@@ -32,19 +32,22 @@
|
|||||||
"rebuild": "run-s clean build",
|
"rebuild": "run-s clean build",
|
||||||
"rebuild:no_website": "run-s clean build:no_website",
|
"rebuild:no_website": "run-s clean build:no_website",
|
||||||
"test": "wsrun test $PKG --fast-exit --serial --exclude-missing",
|
"test": "wsrun test $PKG --fast-exit --serial --exclude-missing",
|
||||||
"stage_docs": "wsrun docs:stage $PKG --fast-exit --parallel --exclude-missing",
|
"generate_doc": "node ./packages/monorepo-scripts/lib/doc_generate_and_upload.js",
|
||||||
|
"test:generate_docs:circleci": "for i in ${npm_package_config_packagesWithDocPages}; do yarn generate_doc --package $i --shouldUpload false --isStaging true || break -1; done;",
|
||||||
"lint": "wsrun lint $PKG --fast-exit --parallel --exclude-missing",
|
"lint": "wsrun lint $PKG --fast-exit --parallel --exclude-missing",
|
||||||
"comment:postinstall": "HACK: For some reason `yarn` is not setting up symlinks properly for order-utils. We temporarily set them manually. Remove this after V2 refactor is complete."
|
"comment:postinstall": "HACK: For some reason `yarn` is not setting up symlinks properly for order-utils. We temporarily set them manually. Remove this after V2 refactor is complete."
|
||||||
},
|
},
|
||||||
"config": {
|
"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",
|
||||||
|
"packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-cov ethereum-types"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x-lerna-fork/lerna": "3.0.0-beta.23",
|
"@0x-lerna-fork/lerna": "3.0.0-beta.25",
|
||||||
"async-child-process": "^1.1.1",
|
"async-child-process": "^1.1.1",
|
||||||
"coveralls": "^3.0.0",
|
"coveralls": "^3.0.0",
|
||||||
"ganache-cli": "6.1.3",
|
"ganache-cli": "6.1.3",
|
||||||
"lcov-result-merger": "^3.0.0",
|
"lcov-result-merger": "^3.0.0",
|
||||||
|
"npm-cli-login": "^0.0.10",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
"prettier": "^1.11.1",
|
"prettier": "^1.11.1",
|
||||||
"source-map-support": "^0.5.6",
|
"source-map-support": "^0.5.6",
|
||||||
|
@@ -1,4 +1,33 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "1.0.1-rc.6",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Fix missing `BlockParamLiteral` type import issue"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1535377027
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "1.0.1-rc.5",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Fix `main` and `types` package.json entries so that they point to the new location of index.d.ts and index.js"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "1.0.1-rc.4",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Re-organize the exported interface of 0x.js. Remove the `ZeroEx` class, and instead export the same exports as `0x.js`'s sub-packages: `@0xproject/contract-wrappers`, `@0xproject/order-utils` and `@0xproject/order-watcher`",
|
||||||
|
"pr": 963
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1535133899
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "1.0.1-rc.3",
|
"version": "1.0.1-rc.3",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@@ -5,7 +5,19 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
## v1.0.1-rc.3 - _August 13, 2018_
|
## v1.0.1-rc.6 - _August 27, 2018_
|
||||||
|
|
||||||
|
* Fix missing `BlockParamLiteral` type import issue
|
||||||
|
|
||||||
|
## v1.0.1-rc.5 - _Invalid date_
|
||||||
|
|
||||||
|
* Fix `main` and `types` package.json entries so that they point to the new location of index.d.ts and index.js
|
||||||
|
|
||||||
|
## v1.0.1-rc.4 - _August 24, 2018_
|
||||||
|
|
||||||
|
* Re-organize the exported interface of 0x.js. Remove the `ZeroEx` class, and instead export the same exports as `0x.js`'s sub-packages: `@0xproject/contract-wrappers`, `@0xproject/order-utils` and `@0xproject/order-watcher` (#963)
|
||||||
|
|
||||||
|
## v1.0.1-rc.3 - _August 14, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
* Update ecSignOrderHashAsync to return the signature as a string for immediate use in contracts (#914)
|
* Update ecSignOrderHashAsync to return the signature as a string for immediate use in contracts (#914)
|
||||||
@@ -22,11 +34,11 @@ CHANGELOG
|
|||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
## v1.0.0-rc.2 - _July 19, 2018_
|
## v1.0.0-rc.2 - _July 20, 2018_
|
||||||
|
|
||||||
* Remove `zeroEx.assetData` and instead re-export it's static functions directly off `ZeroEx`
|
* Remove `zeroEx.assetData` and instead re-export it's static functions directly off `ZeroEx`
|
||||||
|
|
||||||
## v1.0.0-rc.1 - _July 19, 2018_
|
## v1.0.0-rc.1 - _July 20, 2018_
|
||||||
|
|
||||||
* Remove tokenRegistry wrapper (#863)
|
* Remove tokenRegistry wrapper (#863)
|
||||||
* Rename `zeroEx.token` to `zeroEx.erc20Token`, and add `zeroEx.erc721Token` (#863)
|
* Rename `zeroEx.token` to `zeroEx.erc20Token`, and add `zeroEx.erc721Token` (#863)
|
||||||
@@ -66,7 +78,7 @@ CHANGELOG
|
|||||||
* Renamed createOrderStateWatcher to createOrderWatcherAsync since it is now async (#579)
|
* 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)
|
* Renamed ZeroExError to ContractWrappersErrors since they now lives in the @0xproject/contract-wrappers subpackage (#579)
|
||||||
|
|
||||||
## v0.37.2 - _May 4, 2018_
|
## v0.37.2 - _May 5, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "0x.js",
|
"name": "0x.js",
|
||||||
"version": "1.0.1-rc.2",
|
"version": "1.0.1-rc.6",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -12,54 +12,28 @@
|
|||||||
"tokens",
|
"tokens",
|
||||||
"exchange"
|
"exchange"
|
||||||
],
|
],
|
||||||
"main": "lib/src/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch_without_deps": "yarn pre_build && tsc -w",
|
"watch_without_deps": "tsc -w",
|
||||||
"build": "yarn pre_build && yarn build:all && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
"build": "yarn build:all",
|
||||||
"build:all": "run-p build:umd:prod build:commonjs; exit 0;",
|
"build:all": "run-p build:umd:prod build:commonjs",
|
||||||
"pre_build": "run-s update_artifacts generate_contract_wrappers",
|
|
||||||
"copy_artifacts": "copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts",
|
|
||||||
"update_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/artifacts/2.0.0/$i.json src/artifacts; done;",
|
|
||||||
"generate_contract_wrappers": "abi-gen --abis 'src/artifacts/@(ZRXToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers",
|
|
||||||
"lint": "tslint --project . --exclude **/src/generated_contract_wrappers/**/*",
|
"lint": "tslint --project . --exclude **/src/generated_contract_wrappers/**/*",
|
||||||
"test:circleci": "run-s test:coverage",
|
"test:circleci": "run-s test:coverage",
|
||||||
"test": "yarn run_mocha",
|
|
||||||
"rebuild_and_test": "run-s build test",
|
"rebuild_and_test": "run-s build test",
|
||||||
"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",
|
||||||
"clean": "shx rm -rf _bundles lib test_temp scripts src/generated_contract_wrappers",
|
"clean": "shx rm -rf _bundles lib test_temp src/generated_contract_wrappers generated_docs",
|
||||||
"build:umd:prod": "NODE_ENV=production webpack",
|
"build:umd:prod": "NODE_ENV=production webpack",
|
||||||
"build:commonjs": "tsc && yarn copy_artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
"build:commonjs": "tsc",
|
||||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
|
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES"
|
||||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
|
|
||||||
"docs:stage": "node scripts/stage_docs.js",
|
|
||||||
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
|
|
||||||
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
|
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"contracts": "ZRXToken",
|
|
||||||
"postpublish": {
|
"postpublish": {
|
||||||
"assets": [
|
"assets": [
|
||||||
"packages/0x.js/_bundles/index.js",
|
"packages/0x.js/_bundles/index.js",
|
||||||
"packages/0x.js/_bundles/index.min.js"
|
"packages/0x.js/_bundles/index.min.js"
|
||||||
],
|
]
|
||||||
"docPublishConfigs": {
|
|
||||||
"extraFileIncludes": [
|
|
||||||
"../types/src/index.ts",
|
|
||||||
"../ethereum-types/src/index.ts",
|
|
||||||
"../contract-wrappers/src/types.ts",
|
|
||||||
"../contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts",
|
|
||||||
"../contract-wrappers/src/contract_wrappers/exchange_wrapper.ts",
|
|
||||||
"../contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts",
|
|
||||||
"../contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts",
|
|
||||||
"../contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts",
|
|
||||||
"../contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts",
|
|
||||||
"../order-watcher/src/order_watcher/order_watcher.ts"
|
|
||||||
],
|
|
||||||
"s3BucketPath": "s3://doc-jsons/0x.js/",
|
|
||||||
"s3StagingBucketPath": "s3://staging-doc-jsons/0x.js/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -68,11 +42,11 @@
|
|||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/abi-gen": "^1.0.4",
|
"@0xproject/abi-gen": "^1.0.7",
|
||||||
"@0xproject/dev-utils": "^1.0.3",
|
"@0xproject/dev-utils": "^1.0.6",
|
||||||
"@0xproject/migrations": "^1.0.3",
|
"@0xproject/migrations": "^1.0.6",
|
||||||
"@0xproject/monorepo-scripts": "^1.0.4",
|
"@0xproject/monorepo-scripts": "^1.0.7",
|
||||||
"@0xproject/tslint-config": "^1.0.4",
|
"@0xproject/tslint-config": "^1.0.6",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/mocha": "^2.2.42",
|
"@types/mocha": "^2.2.42",
|
||||||
"@types/node": "^8.0.53",
|
"@types/node": "^8.0.53",
|
||||||
@@ -81,7 +55,7 @@
|
|||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"chai-as-promised": "^7.1.0",
|
"chai-as-promised": "^7.1.0",
|
||||||
"chai-bignumber": "^2.0.1",
|
"chai-bignumber": "^2.0.1",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "^2.0.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
@@ -93,24 +67,26 @@
|
|||||||
"sinon": "^4.0.0",
|
"sinon": "^4.0.0",
|
||||||
"source-map-support": "^0.5.0",
|
"source-map-support": "^0.5.0",
|
||||||
"tslint": "5.11.0",
|
"tslint": "5.11.0",
|
||||||
"typedoc": "0xProject/typedoc",
|
"typedoc": "0.12.0",
|
||||||
"typescript": "2.9.2",
|
"typescript": "3.0.1",
|
||||||
|
"uglifyjs-webpack-plugin": "^1.3.0",
|
||||||
"webpack": "^3.1.0"
|
"webpack": "^3.1.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/assert": "^1.0.4",
|
"@0xproject/assert": "^1.0.7",
|
||||||
"@0xproject/base-contract": "^1.0.4",
|
"@0xproject/base-contract": "^2.0.1",
|
||||||
"@0xproject/contract-wrappers": "^1.0.1-rc.2",
|
"@0xproject/contract-wrappers": "^1.0.1-rc.5",
|
||||||
"@0xproject/order-utils": "^1.0.1-rc.2",
|
"@0xproject/order-utils": "^1.0.1-rc.6",
|
||||||
"@0xproject/sol-compiler": "^1.0.4",
|
"@0xproject/order-watcher": "^1.0.1-rc.5",
|
||||||
"@0xproject/subproviders": "^1.0.4",
|
"@0xproject/subproviders": "^2.0.1",
|
||||||
"@0xproject/types": "^1.0.1-rc.3",
|
"@0xproject/types": "^1.0.1-rc.6",
|
||||||
"@0xproject/typescript-typings": "^1.0.3",
|
"@0xproject/typescript-typings": "^1.0.5",
|
||||||
"@0xproject/utils": "^1.0.4",
|
"@0xproject/utils": "^1.0.7",
|
||||||
"@0xproject/web3-wrapper": "^1.1.2",
|
"@0xproject/web3-wrapper": "^2.0.1",
|
||||||
"ethereum-types": "^1.0.3",
|
"ethereum-types": "^1.0.5",
|
||||||
"ethers": "3.0.22",
|
"ethers": "3.0.22",
|
||||||
"lodash": "^4.17.5"
|
"lodash": "^4.17.5",
|
||||||
|
"web3-provider-engine": "14.0.6"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
@@ -1,279 +0,0 @@
|
|||||||
import { assert } from '@0xproject/assert';
|
|
||||||
import {
|
|
||||||
ContractWrappers,
|
|
||||||
ContractWrappersConfig,
|
|
||||||
ERC20ProxyWrapper,
|
|
||||||
ERC20TokenWrapper,
|
|
||||||
ERC721ProxyWrapper,
|
|
||||||
ERC721TokenWrapper,
|
|
||||||
EtherTokenWrapper,
|
|
||||||
ExchangeWrapper,
|
|
||||||
} from '@0xproject/contract-wrappers';
|
|
||||||
import {
|
|
||||||
assetDataUtils,
|
|
||||||
ecSignOrderHashAsync,
|
|
||||||
generatePseudoRandomSalt,
|
|
||||||
isValidSignatureAsync,
|
|
||||||
orderHashUtils,
|
|
||||||
} from '@0xproject/order-utils';
|
|
||||||
// HACK: Since we export assetDataUtils from ZeroEx and it has AssetProxyId, ERC20AssetData and ERC721AssetData
|
|
||||||
// in it's public interface, we need to import these types here.
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
import { AssetProxyId, ERC20AssetData, ERC721AssetData, Order, SignedOrder, SignerType } from '@0xproject/types';
|
|
||||||
import { BigNumber } from '@0xproject/utils';
|
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|
||||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
|
||||||
|
|
||||||
import { constants } from './utils/constants';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The ZeroEx class is the single entry-point into the 0x.js library. It contains all of the library's functionality
|
|
||||||
* and all calls to the library should be made through a ZeroEx instance.
|
|
||||||
*/
|
|
||||||
export class ZeroEx {
|
|
||||||
/**
|
|
||||||
* When creating an order without a specified taker or feeRecipient you must supply the Solidity
|
|
||||||
* address null type (as opposed to Javascripts `null`, `undefined` or empty string). We expose
|
|
||||||
* this constant for your convenience.
|
|
||||||
*/
|
|
||||||
public static NULL_ADDRESS = constants.NULL_ADDRESS;
|
|
||||||
/**
|
|
||||||
* An instance of the ExchangeWrapper class containing methods for interacting with the 0x Exchange smart contract.
|
|
||||||
*/
|
|
||||||
public exchange: ExchangeWrapper;
|
|
||||||
/**
|
|
||||||
* An instance of the ERC20TokenWrapper class containing methods for interacting with any ERC20 token smart contract.
|
|
||||||
*/
|
|
||||||
public erc20Token: ERC20TokenWrapper;
|
|
||||||
/**
|
|
||||||
* An instance of the ERC721TokenWrapper class containing methods for interacting with any ERC721 token smart contract.
|
|
||||||
*/
|
|
||||||
public erc721Token: ERC721TokenWrapper;
|
|
||||||
/**
|
|
||||||
* An instance of the EtherTokenWrapper class containing methods for interacting with the
|
|
||||||
* wrapped ETH ERC20 token smart contract.
|
|
||||||
*/
|
|
||||||
public etherToken: EtherTokenWrapper;
|
|
||||||
/**
|
|
||||||
* An instance of the ERC20ProxyWrapper class containing methods for interacting with the
|
|
||||||
* ERC20 proxy smart contract.
|
|
||||||
*/
|
|
||||||
public erc20Proxy: ERC20ProxyWrapper;
|
|
||||||
/**
|
|
||||||
* An instance of the ERC721ProxyWrapper class containing methods for interacting with the
|
|
||||||
* ERC721 proxy smart contract.
|
|
||||||
*/
|
|
||||||
public erc721Proxy: ERC721ProxyWrapper;
|
|
||||||
private readonly _contractWrappers: ContractWrappers;
|
|
||||||
/**
|
|
||||||
* Generates a pseudo-random 256-bit salt.
|
|
||||||
* The salt can be included in a 0x order, ensuring that the order generates a unique orderHash
|
|
||||||
* 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();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Computes the orderHash for a supplied order.
|
|
||||||
* @param order An object that conforms to the Order or SignedOrder interface definitions.
|
|
||||||
* @return The resulting orderHash from hashing the supplied order.
|
|
||||||
*/
|
|
||||||
public static getOrderHashHex(order: Order | SignedOrder): string {
|
|
||||||
return orderHashUtils.getOrderHashHex(order);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Checks if the supplied hex encoded order hash is valid.
|
|
||||||
* Note: Valid means it has the expected format, not that an order with the orderHash exists.
|
|
||||||
* Use this method when processing orderHashes submitted as user input.
|
|
||||||
* @param orderHash Hex encoded orderHash.
|
|
||||||
* @return Whether the supplied orderHash has the expected format.
|
|
||||||
*/
|
|
||||||
public static isValidOrderHash(orderHash: string): boolean {
|
|
||||||
return orderHashUtils.isValidOrderHash(orderHash);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* A unit amount is defined as the amount of a token above the specified decimal places (integer part).
|
|
||||||
* E.g: If a currency has 18 decimal places, 1e18 or one quintillion of the currency is equivalent
|
|
||||||
* to 1 unit.
|
|
||||||
* @param amount The amount in baseUnits that you would like converted to units.
|
|
||||||
* @param decimals The number of decimal places the unit amount has.
|
|
||||||
* @return The amount in units.
|
|
||||||
*/
|
|
||||||
public static toUnitAmount(amount: BigNumber, decimals: number): BigNumber {
|
|
||||||
assert.isValidBaseUnitAmount('amount', amount);
|
|
||||||
assert.isNumber('decimals', decimals);
|
|
||||||
const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);
|
|
||||||
return unitAmount;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* A baseUnit is defined as the smallest denomination of a token. An amount expressed in baseUnits
|
|
||||||
* is the amount expressed in the smallest denomination.
|
|
||||||
* E.g: 1 unit of a token with 18 decimal places is expressed in baseUnits as 1000000000000000000
|
|
||||||
* @param amount The amount of units that you would like converted to baseUnits.
|
|
||||||
* @param decimals The number of decimal places the unit amount has.
|
|
||||||
* @return The amount in baseUnits.
|
|
||||||
*/
|
|
||||||
public static toBaseUnitAmount(amount: BigNumber, decimals: number): BigNumber {
|
|
||||||
assert.isBigNumber('amount', amount);
|
|
||||||
assert.isNumber('decimals', decimals);
|
|
||||||
const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amount, decimals);
|
|
||||||
return baseUnitAmount;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Encodes an ERC20 token address into a hex encoded assetData string, usable in the makerAssetData or
|
|
||||||
* takerAssetData fields in a 0x order.
|
|
||||||
* @param tokenAddress The ERC20 token address to encode
|
|
||||||
* @return The hex encoded assetData string
|
|
||||||
*/
|
|
||||||
public static encodeERC20AssetData(tokenAddress: string): string {
|
|
||||||
return assetDataUtils.encodeERC20AssetData(tokenAddress);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Decodes an ERC20 assetData hex string into it's corresponding ERC20 tokenAddress & assetProxyId
|
|
||||||
* @param assetData Hex encoded assetData string to decode
|
|
||||||
* @return An object containing the decoded tokenAddress & assetProxyId
|
|
||||||
*/
|
|
||||||
public static decodeERC20AssetData(assetData: string): ERC20AssetData {
|
|
||||||
return assetDataUtils.decodeERC20AssetData(assetData);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Encodes an ERC721 token address into a hex encoded assetData string, usable in the makerAssetData or
|
|
||||||
* takerAssetData fields in a 0x order.
|
|
||||||
* @param tokenAddress The ERC721 token address to encode
|
|
||||||
* @param tokenId The ERC721 tokenId to encode
|
|
||||||
* @return The hex encoded assetData string
|
|
||||||
*/
|
|
||||||
public static encodeERC721AssetData(tokenAddress: string, tokenId: BigNumber): string {
|
|
||||||
return assetDataUtils.encodeERC721AssetData(tokenAddress, tokenId);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Decodes an ERC721 assetData hex string into it's corresponding ERC721 tokenAddress, tokenId & assetProxyId
|
|
||||||
* @param assetData Hex encoded assetData string to decode
|
|
||||||
* @return An object containing the decoded tokenAddress, tokenId & assetProxyId
|
|
||||||
*/
|
|
||||||
public static decodeERC721AssetData(assetData: string): ERC721AssetData {
|
|
||||||
return assetDataUtils.decodeERC721AssetData(assetData);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Decode and return the assetProxyId from the assetData
|
|
||||||
* @param assetData Hex encoded assetData string to decode
|
|
||||||
* @return The assetProxyId
|
|
||||||
*/
|
|
||||||
public static decodeAssetProxyId(assetData: string): AssetProxyId {
|
|
||||||
return assetDataUtils.decodeAssetProxyId(assetData);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Decode any assetData into it's corresponding assetData object
|
|
||||||
* @param assetData Hex encoded assetData string to decode
|
|
||||||
* @return Either a ERC20 or ERC721 assetData object
|
|
||||||
*/
|
|
||||||
public static decodeAssetDataOrThrow(assetData: string): ERC20AssetData | ERC721AssetData {
|
|
||||||
return assetDataUtils.decodeAssetDataOrThrow(assetData);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Instantiates a new ZeroEx instance that provides the public interface to the 0x.js library.
|
|
||||||
* @param provider The Provider instance you would like the 0x.js library to use for interacting with
|
|
||||||
* the Ethereum network.
|
|
||||||
* @param config The configuration object. Look up the type for the description.
|
|
||||||
* @return An instance of the 0x.js ZeroEx class.
|
|
||||||
*/
|
|
||||||
constructor(provider: Provider, config: ContractWrappersConfig) {
|
|
||||||
assert.isWeb3Provider('provider', provider);
|
|
||||||
this._contractWrappers = new ContractWrappers(provider, config);
|
|
||||||
|
|
||||||
this.erc20Proxy = this._contractWrappers.erc20Proxy;
|
|
||||||
this.erc721Proxy = this._contractWrappers.erc721Proxy;
|
|
||||||
this.erc20Token = this._contractWrappers.erc20Token;
|
|
||||||
this.erc721Token = this._contractWrappers.erc721Token;
|
|
||||||
this.exchange = this._contractWrappers.exchange;
|
|
||||||
this.etherToken = this._contractWrappers.etherToken;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Verifies that the provided signature is valid according to the 0x Protocol smart contracts
|
|
||||||
* @param data The hex encoded data signed by the supplied signature.
|
|
||||||
* @param signature The hex encoded signature.
|
|
||||||
* @param signerAddress The hex encoded address that signed the data, producing the supplied signature.
|
|
||||||
* @return Whether the signature is valid for the supplied signerAddress and data.
|
|
||||||
*/
|
|
||||||
public async isValidSignatureAsync(data: string, signature: string, signerAddress: string): Promise<boolean> {
|
|
||||||
const isValid = await isValidSignatureAsync(
|
|
||||||
this._contractWrappers.getProvider(),
|
|
||||||
data,
|
|
||||||
signature,
|
|
||||||
signerAddress,
|
|
||||||
);
|
|
||||||
return isValid;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Sets a new web3 provider for 0x.js. Updating the provider will stop all
|
|
||||||
* subscriptions so you will need to re-subscribe to all events relevant to your app after this call.
|
|
||||||
* @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._contractWrappers.setProvider(provider, networkId);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get the provider instance currently used by 0x.js
|
|
||||||
* @return Web3 provider instance
|
|
||||||
*/
|
|
||||||
public getProvider(): Provider {
|
|
||||||
return this._contractWrappers.getProvider();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get user Ethereum addresses available through the supplied web3 provider available for sending transactions.
|
|
||||||
* @return An array of available user Ethereum addresses.
|
|
||||||
*/
|
|
||||||
public async getAvailableAddressesAsync(): Promise<string[]> {
|
|
||||||
// Hack: Get Web3Wrapper from ContractWrappers
|
|
||||||
const web3Wrapper: Web3Wrapper = (this._contractWrappers as any)._web3Wrapper;
|
|
||||||
const availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
|
||||||
return availableAddresses;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Signs an orderHash and returns it's elliptic curve signature.
|
|
||||||
* This method currently supports TestRPC, Geth and Parity above and below V1.6.6
|
|
||||||
* @param orderHash Hex encoded orderHash to sign.
|
|
||||||
* @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address
|
|
||||||
* must be available via the Provider supplied to 0x.js.
|
|
||||||
* @param signerType the signer type that will perform the `eth_sign` operation. E.g Default, Metamask, Ledger or Trezor.
|
|
||||||
* Some implementations exhibit different behaviour. Default will assume a spec compliant eth_sign implementation.
|
|
||||||
* This parameter is defaulted to `SignerType.Default`.
|
|
||||||
* @return A hex encoded string of the Elliptic curve signature parameters generated by signing the orderHash and signature type.
|
|
||||||
*/
|
|
||||||
public async ecSignOrderHashAsync(
|
|
||||||
orderHash: string,
|
|
||||||
signerAddress: string,
|
|
||||||
signerType: SignerType = SignerType.Default,
|
|
||||||
): Promise<string> {
|
|
||||||
const signature = await ecSignOrderHashAsync(
|
|
||||||
this._contractWrappers.getProvider(),
|
|
||||||
orderHash,
|
|
||||||
signerAddress,
|
|
||||||
signerType,
|
|
||||||
);
|
|
||||||
return signature;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Waits for a transaction to be mined and returns the transaction receipt.
|
|
||||||
* @param txHash Transaction hash
|
|
||||||
* @param pollingIntervalMs How often (in ms) should we check if the transaction is mined.
|
|
||||||
* @param timeoutMs How long (in ms) to poll for transaction mined until aborting.
|
|
||||||
* @return Transaction receipt with decoded log args.
|
|
||||||
*/
|
|
||||||
public async awaitTransactionMinedAsync(
|
|
||||||
txHash: string,
|
|
||||||
pollingIntervalMs: number = 1000,
|
|
||||||
timeoutMs?: number,
|
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
|
||||||
// Hack: Get Web3Wrapper from ContractWrappers
|
|
||||||
const web3Wrapper: Web3Wrapper = (this._contractWrappers as any)._web3Wrapper;
|
|
||||||
const transactionReceiptWithDecodedLogs = await web3Wrapper.awaitTransactionMinedAsync(
|
|
||||||
txHash,
|
|
||||||
pollingIntervalMs,
|
|
||||||
timeoutMs,
|
|
||||||
);
|
|
||||||
return transactionReceiptWithDecodedLogs;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,7 +0,0 @@
|
|||||||
import { ContractArtifact } from '@0xproject/sol-compiler';
|
|
||||||
|
|
||||||
import * as ZRXToken from './artifacts/ZRXToken.json';
|
|
||||||
|
|
||||||
export const artifacts = {
|
|
||||||
ZRXToken: (ZRXToken as any) as ContractArtifact,
|
|
||||||
};
|
|
File diff suppressed because one or more lines are too long
@@ -1,47 +1,22 @@
|
|||||||
export { ZeroEx } from './0x';
|
export { assetDataUtils, signatureUtils, generatePseudoRandomSalt, orderHashUtils } from '@0xproject/order-utils';
|
||||||
|
|
||||||
export { Web3ProviderEngine, RPCSubprovider } from '@0xproject/subproviders';
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ExchangeContractErrs,
|
ContractWrappers,
|
||||||
Order,
|
ERC20TokenWrapper,
|
||||||
SignedOrder,
|
ERC721TokenWrapper,
|
||||||
SignerType,
|
EtherTokenWrapper,
|
||||||
ECSignature,
|
ExchangeWrapper,
|
||||||
OrderStateValid,
|
ERC20ProxyWrapper,
|
||||||
OrderStateInvalid,
|
ERC721ProxyWrapper,
|
||||||
OrderState,
|
ForwarderWrapper,
|
||||||
Token,
|
|
||||||
ERC20AssetData,
|
|
||||||
ERC721AssetData,
|
|
||||||
AssetProxyId,
|
|
||||||
} from '@0xproject/types';
|
|
||||||
|
|
||||||
export {
|
|
||||||
BlockParamLiteral,
|
|
||||||
FilterObject,
|
|
||||||
BlockParam,
|
|
||||||
LogWithDecodedArgs,
|
|
||||||
ContractEventArg,
|
|
||||||
Provider,
|
|
||||||
TransactionReceipt,
|
|
||||||
TransactionReceiptWithDecodedLogs,
|
|
||||||
} from 'ethereum-types';
|
|
||||||
|
|
||||||
export {
|
|
||||||
EventCallback,
|
|
||||||
ContractEvent,
|
|
||||||
IndexedFilterValues,
|
IndexedFilterValues,
|
||||||
BlockRange,
|
BlockRange,
|
||||||
OrderFillRequest,
|
ContractWrappersConfig,
|
||||||
ContractEventArgs,
|
|
||||||
MethodOpts,
|
MethodOpts,
|
||||||
OrderTransactionOpts,
|
OrderTransactionOpts,
|
||||||
TransactionOpts,
|
TransactionOpts,
|
||||||
LogEvent,
|
OrderStatus,
|
||||||
DecodedLogEvent,
|
OrderInfo,
|
||||||
OnOrderStateChangeCallback,
|
|
||||||
ContractWrappersError,
|
|
||||||
WETH9Events,
|
WETH9Events,
|
||||||
WETH9WithdrawalEventArgs,
|
WETH9WithdrawalEventArgs,
|
||||||
WETH9ApprovalEventArgs,
|
WETH9ApprovalEventArgs,
|
||||||
@@ -56,11 +31,69 @@ export {
|
|||||||
ERC721TokenApprovalForAllEventArgs,
|
ERC721TokenApprovalForAllEventArgs,
|
||||||
ERC721TokenTransferEventArgs,
|
ERC721TokenTransferEventArgs,
|
||||||
ERC721TokenEvents,
|
ERC721TokenEvents,
|
||||||
|
ERC721TokenEventArgs,
|
||||||
ExchangeCancelUpToEventArgs,
|
ExchangeCancelUpToEventArgs,
|
||||||
ExchangeAssetProxyRegisteredEventArgs,
|
ExchangeAssetProxyRegisteredEventArgs,
|
||||||
|
ExchangeSignatureValidatorApprovalEventArgs,
|
||||||
ExchangeFillEventArgs,
|
ExchangeFillEventArgs,
|
||||||
ExchangeCancelEventArgs,
|
ExchangeCancelEventArgs,
|
||||||
|
ExchangeEvents,
|
||||||
|
EventCallback,
|
||||||
|
DecodedLogEvent,
|
||||||
ExchangeEventArgs,
|
ExchangeEventArgs,
|
||||||
ContractWrappersConfig,
|
TransactionEncoder,
|
||||||
OrderInfo,
|
|
||||||
} from '@0xproject/contract-wrappers';
|
} from '@0xproject/contract-wrappers';
|
||||||
|
|
||||||
|
export { OrderWatcher, OnOrderStateChangeCallback, OrderWatcherConfig } from '@0xproject/order-watcher';
|
||||||
|
|
||||||
|
export import Web3ProviderEngine = require('web3-provider-engine');
|
||||||
|
|
||||||
|
export { RPCSubprovider, Callback, JSONRPCRequestPayloadWithMethod, ErrorCallback } from '@0xproject/subproviders';
|
||||||
|
|
||||||
|
export { AbiDecoder } from '@0xproject/utils';
|
||||||
|
|
||||||
|
export { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
|
export {
|
||||||
|
ExchangeContractErrs,
|
||||||
|
Order,
|
||||||
|
SignedOrder,
|
||||||
|
ECSignature,
|
||||||
|
OrderStateValid,
|
||||||
|
OrderStateInvalid,
|
||||||
|
OrderState,
|
||||||
|
AssetProxyId,
|
||||||
|
SignerType,
|
||||||
|
ERC20AssetData,
|
||||||
|
ERC721AssetData,
|
||||||
|
SignatureType,
|
||||||
|
OrderRelevantState,
|
||||||
|
} from '@0xproject/types';
|
||||||
|
|
||||||
|
export {
|
||||||
|
BlockParamLiteral,
|
||||||
|
ContractAbi,
|
||||||
|
BlockParam,
|
||||||
|
LogWithDecodedArgs,
|
||||||
|
ContractEventArg,
|
||||||
|
Provider,
|
||||||
|
JSONRPCRequestPayload,
|
||||||
|
JSONRPCResponsePayload,
|
||||||
|
JSONRPCErrorCallback,
|
||||||
|
LogEntry,
|
||||||
|
DecodedLogArgs,
|
||||||
|
LogEntryEvent,
|
||||||
|
DecodedLogEntry,
|
||||||
|
DecodedLogEntryEvent,
|
||||||
|
RawLog,
|
||||||
|
AbiDefinition,
|
||||||
|
FunctionAbi,
|
||||||
|
EventAbi,
|
||||||
|
EventParameter,
|
||||||
|
MethodAbi,
|
||||||
|
ConstructorAbi,
|
||||||
|
FallbackAbi,
|
||||||
|
DataItem,
|
||||||
|
ConstructorStateMutability,
|
||||||
|
StateMutability,
|
||||||
|
} from 'ethereum-types';
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
import { postpublishUtils } from '@0xproject/monorepo-scripts';
|
|
||||||
|
|
||||||
import * as packageJSON from '../package.json';
|
|
||||||
import * as tsConfigJSON from '../tsconfig.json';
|
|
||||||
|
|
||||||
const cwd = `${__dirname}/..`;
|
|
||||||
// tslint:disable-next-line:no-floating-promises
|
|
||||||
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);
|
|
@@ -1,8 +0,0 @@
|
|||||||
import { postpublishUtils } from '@0xproject/monorepo-scripts';
|
|
||||||
|
|
||||||
import * as packageJSON from '../package.json';
|
|
||||||
import * as tsConfigJSON from '../tsconfig.json';
|
|
||||||
|
|
||||||
const cwd = `${__dirname}/..`;
|
|
||||||
// tslint:disable-next-line:no-floating-promises
|
|
||||||
postpublishUtils.publishDocsToStagingAsync(packageJSON, tsConfigJSON, cwd);
|
|
@@ -1,5 +0,0 @@
|
|||||||
export const zeroExConfigSchema = {
|
|
||||||
id: '/ZeroExConfig',
|
|
||||||
oneOf: [{ $ref: '/ZeroExPrivateNetworkConfig' }, { $ref: '/ZeroExPublicNetworkConfig' }],
|
|
||||||
type: 'object',
|
|
||||||
};
|
|
@@ -1,35 +0,0 @@
|
|||||||
export const zeroExPrivateNetworkConfigSchema = {
|
|
||||||
id: '/ZeroExPrivateNetworkConfig',
|
|
||||||
properties: {
|
|
||||||
networkId: {
|
|
||||||
type: 'number',
|
|
||||||
minimum: 1,
|
|
||||||
},
|
|
||||||
gasPrice: { $ref: '/Number' },
|
|
||||||
zrxContractAddress: { $ref: '/Address' },
|
|
||||||
exchangeContractAddress: { $ref: '/Address' },
|
|
||||||
erc20ProxyContractAddress: { $ref: '/Address' },
|
|
||||||
erc721ProxyContractAddress: { $ref: '/Address' },
|
|
||||||
orderWatcherConfig: {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
pollingIntervalMs: {
|
|
||||||
type: 'number',
|
|
||||||
minimum: 0,
|
|
||||||
},
|
|
||||||
numConfirmations: {
|
|
||||||
type: 'number',
|
|
||||||
minimum: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
type: 'object',
|
|
||||||
required: [
|
|
||||||
'networkId',
|
|
||||||
'zrxContractAddress',
|
|
||||||
'exchangeContractAddress',
|
|
||||||
'erc20ProxyContractAddress',
|
|
||||||
'erc721ProxyContractAddress',
|
|
||||||
],
|
|
||||||
};
|
|
@@ -1,43 +0,0 @@
|
|||||||
const networkNameToId: { [networkName: string]: number } = {
|
|
||||||
mainnet: 1,
|
|
||||||
ropsten: 3,
|
|
||||||
rinkeby: 4,
|
|
||||||
kovan: 42,
|
|
||||||
ganache: 50,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const zeroExPublicNetworkConfigSchema = {
|
|
||||||
id: '/ZeroExPublicNetworkConfig',
|
|
||||||
properties: {
|
|
||||||
networkId: {
|
|
||||||
type: 'number',
|
|
||||||
enum: [
|
|
||||||
networkNameToId.mainnet,
|
|
||||||
networkNameToId.ropsten,
|
|
||||||
networkNameToId.rinkeby,
|
|
||||||
networkNameToId.kovan,
|
|
||||||
networkNameToId.ganache,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
gasPrice: { $ref: '/Number' },
|
|
||||||
zrxContractAddress: { $ref: '/Address' },
|
|
||||||
exchangeContractAddress: { $ref: '/Address' },
|
|
||||||
erc20ProxyContractAddress: { $ref: '/Address' },
|
|
||||||
erc721ProxyContractAddress: { $ref: '/Address' },
|
|
||||||
orderWatcherConfig: {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
pollingIntervalMs: {
|
|
||||||
type: 'number',
|
|
||||||
minimum: 0,
|
|
||||||
},
|
|
||||||
numConfirmations: {
|
|
||||||
type: 'number',
|
|
||||||
minimum: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
type: 'object',
|
|
||||||
required: ['networkId'],
|
|
||||||
};
|
|
@@ -1,7 +0,0 @@
|
|||||||
export enum InternalZeroExError {
|
|
||||||
NoAbiDecoder = 'NO_ABI_DECODER',
|
|
||||||
ZrxNotInTokenRegistry = 'ZRX_NOT_IN_TOKEN_REGISTRY',
|
|
||||||
WethNotInTokenRegistry = 'WETH_NOT_IN_TOKEN_REGISTRY',
|
|
||||||
}
|
|
||||||
|
|
||||||
// tslint:disable:max-file-line-count
|
|
@@ -1,4 +0,0 @@
|
|||||||
export const constants = {
|
|
||||||
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
|
|
||||||
TESTRPC_NETWORK_ID: 50,
|
|
||||||
};
|
|
@@ -1,150 +0,0 @@
|
|||||||
import { ContractWrappers } from '@0xproject/contract-wrappers';
|
|
||||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
|
||||||
import { BigNumber } from '@0xproject/utils';
|
|
||||||
import * as chai from 'chai';
|
|
||||||
import 'mocha';
|
|
||||||
|
|
||||||
import { ERC20TokenApprovalEventArgs, ERC20TokenEvents, LogWithDecodedArgs, ZeroEx } from '../src';
|
|
||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
|
||||||
import { constants } from './utils/constants';
|
|
||||||
import { tokenUtils } from './utils/token_utils';
|
|
||||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
|
||||||
|
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
|
||||||
chaiSetup.configure();
|
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
describe('ZeroEx library', () => {
|
|
||||||
let zeroEx: ZeroEx;
|
|
||||||
before(async () => {
|
|
||||||
const config = {
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
};
|
|
||||||
zeroEx = new ZeroEx(provider, config);
|
|
||||||
});
|
|
||||||
describe('#setProvider', () => {
|
|
||||||
it('overrides provider in nested web3s and invalidates contractInstances', async () => {
|
|
||||||
// Instantiate the contract instances with the current provider
|
|
||||||
await (zeroEx.exchange as any)._getExchangeContractAsync();
|
|
||||||
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.not.be.undefined();
|
|
||||||
|
|
||||||
// Add property to newProvider so that we can differentiate it from old provider
|
|
||||||
(provider as any).zeroExTestId = 1;
|
|
||||||
zeroEx.setProvider(provider, constants.TESTRPC_NETWORK_ID);
|
|
||||||
|
|
||||||
// Check that contractInstances with old provider are removed after provider update
|
|
||||||
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.be.undefined();
|
|
||||||
|
|
||||||
// Check that all nested zeroExContract/web3Wrapper instances return the updated provider
|
|
||||||
const nestedWeb3WrapperProvider = ((zeroEx as any)._contractWrappers as ContractWrappers).getProvider();
|
|
||||||
expect((nestedWeb3WrapperProvider as any).zeroExTestId).to.be.a('number');
|
|
||||||
const exchangeWeb3WrapperProvider = (zeroEx.exchange as any)._web3Wrapper.getProvider();
|
|
||||||
expect(exchangeWeb3WrapperProvider.zeroExTestId).to.be.a('number');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('#isValidSignature', () => {
|
|
||||||
const dataHex = '0x6927e990021d23b1eb7b8789f6a6feaf98fe104bb0cf8259421b79f9a34222b0';
|
|
||||||
const ethSignSignature =
|
|
||||||
'0x1B61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3340349190569279751135161d22529dc25add4f6069af05be04cacbda2ace225403';
|
|
||||||
const address = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
|
|
||||||
const bytes32Zeros = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
||||||
it("should return false if the data doesn't pertain to the signature & address", async () => {
|
|
||||||
return expect(
|
|
||||||
(zeroEx.exchange as any).isValidSignatureAsync(bytes32Zeros, address, ethSignSignature),
|
|
||||||
).to.become(false);
|
|
||||||
});
|
|
||||||
it("should return false if the address doesn't pertain to the signature & data", async () => {
|
|
||||||
const validUnrelatedAddress = '0x8b0292b11a196601ed2ce54b665cafeca0347d42';
|
|
||||||
return expect(
|
|
||||||
(zeroEx.exchange as any).isValidSignatureAsync(dataHex, validUnrelatedAddress, ethSignSignature),
|
|
||||||
).to.become(false);
|
|
||||||
});
|
|
||||||
it("should return false if the signature doesn't pertain to the dataHex & address", async () => {
|
|
||||||
const signatureArray = ethSignSignature.split('');
|
|
||||||
// tslint:disable-next-line:custom-no-magic-numbers
|
|
||||||
signatureArray[5] = 'C'; // V = 28, instead of 27
|
|
||||||
const wrongSignature = signatureArray.join('');
|
|
||||||
return expect((zeroEx.exchange as any).isValidSignatureAsync(dataHex, address, wrongSignature)).to.become(
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('should return true if the signature does pertain to the dataHex & address', async () => {
|
|
||||||
return expect((zeroEx.exchange as any).isValidSignatureAsync(dataHex, address, ethSignSignature)).to.become(
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('#toUnitAmount', () => {
|
|
||||||
it('should throw if invalid baseUnit amount supplied as argument', () => {
|
|
||||||
const invalidBaseUnitAmount = new BigNumber(1000000000.4);
|
|
||||||
const decimals = 6;
|
|
||||||
expect(() => ZeroEx.toUnitAmount(invalidBaseUnitAmount, decimals)).to.throw(
|
|
||||||
'amount should be in baseUnits (no decimals), found value: 1000000000.4',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('Should return the expected unit amount for the decimals passed in', () => {
|
|
||||||
const baseUnitAmount = new BigNumber(1000000000);
|
|
||||||
const decimals = 6;
|
|
||||||
const unitAmount = ZeroEx.toUnitAmount(baseUnitAmount, decimals);
|
|
||||||
const expectedUnitAmount = new BigNumber(1000);
|
|
||||||
expect(unitAmount).to.be.bignumber.equal(expectedUnitAmount);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('#toBaseUnitAmount', () => {
|
|
||||||
it('Should return the expected base unit amount for the decimals passed in', () => {
|
|
||||||
const unitAmount = new BigNumber(1000);
|
|
||||||
const decimals = 6;
|
|
||||||
const baseUnitAmount = ZeroEx.toBaseUnitAmount(unitAmount, decimals);
|
|
||||||
const expectedUnitAmount = new BigNumber(1000000000);
|
|
||||||
expect(baseUnitAmount).to.be.bignumber.equal(expectedUnitAmount);
|
|
||||||
});
|
|
||||||
it('should throw if unitAmount has more decimals then specified as the max decimal precision', () => {
|
|
||||||
const unitAmount = new BigNumber(0.823091);
|
|
||||||
const decimals = 5;
|
|
||||||
expect(() => ZeroEx.toBaseUnitAmount(unitAmount, decimals)).to.throw(
|
|
||||||
'Invalid unit amount: 0.823091 - Too many decimal places',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('#awaitTransactionMinedAsync', () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
await blockchainLifecycle.startAsync();
|
|
||||||
});
|
|
||||||
afterEach(async () => {
|
|
||||||
await blockchainLifecycle.revertAsync();
|
|
||||||
});
|
|
||||||
it('returns transaction receipt with decoded logs', async () => {
|
|
||||||
const availableAddresses = await zeroEx.getAvailableAddressesAsync();
|
|
||||||
const coinbase = availableAddresses[0];
|
|
||||||
const zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
|
|
||||||
const erc20ProxyAddress = zeroEx.erc20Proxy.getContractAddress();
|
|
||||||
const txHash = await zeroEx.erc20Token.setUnlimitedProxyAllowanceAsync(zrxTokenAddress, coinbase);
|
|
||||||
const txReceiptWithDecodedLogs = await zeroEx.awaitTransactionMinedAsync(txHash);
|
|
||||||
// tslint:disable-next-line:no-unnecessary-type-assertion
|
|
||||||
const log = txReceiptWithDecodedLogs.logs[0] as LogWithDecodedArgs<ERC20TokenApprovalEventArgs>;
|
|
||||||
expect(log.event).to.be.equal(ERC20TokenEvents.Approval);
|
|
||||||
expect(log.args._owner).to.be.equal(coinbase);
|
|
||||||
expect(log.args._spender).to.be.equal(erc20ProxyAddress);
|
|
||||||
expect(log.args._value).to.be.bignumber.equal(zeroEx.erc20Token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('#config', () => {
|
|
||||||
it('allows to specify exchange contract address', async () => {
|
|
||||||
const zeroExConfig = {
|
|
||||||
exchangeContractAddress: ZeroEx.NULL_ADDRESS,
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
};
|
|
||||||
const zeroExWithWrongExchangeAddress = new ZeroEx(provider, zeroExConfig);
|
|
||||||
expect(zeroExWithWrongExchangeAddress.exchange.getContractAddress()).to.be.equal(ZeroEx.NULL_ADDRESS);
|
|
||||||
});
|
|
||||||
it('allows to specify erc20Proxy contract address', async () => {
|
|
||||||
const zeroExConfig = {
|
|
||||||
erc20ProxyContractAddress: ZeroEx.NULL_ADDRESS,
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
};
|
|
||||||
const zeroExWithWrongERC20ProxyAddress = new ZeroEx(provider, zeroExConfig);
|
|
||||||
expect(zeroExWithWrongERC20ProxyAddress.erc20Proxy.getContractAddress()).to.be.equal(ZeroEx.NULL_ADDRESS);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,17 +0,0 @@
|
|||||||
import { devConstants } from '@0xproject/dev-utils';
|
|
||||||
import { runV2MigrationsAsync } from '@0xproject/migrations';
|
|
||||||
|
|
||||||
import { provider } from './utils/web3_wrapper';
|
|
||||||
|
|
||||||
before('migrate contracts', async function(): Promise<void> {
|
|
||||||
// HACK: Since the migrations take longer then our global mocha timeout limit
|
|
||||||
// we manually increase it for this before hook.
|
|
||||||
const mochaTestTimeoutMs = 20000;
|
|
||||||
this.timeout(mochaTestTimeoutMs); // tslint:disable-line:no-invalid-this
|
|
||||||
const txDefaults = {
|
|
||||||
gas: devConstants.GAS_LIMIT,
|
|
||||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
|
||||||
};
|
|
||||||
const artifactsDir = `../migrations/artifacts/2.0.0`;
|
|
||||||
await runV2MigrationsAsync(provider, artifactsDir, txDefaults);
|
|
||||||
});
|
|
@@ -1,9 +0,0 @@
|
|||||||
export const constants = {
|
|
||||||
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
|
|
||||||
ROPSTEN_NETWORK_ID: 3,
|
|
||||||
KOVAN_NETWORK_ID: 42,
|
|
||||||
TESTRPC_NETWORK_ID: 50,
|
|
||||||
KOVAN_RPC_URL: 'https://kovan.infura.io/',
|
|
||||||
ROPSTEN_RPC_URL: 'https://ropsten.infura.io/',
|
|
||||||
ZRX_DECIMALS: 18,
|
|
||||||
};
|
|
@@ -1,9 +0,0 @@
|
|||||||
import { artifacts } from '../../src/artifacts';
|
|
||||||
|
|
||||||
import { constants } from './constants';
|
|
||||||
|
|
||||||
export const tokenUtils = {
|
|
||||||
getProtocolTokenAddress(): string {
|
|
||||||
return artifacts.ZRXToken.networks[constants.TESTRPC_NETWORK_ID].address;
|
|
||||||
},
|
|
||||||
};
|
|
@@ -1,12 +0,0 @@
|
|||||||
import { devConstants, web3Factory } from '@0xproject/dev-utils';
|
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|
||||||
import { Provider } from 'ethereum-types';
|
|
||||||
|
|
||||||
const txDefaults = {
|
|
||||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
|
||||||
gas: devConstants.GAS_LIMIT,
|
|
||||||
};
|
|
||||||
const provider: Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
|
||||||
const web3Wrapper = new Web3Wrapper(provider);
|
|
||||||
|
|
||||||
export { provider, web3Wrapper, txDefaults };
|
|
@@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const production = process.env.NODE_ENV === 'production';
|
const production = process.env.NODE_ENV === 'production';
|
||||||
|
|
||||||
@@ -27,10 +28,16 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.optimize.UglifyJsPlugin({
|
// TODO: Revert to webpack bundled version with webpack v4.
|
||||||
minimize: true,
|
// The v3 series bundled version does not support ES6 and
|
||||||
|
// fails to build.
|
||||||
|
new UglifyJsPlugin({
|
||||||
sourceMap: true,
|
sourceMap: true,
|
||||||
include: /\.min\.js$/,
|
uglifyOptions: {
|
||||||
|
mangle: {
|
||||||
|
reserved: ['BigNumber'],
|
||||||
|
},
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
module: {
|
module: {
|
||||||
|
@@ -1,4 +1,22 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"timestamp": 1535377027,
|
||||||
|
"version": "1.0.7",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1535133899,
|
||||||
|
"version": "1.0.6",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1534210131,
|
"timestamp": 1534210131,
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
|
@@ -5,7 +5,15 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
## v1.0.5 - _August 13, 2018_
|
## v1.0.7 - _August 27, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v1.0.6 - _August 24, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v1.0.5 - _August 14, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
@@ -25,7 +33,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* Fix the abi-gen entry point in package.json (#901)
|
* Fix the abi-gen entry point in package.json (#901)
|
||||||
|
|
||||||
## v1.0.0 - _July 19, 2018_
|
## v1.0.0 - _July 20, 2018_
|
||||||
|
|
||||||
* Convert e_r_c to erc in generated file names (#822)
|
* Convert e_r_c to erc in generated file names (#822)
|
||||||
* Remove the output directory before writing to it (#822)
|
* Remove the output directory before writing to it (#822)
|
||||||
@@ -43,7 +51,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
## v0.3.1 - _May 31, 2018_
|
## v0.3.1 - _June 1, 2018_
|
||||||
|
|
||||||
* Incorrect publish that was unpublished
|
* Incorrect publish that was unpublished
|
||||||
|
|
||||||
@@ -51,7 +59,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* Properly export the executable binary (#588)
|
* Properly export the executable binary (#588)
|
||||||
|
|
||||||
## v0.2.13 - _May 4, 2018_
|
## v0.2.13 - _May 5, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/abi-gen",
|
"name": "@0xproject/abi-gen",
|
||||||
"version": "1.0.4",
|
"version": "1.0.7",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -10,14 +10,13 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"watch_without_deps": "tsc -w",
|
"watch_without_deps": "tsc -w",
|
||||||
"lint": "tslint --project .",
|
"lint": "tslint --project .",
|
||||||
"clean": "shx rm -rf lib scripts",
|
"clean": "shx rm -rf lib",
|
||||||
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
"build": "tsc",
|
||||||
"test": "yarn run_mocha",
|
"test": "yarn run_mocha",
|
||||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --bail --exit",
|
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --bail --exit",
|
||||||
"test:circleci": "yarn test:coverage",
|
"test:circleci": "yarn test:coverage",
|
||||||
"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"
|
||||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"abi-gen": "bin/abi-gen.js"
|
"abi-gen": "bin/abi-gen.js"
|
||||||
@@ -32,10 +31,10 @@
|
|||||||
},
|
},
|
||||||
"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/typescript-typings": "^1.0.3",
|
"@0xproject/typescript-typings": "^1.0.5",
|
||||||
"@0xproject/utils": "^1.0.4",
|
"@0xproject/utils": "^1.0.7",
|
||||||
"chalk": "^2.3.0",
|
"chalk": "^2.3.0",
|
||||||
"ethereum-types": "^1.0.3",
|
"ethereum-types": "^1.0.5",
|
||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
"handlebars": "^4.0.11",
|
"handlebars": "^4.0.11",
|
||||||
"lodash": "^4.17.5",
|
"lodash": "^4.17.5",
|
||||||
@@ -46,8 +45,7 @@
|
|||||||
"yargs": "^10.0.3"
|
"yargs": "^10.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/monorepo-scripts": "^1.0.4",
|
"@0xproject/tslint-config": "^1.0.6",
|
||||||
"@0xproject/tslint-config": "^1.0.4",
|
|
||||||
"@types/glob": "5.0.35",
|
"@types/glob": "5.0.35",
|
||||||
"@types/handlebars": "^4.0.36",
|
"@types/handlebars": "^4.0.36",
|
||||||
"@types/mkdirp": "^0.5.1",
|
"@types/mkdirp": "^0.5.1",
|
||||||
@@ -56,14 +54,14 @@
|
|||||||
"@types/tmp": "^0.0.33",
|
"@types/tmp": "^0.0.33",
|
||||||
"@types/yargs": "^10.0.0",
|
"@types/yargs": "^10.0.0",
|
||||||
"chai": "^4.1.2",
|
"chai": "^4.1.2",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "^2.0.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
"mocha": "^5.2.0",
|
"mocha": "^5.2.0",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
"shx": "^0.2.2",
|
"shx": "^0.2.2",
|
||||||
"tslint": "5.11.0",
|
"tslint": "5.11.0",
|
||||||
"typescript": "2.9.2"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
import { postpublishUtils } from '@0xproject/monorepo-scripts';
|
|
||||||
|
|
||||||
import * as packageJSON from '../package.json';
|
|
||||||
import * as tsConfigJSON from '../tsconfig.json';
|
|
||||||
|
|
||||||
const cwd = `${__dirname}/..`;
|
|
||||||
// tslint:disable-next-line:no-floating-promises
|
|
||||||
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);
|
|
@@ -1,4 +1,22 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"timestamp": 1535377027,
|
||||||
|
"version": "1.0.7",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1535133899,
|
||||||
|
"version": "1.0.6",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1534210131,
|
"timestamp": 1534210131,
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
|
@@ -5,7 +5,15 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
## v1.0.5 - _August 13, 2018_
|
## v1.0.7 - _August 27, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v1.0.6 - _August 24, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v1.0.5 - _August 14, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
@@ -25,7 +33,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
## v1.0.0 - _July 19, 2018_
|
## v1.0.0 - _July 20, 2018_
|
||||||
|
|
||||||
* Fix bug in string enum assertion. We erroneously were checking against the enum keys, not values (#821)
|
* Fix bug in string enum assertion. We erroneously were checking against the enum keys, not values (#821)
|
||||||
|
|
||||||
@@ -41,7 +49,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
## v0.2.11 - _May 31, 2018_
|
## v0.2.11 - _June 1, 2018_
|
||||||
|
|
||||||
* Incorrect publish that was unpublished
|
* Incorrect publish that was unpublished
|
||||||
|
|
||||||
@@ -49,7 +57,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
## v0.2.9 - _May 4, 2018_
|
## v0.2.9 - _May 5, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/assert",
|
"name": "@0xproject/assert",
|
||||||
"version": "1.0.4",
|
"version": "1.0.7",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -9,16 +9,15 @@
|
|||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch_without_deps": "tsc -w",
|
"watch_without_deps": "tsc -w",
|
||||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
"build": "tsc",
|
||||||
"clean": "shx rm -rf lib test_temp scripts",
|
"clean": "shx rm -rf lib test_temp",
|
||||||
"lint": "tslint --project .",
|
"lint": "tslint --project .",
|
||||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
|
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
|
||||||
"test": "yarn run_mocha",
|
"test": "yarn run_mocha",
|
||||||
"rebuild_and_test": "run-s clean build test",
|
"rebuild_and_test": "run-s clean build test",
|
||||||
"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"
|
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -30,13 +29,12 @@
|
|||||||
},
|
},
|
||||||
"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": "^1.0.4",
|
"@0xproject/tslint-config": "^1.0.6",
|
||||||
"@0xproject/tslint-config": "^1.0.4",
|
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/mocha": "^2.2.42",
|
"@types/mocha": "^2.2.42",
|
||||||
"@types/valid-url": "^1.0.2",
|
"@types/valid-url": "^1.0.2",
|
||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "^2.0.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
"mocha": "^4.1.0",
|
"mocha": "^4.1.0",
|
||||||
@@ -44,12 +42,12 @@
|
|||||||
"nyc": "^11.0.1",
|
"nyc": "^11.0.1",
|
||||||
"shx": "^0.2.2",
|
"shx": "^0.2.2",
|
||||||
"tslint": "5.11.0",
|
"tslint": "5.11.0",
|
||||||
"typescript": "2.9.2"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/json-schemas": "^1.0.1-rc.3",
|
"@0xproject/json-schemas": "^1.0.1-rc.6",
|
||||||
"@0xproject/typescript-typings": "^1.0.3",
|
"@0xproject/typescript-typings": "^1.0.5",
|
||||||
"@0xproject/utils": "^1.0.4",
|
"@0xproject/utils": "^1.0.7",
|
||||||
"lodash": "^4.17.5",
|
"lodash": "^4.17.5",
|
||||||
"valid-url": "^1.0.9"
|
"valid-url": "^1.0.9"
|
||||||
},
|
},
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
import { postpublishUtils } from '@0xproject/monorepo-scripts';
|
|
||||||
|
|
||||||
import * as packageJSON from '../package.json';
|
|
||||||
import * as tsConfigJSON from '../tsconfig.json';
|
|
||||||
|
|
||||||
const cwd = `${__dirname}/..`;
|
|
||||||
// tslint:disable-next-line:no-floating-promises
|
|
||||||
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);
|
|
@@ -1,4 +1,22 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"timestamp": 1535377027,
|
||||||
|
"version": "2.0.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timestamp": 1535133899,
|
||||||
|
"version": "2.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "2.0.0-rc.1",
|
"version": "2.0.0-rc.1",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@@ -5,7 +5,15 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
## v2.0.0-rc.1 - _August 13, 2018_
|
## v2.0.1 - _August 27, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v2.0.0 - _August 24, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v2.0.0-rc.1 - _August 14, 2018_
|
||||||
|
|
||||||
* Added strict encoding/decoding checks for sendTransaction and call (#915)
|
* Added strict encoding/decoding checks for sendTransaction and call (#915)
|
||||||
|
|
||||||
@@ -25,7 +33,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
## v1.0.0 - _July 19, 2018_
|
## v1.0.0 - _July 20, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
@@ -41,7 +49,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* 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
|
* 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 - _May 31, 2018_
|
## v0.3.3 - _June 1, 2018_
|
||||||
|
|
||||||
* Incorrect publish that was unpublished
|
* Incorrect publish that was unpublished
|
||||||
|
|
||||||
@@ -49,7 +57,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
## v0.3.1 - _May 4, 2018_
|
## v0.3.1 - _May 5, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/base-contract",
|
"name": "@0xproject/base-contract",
|
||||||
"version": "1.0.4",
|
"version": "2.0.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -9,16 +9,15 @@
|
|||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch_without_deps": "tsc -w",
|
"watch_without_deps": "tsc -w",
|
||||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
"build": "tsc",
|
||||||
"clean": "shx rm -rf lib scripts",
|
"clean": "shx rm -rf lib",
|
||||||
"test": "yarn run_mocha",
|
"test": "yarn run_mocha",
|
||||||
"rebuild_and_test": "run-s clean build test",
|
"rebuild_and_test": "run-s clean build test",
|
||||||
"test:circleci": "yarn test:coverage",
|
"test:circleci": "yarn test:coverage",
|
||||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --bail --exit",
|
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --bail --exit",
|
||||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
"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",
|
||||||
"lint": "tslint --project . --exclude **/src/contract_wrappers/**/*",
|
"lint": "tslint --project . --exclude **/src/contract_wrappers/**/*"
|
||||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -30,23 +29,22 @@
|
|||||||
},
|
},
|
||||||
"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": "^1.0.4",
|
"@0xproject/tslint-config": "^1.0.6",
|
||||||
"@0xproject/tslint-config": "^1.0.4",
|
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "^2.0.0",
|
||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
"mocha": "^4.1.0",
|
"mocha": "^4.1.0",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
"shx": "^0.2.2",
|
"shx": "^0.2.2",
|
||||||
"tslint": "5.11.0",
|
"tslint": "5.11.0",
|
||||||
"typescript": "2.9.2"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/typescript-typings": "^1.0.3",
|
"@0xproject/typescript-typings": "^1.0.5",
|
||||||
"@0xproject/utils": "^1.0.4",
|
"@0xproject/utils": "^1.0.7",
|
||||||
"@0xproject/web3-wrapper": "^1.1.2",
|
"@0xproject/web3-wrapper": "^2.0.1",
|
||||||
"ethereum-types": "^1.0.3",
|
"ethereum-types": "^1.0.5",
|
||||||
"ethers": "3.0.22",
|
"ethers": "3.0.22",
|
||||||
"lodash": "^4.17.5"
|
"lodash": "^4.17.5"
|
||||||
},
|
},
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
import { postpublishUtils } from '@0xproject/monorepo-scripts';
|
|
||||||
|
|
||||||
import * as packageJSON from '../package.json';
|
|
||||||
import * as tsConfigJSON from '../tsconfig.json';
|
|
||||||
|
|
||||||
const cwd = `${__dirname}/..`;
|
|
||||||
// tslint:disable-next-line:no-floating-promises
|
|
||||||
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);
|
|
@@ -1,4 +1,27 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "2.0.0-rc.2",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Dependencies updated"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1535377027
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "2.0.0-rc.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Updated for SRA v2",
|
||||||
|
"pr": 974
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Stopped exporting `Order` type",
|
||||||
|
"pr": 924
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1535133899
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1534210131,
|
"timestamp": 1534210131,
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
|
@@ -5,7 +5,16 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
## v1.0.5 - _August 13, 2018_
|
## v2.0.0-rc.2 - _August 27, 2018_
|
||||||
|
|
||||||
|
* Dependencies updated
|
||||||
|
|
||||||
|
## v2.0.0-rc.1 - _August 24, 2018_
|
||||||
|
|
||||||
|
* Updated for SRA v2 (#974)
|
||||||
|
* Stopped exporting `Order` type (#924)
|
||||||
|
|
||||||
|
## v1.0.5 - _August 14, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
@@ -25,7 +34,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
## v1.0.0 - _July 19, 2018_
|
## v1.0.0 - _July 20, 2018_
|
||||||
|
|
||||||
* Remove `WebSocketOrderbookChannel` from the public interface and replace with `orderbookChannelFactory`
|
* Remove `WebSocketOrderbookChannel` from the public interface and replace with `orderbookChannelFactory`
|
||||||
|
|
||||||
@@ -49,7 +58,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
## v0.6.12 - _May 4, 2018_
|
## v0.6.12 - _May 5, 2018_
|
||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/connect",
|
"name": "@0xproject/connect",
|
||||||
"version": "1.0.4",
|
"version": "2.0.0-rc.2",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
@@ -16,8 +16,8 @@
|
|||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch_without_deps": "tsc -w",
|
"watch_without_deps": "tsc -w",
|
||||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
"build": "tsc",
|
||||||
"clean": "shx rm -rf lib test_temp scripts",
|
"clean": "shx rm -rf lib test_temp generated_docs",
|
||||||
"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 .",
|
"lint": "tslint --project .",
|
||||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
|
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
|
||||||
@@ -26,18 +26,11 @@
|
|||||||
"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",
|
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES"
|
||||||
"docs:stage": "node scripts/stage_docs.js",
|
|
||||||
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
|
|
||||||
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
|
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"postpublish": {
|
"postpublish": {
|
||||||
"assets": [],
|
"assets": []
|
||||||
"docPublishConfigs": {
|
|
||||||
"s3BucketPath": "s3://doc-jsons/connect/",
|
|
||||||
"s3StagingBucketPath": "s3://staging-doc-jsons/connect/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -51,29 +44,30 @@
|
|||||||
},
|
},
|
||||||
"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.14",
|
"@0xproject/assert": "^1.0.7",
|
||||||
"@0xproject/json-schemas": "^0.8.3",
|
"@0xproject/json-schemas": "^1.0.1-rc.6",
|
||||||
"@0xproject/types": "^0.8.2",
|
"@0xproject/types": "^1.0.1-rc.6",
|
||||||
"@0xproject/typescript-typings": "^1.0.3",
|
"@0xproject/typescript-typings": "^1.0.5",
|
||||||
"@0xproject/utils": "^1.0.4",
|
"@0xproject/utils": "^1.0.7",
|
||||||
"lodash": "^4.17.5",
|
"lodash": "^4.17.5",
|
||||||
"query-string": "^5.0.1",
|
"query-string": "^5.0.1",
|
||||||
"sinon": "^4.0.0",
|
"sinon": "^4.0.0",
|
||||||
|
"uuid": "^3.3.2",
|
||||||
"websocket": "^1.0.25"
|
"websocket": "^1.0.25"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/monorepo-scripts": "^1.0.4",
|
"@0xproject/tslint-config": "^1.0.6",
|
||||||
"@0xproject/tslint-config": "^1.0.4",
|
"@types/fetch-mock": "^6.0.3",
|
||||||
"@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.42",
|
||||||
"@types/query-string": "^5.0.1",
|
"@types/query-string": "^5.0.1",
|
||||||
"@types/sinon": "^2.2.2",
|
"@types/sinon": "^2.2.2",
|
||||||
|
"@types/uuid": "^3.4.3",
|
||||||
"@types/websocket": "^0.0.39",
|
"@types/websocket": "^0.0.39",
|
||||||
"async-child-process": "^1.1.1",
|
"async-child-process": "^1.1.1",
|
||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"chai-as-promised": "^7.1.0",
|
"chai-as-promised": "^7.1.0",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "^2.0.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"fetch-mock": "^5.13.1",
|
"fetch-mock": "^5.13.1",
|
||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
@@ -82,8 +76,8 @@
|
|||||||
"nyc": "^11.0.1",
|
"nyc": "^11.0.1",
|
||||||
"shx": "^0.2.2",
|
"shx": "^0.2.2",
|
||||||
"tslint": "5.11.0",
|
"tslint": "5.11.0",
|
||||||
"typedoc": "~0.8.0",
|
"typedoc": "0.12.0",
|
||||||
"typescript": "2.9.2"
|
"typescript": "3.0.1"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
@@ -7,31 +7,25 @@ import * as queryString from 'query-string';
|
|||||||
|
|
||||||
import { schemas as clientSchemas } from './schemas/schemas';
|
import { schemas as clientSchemas } from './schemas/schemas';
|
||||||
import {
|
import {
|
||||||
|
APIOrder,
|
||||||
|
AssetPairsRequestOpts,
|
||||||
|
AssetPairsResponse,
|
||||||
Client,
|
Client,
|
||||||
FeesRequest,
|
FeeRecipientsResponse,
|
||||||
FeesResponse,
|
|
||||||
HttpRequestOptions,
|
HttpRequestOptions,
|
||||||
HttpRequestType,
|
HttpRequestType,
|
||||||
OrderbookRequest,
|
OrderbookRequest,
|
||||||
OrderbookResponse,
|
OrderbookResponse,
|
||||||
|
OrderConfigRequest,
|
||||||
|
OrderConfigResponse,
|
||||||
OrdersRequestOpts,
|
OrdersRequestOpts,
|
||||||
|
OrdersResponse,
|
||||||
PagedRequestOpts,
|
PagedRequestOpts,
|
||||||
TokenPairsItem,
|
RequestOpts,
|
||||||
TokenPairsRequestOpts,
|
|
||||||
} from './types';
|
} from './types';
|
||||||
import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers';
|
import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers';
|
||||||
|
|
||||||
const TRAILING_SLASHES_REGEX = /\/+$/;
|
const TRAILING_SLASHES_REGEX = /\/+$/;
|
||||||
const DEFAULT_PAGED_REQUEST_OPTS: PagedRequestOpts = {
|
|
||||||
page: 1,
|
|
||||||
perPage: 100,
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* This mapping defines how an option property name gets converted into an HTTP request query field
|
|
||||||
*/
|
|
||||||
const OPTS_TO_QUERY_FIELD_MAP = {
|
|
||||||
perPage: 'per_page',
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class includes all the functionality related to interacting with a set of HTTP endpoints
|
* This class includes all the functionality related to interacting with a set of HTTP endpoints
|
||||||
@@ -47,12 +41,8 @@ export class HttpClient implements Client {
|
|||||||
if (_.isUndefined(params) || _.isEmpty(params)) {
|
if (_.isUndefined(params) || _.isEmpty(params)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
// format params into a form the api expects
|
|
||||||
const formattedParams = _.mapKeys(params, (_value: any, key: string) => {
|
|
||||||
return _.get(OPTS_TO_QUERY_FIELD_MAP, key, key);
|
|
||||||
});
|
|
||||||
// stringify the formatted object
|
// stringify the formatted object
|
||||||
const stringifiedParams = queryString.stringify(formattedParams);
|
const stringifiedParams = queryString.stringify(params);
|
||||||
return `?${stringifiedParams}`;
|
return `?${stringifiedParams}`;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -65,34 +55,40 @@ export class HttpClient implements Client {
|
|||||||
this._apiEndpointUrl = url.replace(TRAILING_SLASHES_REGEX, ''); // remove trailing slashes
|
this._apiEndpointUrl = url.replace(TRAILING_SLASHES_REGEX, ''); // remove trailing slashes
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve token pair info from the API
|
* Retrieve assetData pair info from the API
|
||||||
* @param requestOpts Options specifying token information to retrieve and page information, defaults to { page: 1, perPage: 100 }
|
* @param requestOpts Options specifying assetData information to retrieve, page information, and network id.
|
||||||
* @return The resulting TokenPairsItems that match the request
|
* @return The resulting AssetPairsResponse that match the request
|
||||||
*/
|
*/
|
||||||
public async getTokenPairsAsync(requestOpts?: TokenPairsRequestOpts & PagedRequestOpts): Promise<TokenPairsItem[]> {
|
public async getAssetPairsAsync(
|
||||||
|
requestOpts?: RequestOpts & AssetPairsRequestOpts & PagedRequestOpts,
|
||||||
|
): Promise<AssetPairsResponse> {
|
||||||
if (!_.isUndefined(requestOpts)) {
|
if (!_.isUndefined(requestOpts)) {
|
||||||
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.tokenPairsRequestOptsSchema);
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.assetPairsRequestOptsSchema);
|
||||||
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
|
||||||
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
|
||||||
}
|
}
|
||||||
const httpRequestOpts = {
|
const httpRequestOpts = {
|
||||||
params: _.defaults({}, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
|
params: requestOpts,
|
||||||
};
|
};
|
||||||
const responseJson = await this._requestAsync('/token_pairs', HttpRequestType.Get, httpRequestOpts);
|
const responseJson = await this._requestAsync('/asset_pairs', HttpRequestType.Get, httpRequestOpts);
|
||||||
const tokenPairs = relayerResponseJsonParsers.parseTokenPairsJson(responseJson);
|
const assetDataPairs = relayerResponseJsonParsers.parseAssetDataPairsJson(responseJson);
|
||||||
return tokenPairs;
|
return assetDataPairs;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve orders from the API
|
* Retrieve orders from the API
|
||||||
* @param requestOpts Options specifying orders to retrieve and page information, defaults to { page: 1, perPage: 100 }
|
* @param requestOpts Options specifying orders to retrieve and page information, page information, and network id.
|
||||||
* @return The resulting SignedOrders that match the request
|
* @return The resulting OrdersResponse that match the request
|
||||||
*/
|
*/
|
||||||
public async getOrdersAsync(requestOpts?: OrdersRequestOpts & PagedRequestOpts): Promise<SignedOrder[]> {
|
public async getOrdersAsync(
|
||||||
|
requestOpts?: RequestOpts & OrdersRequestOpts & PagedRequestOpts,
|
||||||
|
): Promise<OrdersResponse> {
|
||||||
if (!_.isUndefined(requestOpts)) {
|
if (!_.isUndefined(requestOpts)) {
|
||||||
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.ordersRequestOptsSchema);
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.ordersRequestOptsSchema);
|
||||||
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
|
||||||
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
|
||||||
}
|
}
|
||||||
const httpRequestOpts = {
|
const httpRequestOpts = {
|
||||||
params: _.defaults({}, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
|
params: requestOpts,
|
||||||
};
|
};
|
||||||
const responseJson = await this._requestAsync(`/orders`, HttpRequestType.Get, httpRequestOpts);
|
const responseJson = await this._requestAsync(`/orders`, HttpRequestType.Get, httpRequestOpts);
|
||||||
const orders = relayerResponseJsonParsers.parseOrdersJson(responseJson);
|
const orders = relayerResponseJsonParsers.parseOrdersJson(responseJson);
|
||||||
@@ -101,30 +97,37 @@ export class HttpClient implements Client {
|
|||||||
/**
|
/**
|
||||||
* Retrieve a specific order from the API
|
* Retrieve a specific order from the API
|
||||||
* @param orderHash An orderHash generated from the desired order
|
* @param orderHash An orderHash generated from the desired order
|
||||||
* @return The SignedOrder that matches the supplied orderHash
|
* @return The APIOrder that matches the supplied orderHash
|
||||||
*/
|
*/
|
||||||
public async getOrderAsync(orderHash: string): Promise<SignedOrder> {
|
public async getOrderAsync(orderHash: string, requestOpts?: RequestOpts): Promise<APIOrder> {
|
||||||
|
if (!_.isUndefined(requestOpts)) {
|
||||||
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
|
||||||
|
}
|
||||||
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
|
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
|
||||||
const responseJson = await this._requestAsync(`/order/${orderHash}`, HttpRequestType.Get);
|
const httpRequestOpts = {
|
||||||
const order = relayerResponseJsonParsers.parseOrderJson(responseJson);
|
params: requestOpts,
|
||||||
|
};
|
||||||
|
const responseJson = await this._requestAsync(`/order/${orderHash}`, HttpRequestType.Get, httpRequestOpts);
|
||||||
|
const order = relayerResponseJsonParsers.parseAPIOrderJson(responseJson);
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve an orderbook from the API
|
* Retrieve an orderbook from the API
|
||||||
* @param request An OrderbookRequest instance describing the specific orderbook to retrieve
|
* @param request An OrderbookRequest instance describing the specific orderbook to retrieve
|
||||||
* @param requestOpts Options specifying page information, defaults to { page: 1, perPage: 100 }
|
* @param requestOpts Options specifying page information, and network id.
|
||||||
* @return The resulting OrderbookResponse that matches the request
|
* @return The resulting OrderbookResponse that matches the request
|
||||||
*/
|
*/
|
||||||
public async getOrderbookAsync(
|
public async getOrderbookAsync(
|
||||||
request: OrderbookRequest,
|
request: OrderbookRequest,
|
||||||
requestOpts?: PagedRequestOpts,
|
requestOpts?: RequestOpts & PagedRequestOpts,
|
||||||
): Promise<OrderbookResponse> {
|
): Promise<OrderbookResponse> {
|
||||||
assert.doesConformToSchema('request', request, clientSchemas.orderBookRequestSchema);
|
assert.doesConformToSchema('request', request, clientSchemas.orderBookRequestSchema);
|
||||||
if (!_.isUndefined(requestOpts)) {
|
if (!_.isUndefined(requestOpts)) {
|
||||||
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
|
||||||
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
|
||||||
}
|
}
|
||||||
const httpRequestOpts = {
|
const httpRequestOpts = {
|
||||||
params: _.defaults({}, request, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
|
params: _.defaults({}, request, requestOpts),
|
||||||
};
|
};
|
||||||
const responseJson = await this._requestAsync('/orderbook', HttpRequestType.Get, httpRequestOpts);
|
const responseJson = await this._requestAsync('/orderbook', HttpRequestType.Get, httpRequestOpts);
|
||||||
const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(responseJson);
|
const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(responseJson);
|
||||||
@@ -132,28 +135,55 @@ export class HttpClient implements Client {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve fee information from the API
|
* Retrieve fee information from the API
|
||||||
* @param request A FeesRequest instance describing the specific fees to retrieve
|
* @param request A OrderConfigRequest instance describing the specific fees to retrieve
|
||||||
* @return The resulting FeesResponse that matches the request
|
* @param requestOpts Options specifying network id.
|
||||||
|
* @return The resulting OrderConfigResponse that matches the request
|
||||||
*/
|
*/
|
||||||
public async getFeesAsync(request: FeesRequest): Promise<FeesResponse> {
|
public async getOrderConfigAsync(
|
||||||
assert.doesConformToSchema('request', request, clientSchemas.feesRequestSchema);
|
request: OrderConfigRequest,
|
||||||
|
requestOpts?: RequestOpts,
|
||||||
|
): Promise<OrderConfigResponse> {
|
||||||
|
if (!_.isUndefined(requestOpts)) {
|
||||||
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
|
||||||
|
}
|
||||||
|
assert.doesConformToSchema('request', request, clientSchemas.orderConfigRequestSchema);
|
||||||
const httpRequestOpts = {
|
const httpRequestOpts = {
|
||||||
|
params: requestOpts,
|
||||||
payload: request,
|
payload: request,
|
||||||
};
|
};
|
||||||
const responseJson = await this._requestAsync('/fees', HttpRequestType.Post, httpRequestOpts);
|
const responseJson = await this._requestAsync('/order_config', HttpRequestType.Post, httpRequestOpts);
|
||||||
const fees = relayerResponseJsonParsers.parseFeesResponseJson(responseJson);
|
const fees = relayerResponseJsonParsers.parseOrderConfigResponseJson(responseJson);
|
||||||
return fees;
|
return fees;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Retrieve the list of fee recipient addresses used by the relayer.
|
||||||
|
* @param requestOpts Options specifying page information, and network id.
|
||||||
|
* @return The resulting FeeRecipientsResponse
|
||||||
|
*/
|
||||||
|
public async getFeeRecipientsAsync(requestOpts?: RequestOpts & PagedRequestOpts): Promise<FeeRecipientsResponse> {
|
||||||
|
if (!_.isUndefined(requestOpts)) {
|
||||||
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
|
||||||
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
|
||||||
|
}
|
||||||
|
const httpRequestOpts = {
|
||||||
|
params: requestOpts,
|
||||||
|
};
|
||||||
|
const feeRecipients = await this._requestAsync('/fee_recipients', HttpRequestType.Get, httpRequestOpts);
|
||||||
|
assert.doesConformToSchema('feeRecipients', feeRecipients, schemas.relayerApiFeeRecipientsResponseSchema);
|
||||||
|
return feeRecipients;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Submit a signed order to the API
|
* Submit a signed order to the API
|
||||||
* @param signedOrder A SignedOrder instance to submit
|
* @param signedOrder A SignedOrder instance to submit
|
||||||
|
* @param requestOpts Options specifying network id.
|
||||||
*/
|
*/
|
||||||
public async submitOrderAsync(signedOrder: SignedOrder): Promise<void> {
|
public async submitOrderAsync(signedOrder: SignedOrder, requestOpts?: RequestOpts): Promise<void> {
|
||||||
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
|
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
|
||||||
const requestOpts = {
|
const httpRequestOpts = {
|
||||||
|
params: requestOpts,
|
||||||
payload: signedOrder,
|
payload: signedOrder,
|
||||||
};
|
};
|
||||||
await this._requestAsync('/order', HttpRequestType.Post, requestOpts);
|
await this._requestAsync('/order', HttpRequestType.Post, httpRequestOpts);
|
||||||
}
|
}
|
||||||
private async _requestAsync(
|
private async _requestAsync(
|
||||||
path: string,
|
path: string,
|
||||||
|
@@ -1,19 +1,23 @@
|
|||||||
export { HttpClient } from './http_client';
|
export { HttpClient } from './http_client';
|
||||||
export { orderbookChannelFactory } from './orderbook_channel_factory';
|
export { ordersChannelFactory } from './orders_channel_factory';
|
||||||
export {
|
export {
|
||||||
Client,
|
Client,
|
||||||
FeesRequest,
|
OrderConfigRequest,
|
||||||
FeesResponse,
|
OrderConfigResponse,
|
||||||
OrderbookChannel,
|
OrdersChannel,
|
||||||
OrderbookChannelHandler,
|
OrdersChannelHandler,
|
||||||
OrderbookChannelSubscriptionOpts,
|
OrdersChannelSubscriptionOpts,
|
||||||
OrderbookRequest,
|
OrderbookRequest,
|
||||||
OrderbookResponse,
|
OrderbookResponse,
|
||||||
OrdersRequestOpts,
|
OrdersRequestOpts,
|
||||||
PagedRequestOpts,
|
PagedRequestOpts,
|
||||||
TokenPairsItem,
|
AssetPairsRequestOpts,
|
||||||
TokenPairsRequestOpts,
|
RequestOpts,
|
||||||
TokenTradeInfo,
|
AssetPairsResponse,
|
||||||
|
FeeRecipientsResponse,
|
||||||
|
APIOrder,
|
||||||
|
OrdersResponse,
|
||||||
|
PaginatedCollection,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
export { Order, SignedOrder } from '@0xproject/types';
|
export { SignedOrder } from '@0xproject/types';
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
import { postpublishUtils } from '@0xproject/monorepo-scripts';
|
|
||||||
|
|
||||||
import * as packageJSON from '../package.json';
|
|
||||||
import * as tsConfigJSON from '../tsconfig.json';
|
|
||||||
|
|
||||||
const cwd = `${__dirname}/..`;
|
|
||||||
// tslint:disable-next-line:no-floating-promises
|
|
||||||
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);
|
|
@@ -1,8 +0,0 @@
|
|||||||
import { postpublishUtils } from '@0xproject/monorepo-scripts';
|
|
||||||
|
|
||||||
import * as packageJSON from '../package.json';
|
|
||||||
import * as tsConfigJSON from '../tsconfig.json';
|
|
||||||
|
|
||||||
const cwd = `${__dirname}/..`;
|
|
||||||
// tslint:disable-next-line:no-floating-promises
|
|
||||||
postpublishUtils.publishDocsToStagingAsync(packageJSON, tsConfigJSON, cwd);
|
|
@@ -1,32 +0,0 @@
|
|||||||
import * as WebSocket from 'websocket';
|
|
||||||
|
|
||||||
import { OrderbookChannel, OrderbookChannelHandler } from './types';
|
|
||||||
import { assert } from './utils/assert';
|
|
||||||
import { WebSocketOrderbookChannel } from './ws_orderbook_channel';
|
|
||||||
|
|
||||||
export const orderbookChannelFactory = {
|
|
||||||
/**
|
|
||||||
* Instantiates a new WebSocketOrderbookChannel instance
|
|
||||||
* @param url The relayer API base WS url you would like to interact with
|
|
||||||
* @param handler An OrderbookChannelHandler instance that responds to various
|
|
||||||
* channel updates
|
|
||||||
* @return An OrderbookChannel Promise
|
|
||||||
*/
|
|
||||||
async createWebSocketOrderbookChannelAsync(
|
|
||||||
url: string,
|
|
||||||
handler: OrderbookChannelHandler,
|
|
||||||
): Promise<OrderbookChannel> {
|
|
||||||
assert.isUri('url', url);
|
|
||||||
assert.isOrderbookChannelHandler('handler', handler);
|
|
||||||
return new Promise<OrderbookChannel>((resolve, reject) => {
|
|
||||||
const client = new WebSocket.w3cwebsocket(url);
|
|
||||||
client.onopen = () => {
|
|
||||||
const orderbookChannel = new WebSocketOrderbookChannel(client, handler);
|
|
||||||
resolve(orderbookChannel);
|
|
||||||
};
|
|
||||||
client.onerror = err => {
|
|
||||||
reject(err);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
29
packages/connect/src/orders_channel_factory.ts
Normal file
29
packages/connect/src/orders_channel_factory.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import * as WebSocket from 'websocket';
|
||||||
|
|
||||||
|
import { OrdersChannel, OrdersChannelHandler } from './types';
|
||||||
|
import { assert } from './utils/assert';
|
||||||
|
import { WebSocketOrdersChannel } from './ws_orders_channel';
|
||||||
|
|
||||||
|
export const ordersChannelFactory = {
|
||||||
|
/**
|
||||||
|
* Instantiates a new WebSocketOrdersChannel instance
|
||||||
|
* @param url The relayer API base WS url you would like to interact with
|
||||||
|
* @param handler An OrdersChannelHandler instance that responds to various
|
||||||
|
* channel updates
|
||||||
|
* @return An OrdersChannel Promise
|
||||||
|
*/
|
||||||
|
async createWebSocketOrdersChannelAsync(url: string, handler: OrdersChannelHandler): Promise<OrdersChannel> {
|
||||||
|
assert.isUri('url', url);
|
||||||
|
assert.isOrdersChannelHandler('handler', handler);
|
||||||
|
return new Promise<OrdersChannel>((resolve, reject) => {
|
||||||
|
const client = new WebSocket.w3cwebsocket(url);
|
||||||
|
client.onopen = () => {
|
||||||
|
const ordersChannel = new WebSocketOrdersChannel(client, handler);
|
||||||
|
resolve(ordersChannel);
|
||||||
|
};
|
||||||
|
client.onerror = err => {
|
||||||
|
reject(err);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
@@ -0,0 +1,8 @@
|
|||||||
|
export const assetPairsRequestOptsSchema = {
|
||||||
|
id: '/AssetPairsRequestOpts',
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
assetDataA: { $ref: '/hexSchema' },
|
||||||
|
assetDataB: { $ref: '/hexSchema' },
|
||||||
|
},
|
||||||
|
};
|
@@ -1,26 +0,0 @@
|
|||||||
export const feesRequestSchema = {
|
|
||||||
id: '/FeesRequest',
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
exchangeContractAddress: { $ref: '/Address' },
|
|
||||||
maker: { $ref: '/Address' },
|
|
||||||
taker: { $ref: '/Address' },
|
|
||||||
makerTokenAddress: { $ref: '/Address' },
|
|
||||||
takerTokenAddress: { $ref: '/Address' },
|
|
||||||
makerTokenAmount: { $ref: '/Number' },
|
|
||||||
takerTokenAmount: { $ref: '/Number' },
|
|
||||||
expirationUnixTimestampSec: { $ref: '/Number' },
|
|
||||||
salt: { $ref: '/Number' },
|
|
||||||
},
|
|
||||||
required: [
|
|
||||||
'exchangeContractAddress',
|
|
||||||
'maker',
|
|
||||||
'taker',
|
|
||||||
'makerTokenAddress',
|
|
||||||
'takerTokenAddress',
|
|
||||||
'makerTokenAmount',
|
|
||||||
'takerTokenAmount',
|
|
||||||
'expirationUnixTimestampSec',
|
|
||||||
'salt',
|
|
||||||
],
|
|
||||||
};
|
|
24
packages/connect/src/schemas/order_config_request_schema.ts
Normal file
24
packages/connect/src/schemas/order_config_request_schema.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
export const orderConfigRequestSchema = {
|
||||||
|
id: '/OrderConfigRequest',
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
makerAddress: { $ref: '/addressSchema' },
|
||||||
|
takerAddress: { $ref: '/addressSchema' },
|
||||||
|
makerAssetAmount: { $ref: '/numberSchema' },
|
||||||
|
takerAssetAmount: { $ref: '/numberSchema' },
|
||||||
|
makerAssetData: { $ref: '/hexSchema' },
|
||||||
|
takerAssetData: { $ref: '/hexSchema' },
|
||||||
|
exchangeAddress: { $ref: '/addressSchema' },
|
||||||
|
expirationTimeSeconds: { $ref: '/numberSchema' },
|
||||||
|
},
|
||||||
|
required: [
|
||||||
|
'makerAddress',
|
||||||
|
'takerAddress',
|
||||||
|
'makerAssetAmount',
|
||||||
|
'takerAssetAmount',
|
||||||
|
'makerAssetData',
|
||||||
|
'takerAssetData',
|
||||||
|
'exchangeAddress',
|
||||||
|
'expirationTimeSeconds',
|
||||||
|
],
|
||||||
|
};
|
@@ -2,8 +2,8 @@ export const orderBookRequestSchema = {
|
|||||||
id: '/OrderBookRequest',
|
id: '/OrderBookRequest',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
baseTokenAddress: { $ref: '/Address' },
|
baseAssetData: { $ref: '/hexSchema' },
|
||||||
quoteTokenAddress: { $ref: '/Address' },
|
quoteAssetData: { $ref: '/hexSchema' },
|
||||||
},
|
},
|
||||||
required: ['baseTokenAddress', 'quoteTokenAddress'],
|
required: ['baseAssetData', 'quoteAssetData'],
|
||||||
};
|
};
|
||||||
|
@@ -2,15 +2,18 @@ export const ordersRequestOptsSchema = {
|
|||||||
id: '/OrdersRequestOpts',
|
id: '/OrdersRequestOpts',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
exchangeContractAddress: { $ref: '/Address' },
|
makerAssetProxyId: { $ref: '/hexSchema' },
|
||||||
tokenAddress: { $ref: '/Address' },
|
takerAssetProxyId: { $ref: '/hexSchema' },
|
||||||
makerTokenAddress: { $ref: '/Address' },
|
makerAssetAddress: { $ref: '/addressSchema' },
|
||||||
takerTokenAddress: { $ref: '/Address' },
|
takerAssetAddress: { $ref: '/addressSchema' },
|
||||||
tokenA: { $ref: '/Address' },
|
exchangeAddress: { $ref: '/addressSchema' },
|
||||||
tokenB: { $ref: '/Address' },
|
senderAddress: { $ref: '/addressSchema' },
|
||||||
maker: { $ref: '/Address' },
|
makerAssetData: { $ref: '/hexSchema' },
|
||||||
taker: { $ref: '/Address' },
|
takerAssetData: { $ref: '/hexSchema' },
|
||||||
trader: { $ref: '/Address' },
|
traderAssetData: { $ref: '/hexSchema' },
|
||||||
feeRecipient: { $ref: '/Address' },
|
makerAddress: { $ref: '/addressSchema' },
|
||||||
|
takerAddress: { $ref: '/addressSchema' },
|
||||||
|
traderAddress: { $ref: '/addressSchema' },
|
||||||
|
feeRecipientAddress: { $ref: '/addressSchema' },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
7
packages/connect/src/schemas/request_opts_schema.ts
Normal file
7
packages/connect/src/schemas/request_opts_schema.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export const requestOptsSchema = {
|
||||||
|
id: '/RequestOpts',
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
networkId: { type: 'number' },
|
||||||
|
},
|
||||||
|
};
|
@@ -1,13 +1,15 @@
|
|||||||
import { feesRequestSchema } from './fees_request_schema';
|
import { assetPairsRequestOptsSchema } from './asset_pairs_request_opts_schema';
|
||||||
|
import { orderConfigRequestSchema } from './order_config_request_schema';
|
||||||
import { orderBookRequestSchema } from './orderbook_request_schema';
|
import { orderBookRequestSchema } from './orderbook_request_schema';
|
||||||
import { ordersRequestOptsSchema } from './orders_request_opts_schema';
|
import { ordersRequestOptsSchema } from './orders_request_opts_schema';
|
||||||
import { pagedRequestOptsSchema } from './paged_request_opts_schema';
|
import { pagedRequestOptsSchema } from './paged_request_opts_schema';
|
||||||
import { tokenPairsRequestOptsSchema } from './token_pairs_request_opts_schema';
|
import { requestOptsSchema } from './request_opts_schema';
|
||||||
|
|
||||||
export const schemas = {
|
export const schemas = {
|
||||||
feesRequestSchema,
|
orderConfigRequestSchema,
|
||||||
orderBookRequestSchema,
|
orderBookRequestSchema,
|
||||||
ordersRequestOptsSchema,
|
ordersRequestOptsSchema,
|
||||||
pagedRequestOptsSchema,
|
pagedRequestOptsSchema,
|
||||||
tokenPairsRequestOptsSchema,
|
requestOptsSchema,
|
||||||
|
assetPairsRequestOptsSchema,
|
||||||
};
|
};
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
export const tokenPairsRequestOptsSchema = {
|
|
||||||
id: '/TokenPairsRequestOpts',
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
tokenA: { $ref: '/Address' },
|
|
||||||
tokenB: { $ref: '/Address' },
|
|
||||||
},
|
|
||||||
};
|
|
@@ -2,73 +2,55 @@ import { SignedOrder } from '@0xproject/types';
|
|||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
export interface Client {
|
export interface Client {
|
||||||
getTokenPairsAsync: (requestOpts?: TokenPairsRequestOpts & PagedRequestOpts) => Promise<TokenPairsItem[]>;
|
getAssetPairsAsync: (
|
||||||
getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<SignedOrder[]>;
|
requestOpts?: AssetPairsRequestOpts & PagedRequestOpts,
|
||||||
getOrderAsync: (orderHash: string) => Promise<SignedOrder>;
|
) => Promise<PaginatedCollection<AssetPairsItem>>;
|
||||||
|
getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<PaginatedCollection<APIOrder>>;
|
||||||
|
getOrderAsync: (orderHash: string) => Promise<APIOrder>;
|
||||||
getOrderbookAsync: (request: OrderbookRequest, requestOpts?: PagedRequestOpts) => Promise<OrderbookResponse>;
|
getOrderbookAsync: (request: OrderbookRequest, requestOpts?: PagedRequestOpts) => Promise<OrderbookResponse>;
|
||||||
getFeesAsync: (request: FeesRequest) => Promise<FeesResponse>;
|
getOrderConfigAsync: (request: OrderConfigRequest) => Promise<OrderConfigResponse>;
|
||||||
|
getFeeRecipientsAsync: (requestOpts?: PagedRequestOpts) => Promise<FeeRecipientsResponse>;
|
||||||
submitOrderAsync: (signedOrder: SignedOrder) => Promise<void>;
|
submitOrderAsync: (signedOrder: SignedOrder) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OrderbookChannel {
|
export interface OrdersChannel {
|
||||||
subscribe: (subscriptionOpts: OrderbookChannelSubscriptionOpts) => void;
|
subscribe: (subscriptionOpts: OrdersChannelSubscriptionOpts) => void;
|
||||||
close: () => void;
|
close: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* baseTokenAddress: The address of token designated as the baseToken in the currency pair calculation of price
|
* baseAssetData: The address of assetData 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
|
* quoteAssetData: The address of assetData 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
|
|
||||||
* limit: Maximum number of bids and asks in orderbook snapshot
|
* limit: Maximum number of bids and asks in orderbook snapshot
|
||||||
*/
|
*/
|
||||||
export interface OrderbookChannelSubscriptionOpts {
|
export interface OrdersChannelSubscriptionOpts {
|
||||||
baseTokenAddress: string;
|
baseAssetData: string;
|
||||||
quoteTokenAddress: string;
|
quoteAssetData: string;
|
||||||
snapshot: boolean;
|
|
||||||
limit: number;
|
limit: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OrderbookChannelHandler {
|
export interface OrdersChannelHandler {
|
||||||
onSnapshot: (
|
onUpdate: (channel: OrdersChannel, subscriptionOpts: OrdersChannelSubscriptionOpts, orders: APIOrder[]) => void;
|
||||||
channel: OrderbookChannel,
|
onError: (channel: OrdersChannel, err: Error, subscriptionOpts?: OrdersChannelSubscriptionOpts) => void;
|
||||||
subscriptionOpts: OrderbookChannelSubscriptionOpts,
|
onClose: (channel: OrdersChannel) => void;
|
||||||
snapshot: OrderbookResponse,
|
|
||||||
) => void;
|
|
||||||
onUpdate: (
|
|
||||||
channel: OrderbookChannel,
|
|
||||||
subscriptionOpts: OrderbookChannelSubscriptionOpts,
|
|
||||||
order: SignedOrder,
|
|
||||||
) => void;
|
|
||||||
onError: (channel: OrderbookChannel, err: Error, subscriptionOpts?: OrderbookChannelSubscriptionOpts) => void;
|
|
||||||
onClose: (channel: OrderbookChannel) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OrderbookChannelMessage =
|
export type OrdersChannelMessage = UpdateOrdersChannelMessage | UnknownOrdersChannelMessage;
|
||||||
| SnapshotOrderbookChannelMessage
|
|
||||||
| UpdateOrderbookChannelMessage
|
|
||||||
| UnknownOrderbookChannelMessage;
|
|
||||||
|
|
||||||
export enum OrderbookChannelMessageTypes {
|
export enum OrdersChannelMessageTypes {
|
||||||
Snapshot = 'snapshot',
|
|
||||||
Update = 'update',
|
Update = 'update',
|
||||||
Unknown = 'unknown',
|
Unknown = 'unknown',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SnapshotOrderbookChannelMessage {
|
export interface UpdateOrdersChannelMessage {
|
||||||
type: OrderbookChannelMessageTypes.Snapshot;
|
type: OrdersChannelMessageTypes.Update;
|
||||||
requestId: number;
|
requestId: string;
|
||||||
payload: OrderbookResponse;
|
payload: APIOrder[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateOrderbookChannelMessage {
|
export interface UnknownOrdersChannelMessage {
|
||||||
type: OrderbookChannelMessageTypes.Update;
|
type: OrdersChannelMessageTypes.Unknown;
|
||||||
requestId: number;
|
requestId: string;
|
||||||
payload: SignedOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UnknownOrderbookChannelMessage {
|
|
||||||
type: OrderbookChannelMessageTypes.Unknown;
|
|
||||||
requestId: number;
|
|
||||||
payload: undefined;
|
payload: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,60 +65,86 @@ export enum WebsocketClientEventType {
|
|||||||
ConnectFailed = 'connectFailed',
|
ConnectFailed = 'connectFailed',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TokenPairsRequestOpts {
|
export type OrdersResponse = PaginatedCollection<APIOrder>;
|
||||||
tokenA?: string;
|
|
||||||
tokenB?: string;
|
export interface APIOrder {
|
||||||
|
order: SignedOrder;
|
||||||
|
metaData: object;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TokenPairsItem {
|
export interface AssetPairsRequestOpts {
|
||||||
tokenA: TokenTradeInfo;
|
assetDataA?: string;
|
||||||
tokenB: TokenTradeInfo;
|
assetDataB?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TokenTradeInfo {
|
export type AssetPairsResponse = PaginatedCollection<AssetPairsItem>;
|
||||||
address: string;
|
|
||||||
|
export interface AssetPairsItem {
|
||||||
|
assetDataA: Asset;
|
||||||
|
assetDataB: Asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Asset {
|
||||||
|
assetData: string;
|
||||||
minAmount: BigNumber;
|
minAmount: BigNumber;
|
||||||
maxAmount: BigNumber;
|
maxAmount: BigNumber;
|
||||||
precision: number;
|
precision: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OrdersRequestOpts {
|
export interface OrdersRequestOpts {
|
||||||
exchangeContractAddress?: string;
|
makerAssetProxyId?: string;
|
||||||
tokenAddress?: string;
|
takerAssetProxyId?: string;
|
||||||
makerTokenAddress?: string;
|
makerAssetAddress?: string;
|
||||||
takerTokenAddress?: string;
|
takerAssetAddress?: string;
|
||||||
maker?: string;
|
exchangeAddress?: string;
|
||||||
taker?: string;
|
senderAddress?: string;
|
||||||
trader?: string;
|
makerAssetData?: string;
|
||||||
feeRecipient?: string;
|
takerAssetData?: string;
|
||||||
|
makerAddress?: string;
|
||||||
|
takerAddress?: string;
|
||||||
|
traderAddress?: string;
|
||||||
|
feeRecipientAddress?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OrderbookRequest {
|
export interface OrderbookRequest {
|
||||||
baseTokenAddress: string;
|
baseAssetData: string;
|
||||||
quoteTokenAddress: string;
|
quoteAssetData: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OrderbookResponse {
|
export interface OrderbookResponse {
|
||||||
bids: SignedOrder[];
|
bids: PaginatedCollection<APIOrder>;
|
||||||
asks: SignedOrder[];
|
asks: PaginatedCollection<APIOrder>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FeesRequest {
|
export interface PaginatedCollection<T> {
|
||||||
exchangeContractAddress: string;
|
total: number;
|
||||||
maker: string;
|
page: number;
|
||||||
taker: string;
|
perPage: number;
|
||||||
makerTokenAddress: string;
|
records: T[];
|
||||||
takerTokenAddress: string;
|
|
||||||
makerTokenAmount: BigNumber;
|
|
||||||
takerTokenAmount: BigNumber;
|
|
||||||
expirationUnixTimestampSec: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FeesResponse {
|
export interface OrderConfigRequest {
|
||||||
feeRecipient: string;
|
makerAddress: string;
|
||||||
|
takerAddress: string;
|
||||||
|
makerAssetAmount: string;
|
||||||
|
takerAssetAmount: string;
|
||||||
|
makerAssetData: string;
|
||||||
|
takerAssetData: string;
|
||||||
|
exchangeAddress: string;
|
||||||
|
expirationTimeSeconds: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderConfigResponse {
|
||||||
makerFee: BigNumber;
|
makerFee: BigNumber;
|
||||||
takerFee: BigNumber;
|
takerFee: BigNumber;
|
||||||
|
feeRecipientAddress: string;
|
||||||
|
senderAddress: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type FeeRecipientsResponse = PaginatedCollection<string>;
|
||||||
|
|
||||||
|
export interface RequestOpts {
|
||||||
|
networkId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PagedRequestOpts {
|
export interface PagedRequestOpts {
|
||||||
|
@@ -10,15 +10,14 @@ import * as _ from 'lodash';
|
|||||||
|
|
||||||
export const assert = {
|
export const assert = {
|
||||||
...sharedAssert,
|
...sharedAssert,
|
||||||
isOrderbookChannelSubscriptionOpts(variableName: string, subscriptionOpts: any): void {
|
isOrdersChannelSubscriptionOpts(variableName: string, subscriptionOpts: any): void {
|
||||||
sharedAssert.doesConformToSchema(
|
sharedAssert.doesConformToSchema(
|
||||||
variableName,
|
variableName,
|
||||||
subscriptionOpts,
|
subscriptionOpts,
|
||||||
schemas.relayerApiOrderbookChannelSubscribePayload,
|
schemas.relayerApiOrdersChannelSubscribePayload,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
isOrderbookChannelHandler(variableName: string, handler: any): void {
|
isOrdersChannelHandler(variableName: string, handler: any): void {
|
||||||
sharedAssert.isFunction(`${variableName}.onSnapshot`, _.get(handler, 'onSnapshot'));
|
|
||||||
sharedAssert.isFunction(`${variableName}.onUpdate`, _.get(handler, 'onUpdate'));
|
sharedAssert.isFunction(`${variableName}.onUpdate`, _.get(handler, 'onUpdate'));
|
||||||
sharedAssert.isFunction(`${variableName}.onError`, _.get(handler, 'onError'));
|
sharedAssert.isFunction(`${variableName}.onError`, _.get(handler, 'onError'));
|
||||||
sharedAssert.isFunction(`${variableName}.onClose`, _.get(handler, 'onClose'));
|
sharedAssert.isFunction(`${variableName}.onClose`, _.get(handler, 'onClose'));
|
||||||
|
@@ -1,43 +0,0 @@
|
|||||||
import { assert } from '@0xproject/assert';
|
|
||||||
import { schemas } from '@0xproject/json-schemas';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
import { OrderbookChannelMessage, OrderbookChannelMessageTypes } from '../types';
|
|
||||||
|
|
||||||
import { relayerResponseJsonParsers } from './relayer_response_json_parsers';
|
|
||||||
|
|
||||||
export const orderbookChannelMessageParser = {
|
|
||||||
parse(utf8Data: string): OrderbookChannelMessage {
|
|
||||||
// parse the message
|
|
||||||
const messageObj = JSON.parse(utf8Data);
|
|
||||||
// ensure we have a type parameter to switch on
|
|
||||||
const type: string = _.get(messageObj, 'type');
|
|
||||||
assert.assert(!_.isUndefined(type), `Message is missing a type parameter: ${utf8Data}`);
|
|
||||||
assert.isString('type', type);
|
|
||||||
// ensure we have a request id for the resulting message
|
|
||||||
const requestId: number = _.get(messageObj, 'requestId');
|
|
||||||
assert.assert(!_.isUndefined(requestId), `Message is missing a requestId parameter: ${utf8Data}`);
|
|
||||||
assert.isNumber('requestId', requestId);
|
|
||||||
switch (type) {
|
|
||||||
case OrderbookChannelMessageTypes.Snapshot: {
|
|
||||||
assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelSnapshotSchema);
|
|
||||||
const orderbookJson = messageObj.payload;
|
|
||||||
const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(orderbookJson);
|
|
||||||
return _.assign(messageObj, { payload: orderbook });
|
|
||||||
}
|
|
||||||
case OrderbookChannelMessageTypes.Update: {
|
|
||||||
assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelUpdateSchema);
|
|
||||||
const orderJson = messageObj.payload;
|
|
||||||
const order = relayerResponseJsonParsers.parseOrderJson(orderJson);
|
|
||||||
return _.assign(messageObj, { payload: order });
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return {
|
|
||||||
type: OrderbookChannelMessageTypes.Unknown,
|
|
||||||
requestId,
|
|
||||||
payload: undefined,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
37
packages/connect/src/utils/orders_channel_message_parser.ts
Normal file
37
packages/connect/src/utils/orders_channel_message_parser.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { assert } from '@0xproject/assert';
|
||||||
|
import { schemas } from '@0xproject/json-schemas';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
import { OrdersChannelMessage, OrdersChannelMessageTypes } from '../types';
|
||||||
|
|
||||||
|
import { relayerResponseJsonParsers } from './relayer_response_json_parsers';
|
||||||
|
|
||||||
|
export const ordersChannelMessageParser = {
|
||||||
|
parse(utf8Data: string): OrdersChannelMessage {
|
||||||
|
// parse the message
|
||||||
|
const messageObj = JSON.parse(utf8Data);
|
||||||
|
// ensure we have a type parameter to switch on
|
||||||
|
const type: string = _.get(messageObj, 'type');
|
||||||
|
assert.assert(!_.isUndefined(type), `Message is missing a type parameter: ${utf8Data}`);
|
||||||
|
assert.isString('type', type);
|
||||||
|
// ensure we have a request id for the resulting message
|
||||||
|
const requestId: string = _.get(messageObj, 'requestId');
|
||||||
|
assert.assert(!_.isUndefined(requestId), `Message is missing a requestId parameter: ${utf8Data}`);
|
||||||
|
assert.isString('requestId', requestId);
|
||||||
|
switch (type) {
|
||||||
|
case OrdersChannelMessageTypes.Update: {
|
||||||
|
assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrdersChannelUpdateSchema);
|
||||||
|
const ordersJson = messageObj.payload;
|
||||||
|
const orders = relayerResponseJsonParsers.parseAPIOrdersJson(ordersJson);
|
||||||
|
return _.assign(messageObj, { payload: orders });
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return {
|
||||||
|
type: OrdersChannelMessageTypes.Unknown,
|
||||||
|
requestId,
|
||||||
|
payload: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
@@ -1,37 +1,49 @@
|
|||||||
import { assert } from '@0xproject/assert';
|
import { assert } from '@0xproject/assert';
|
||||||
import { schemas } from '@0xproject/json-schemas';
|
import { schemas } from '@0xproject/json-schemas';
|
||||||
import { SignedOrder } from '@0xproject/types';
|
|
||||||
|
|
||||||
import { FeesResponse, OrderbookResponse, TokenPairsItem } from '../types';
|
import {
|
||||||
|
APIOrder,
|
||||||
|
AssetPairsItem,
|
||||||
|
AssetPairsResponse,
|
||||||
|
OrderbookResponse,
|
||||||
|
OrderConfigResponse,
|
||||||
|
OrdersResponse,
|
||||||
|
} from '../types';
|
||||||
|
|
||||||
import { typeConverters } from './type_converters';
|
import { typeConverters } from './type_converters';
|
||||||
|
|
||||||
export const relayerResponseJsonParsers = {
|
export const relayerResponseJsonParsers = {
|
||||||
parseTokenPairsJson(json: any): TokenPairsItem[] {
|
parseAssetDataPairsJson(json: any): AssetPairsResponse {
|
||||||
assert.doesConformToSchema('tokenPairs', json, schemas.relayerApiTokenPairsResponseSchema);
|
assert.doesConformToSchema('assetDataPairsResponse', json, schemas.relayerApiAssetDataPairsResponseSchema);
|
||||||
return json.map((tokenPair: any) => {
|
return { ...json, records: relayerResponseJsonParsers.parseAssetPairsItemsJson(json.records) };
|
||||||
return typeConverters.convertStringsFieldsToBigNumbers(tokenPair, [
|
},
|
||||||
'tokenA.minAmount',
|
parseAssetPairsItemsJson(json: any): AssetPairsItem[] {
|
||||||
'tokenA.maxAmount',
|
return json.map((assetDataPair: any) => {
|
||||||
'tokenB.minAmount',
|
return typeConverters.convertStringsFieldsToBigNumbers(assetDataPair, [
|
||||||
'tokenB.maxAmount',
|
'assetDataA.minAmount',
|
||||||
|
'assetDataA.maxAmount',
|
||||||
|
'assetDataB.minAmount',
|
||||||
|
'assetDataB.maxAmount',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
parseOrdersJson(json: any): SignedOrder[] {
|
parseOrdersJson(json: any): OrdersResponse {
|
||||||
assert.doesConformToSchema('orders', json, schemas.signedOrdersSchema);
|
assert.doesConformToSchema('relayerApiOrdersResponse', json, schemas.relayerApiOrdersResponseSchema);
|
||||||
return json.map((order: object) => typeConverters.convertOrderStringFieldsToBigNumber(order));
|
return { ...json, records: relayerResponseJsonParsers.parseAPIOrdersJson(json.records) };
|
||||||
},
|
},
|
||||||
parseOrderJson(json: any): SignedOrder {
|
parseAPIOrdersJson(json: any): APIOrder[] {
|
||||||
assert.doesConformToSchema('order', json, schemas.signedOrderSchema);
|
return json.map(relayerResponseJsonParsers.parseAPIOrderJson.bind(relayerResponseJsonParsers));
|
||||||
return typeConverters.convertOrderStringFieldsToBigNumber(json);
|
},
|
||||||
|
parseAPIOrderJson(json: any): APIOrder {
|
||||||
|
assert.doesConformToSchema('relayerApiOrder', json, schemas.relayerApiOrderSchema);
|
||||||
|
return typeConverters.convertAPIOrderStringFieldsToBigNumber(json);
|
||||||
},
|
},
|
||||||
parseOrderbookResponseJson(json: any): OrderbookResponse {
|
parseOrderbookResponseJson(json: any): OrderbookResponse {
|
||||||
assert.doesConformToSchema('orderBook', json, schemas.relayerApiOrderBookResponseSchema);
|
assert.doesConformToSchema('orderBookResponse', json, schemas.relayerApiOrderbookResponseSchema);
|
||||||
return typeConverters.convertOrderbookStringFieldsToBigNumber(json);
|
return typeConverters.convertOrderbookStringFieldsToBigNumber(json);
|
||||||
},
|
},
|
||||||
parseFeesResponseJson(json: any): FeesResponse {
|
parseOrderConfigResponseJson(json: any): OrderConfigResponse {
|
||||||
assert.doesConformToSchema('fees', json, schemas.relayerApiFeesResponseSchema);
|
assert.doesConformToSchema('orderConfigResponse', json, schemas.relayerApiOrderConfigResponseSchema);
|
||||||
return typeConverters.convertStringsFieldsToBigNumbers(json, ['makerFee', 'takerFee']);
|
return typeConverters.convertStringsFieldsToBigNumbers(json, ['makerFee', 'takerFee']);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@@ -1,29 +1,47 @@
|
|||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
import { APIOrder } from '../types';
|
||||||
|
|
||||||
export const typeConverters = {
|
export const typeConverters = {
|
||||||
convertOrderbookStringFieldsToBigNumber(orderbook: any): any {
|
convertOrderbookStringFieldsToBigNumber(orderbook: any): any {
|
||||||
const bids = _.get(orderbook, 'bids', []);
|
const bids = _.get(orderbook, 'bids', []);
|
||||||
const asks = _.get(orderbook, 'asks', []);
|
const asks = _.get(orderbook, 'asks', []);
|
||||||
return {
|
const convertedBids = {
|
||||||
bids: bids.map((order: any) => typeConverters.convertOrderStringFieldsToBigNumber(order)),
|
...bids,
|
||||||
asks: asks.map((order: any) => typeConverters.convertOrderStringFieldsToBigNumber(order)),
|
records: bids.records.map((order: any) => typeConverters.convertAPIOrderStringFieldsToBigNumber(order)),
|
||||||
};
|
};
|
||||||
|
const convertedAsks = {
|
||||||
|
...asks,
|
||||||
|
records: asks.records.map((order: any) => typeConverters.convertAPIOrderStringFieldsToBigNumber(order)),
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
bids: convertedBids,
|
||||||
|
asks: convertedAsks,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
convertAPIOrderStringFieldsToBigNumber(apiOrder: any): APIOrder {
|
||||||
|
return { ...apiOrder, order: typeConverters.convertOrderStringFieldsToBigNumber(apiOrder.order) };
|
||||||
},
|
},
|
||||||
convertOrderStringFieldsToBigNumber(order: any): any {
|
convertOrderStringFieldsToBigNumber(order: any): any {
|
||||||
return typeConverters.convertStringsFieldsToBigNumbers(order, [
|
return typeConverters.convertStringsFieldsToBigNumbers(order, [
|
||||||
'makerTokenAmount',
|
'makerAssetAmount',
|
||||||
'takerTokenAmount',
|
'takerAssetAmount',
|
||||||
'makerFee',
|
'makerFee',
|
||||||
'takerFee',
|
'takerFee',
|
||||||
'expirationUnixTimestampSec',
|
'expirationTimeSeconds',
|
||||||
'salt',
|
'salt',
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
convertStringsFieldsToBigNumbers(obj: any, fields: string[]): any {
|
convertStringsFieldsToBigNumbers(obj: any, fields: string[]): any {
|
||||||
const result = _.assign({}, obj);
|
const result = _.assign({}, obj);
|
||||||
_.each(fields, field => {
|
_.each(fields, field => {
|
||||||
_.update(result, field, (value: string) => new BigNumber(value));
|
_.update(result, field, (value: string) => {
|
||||||
|
if (_.isUndefined(value)) {
|
||||||
|
throw new Error(`Could not find field '${field}' while converting string fields to BigNumber.`);
|
||||||
|
}
|
||||||
|
return new BigNumber(value);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
@@ -1,32 +1,32 @@
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
import { v4 as uuid } from 'uuid';
|
||||||
import * as WebSocket from 'websocket';
|
import * as WebSocket from 'websocket';
|
||||||
|
|
||||||
import {
|
import { OrdersChannel, OrdersChannelHandler, OrdersChannelMessageTypes, OrdersChannelSubscriptionOpts } from './types';
|
||||||
OrderbookChannel,
|
|
||||||
OrderbookChannelHandler,
|
|
||||||
OrderbookChannelMessageTypes,
|
|
||||||
OrderbookChannelSubscriptionOpts,
|
|
||||||
} from './types';
|
|
||||||
import { assert } from './utils/assert';
|
import { assert } from './utils/assert';
|
||||||
import { orderbookChannelMessageParser } from './utils/orderbook_channel_message_parser';
|
import { ordersChannelMessageParser } from './utils/orders_channel_message_parser';
|
||||||
|
|
||||||
|
export interface OrdersChannelSubscriptionOptsMap {
|
||||||
|
[key: string]: OrdersChannelSubscriptionOpts;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class includes all the functionality related to interacting with a websocket endpoint
|
* This class includes all the functionality related to interacting with a websocket endpoint
|
||||||
* that implements the standard relayer API v0
|
* that implements the standard relayer API v0
|
||||||
*/
|
*/
|
||||||
export class WebSocketOrderbookChannel implements OrderbookChannel {
|
export class WebSocketOrdersChannel implements OrdersChannel {
|
||||||
private readonly _client: WebSocket.w3cwebsocket;
|
private readonly _client: WebSocket.w3cwebsocket;
|
||||||
private readonly _handler: OrderbookChannelHandler;
|
private readonly _handler: OrdersChannelHandler;
|
||||||
private readonly _subscriptionOptsList: OrderbookChannelSubscriptionOpts[] = [];
|
private readonly _subscriptionOptsMap: OrdersChannelSubscriptionOptsMap = {};
|
||||||
/**
|
/**
|
||||||
* Instantiates a new WebSocketOrderbookChannel instance
|
* Instantiates a new WebSocketOrdersChannel instance
|
||||||
* @param client A WebSocket client
|
* @param client A WebSocket client
|
||||||
* @param handler An OrderbookChannelHandler instance that responds to various
|
* @param handler An OrdersChannelHandler instance that responds to various
|
||||||
* channel updates
|
* channel updates
|
||||||
* @return An instance of WebSocketOrderbookChannel
|
* @return An instance of WebSocketOrdersChannel
|
||||||
*/
|
*/
|
||||||
constructor(client: WebSocket.w3cwebsocket, handler: OrderbookChannelHandler) {
|
constructor(client: WebSocket.w3cwebsocket, handler: OrdersChannelHandler) {
|
||||||
assert.isOrderbookChannelHandler('handler', handler);
|
assert.isOrdersChannelHandler('handler', handler);
|
||||||
// set private members
|
// set private members
|
||||||
this._client = client;
|
this._client = client;
|
||||||
this._handler = handler;
|
this._handler = handler;
|
||||||
@@ -43,18 +43,18 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Subscribe to orderbook snapshots and updates from the websocket
|
* Subscribe to orderbook snapshots and updates from the websocket
|
||||||
* @param subscriptionOpts An OrderbookChannelSubscriptionOpts instance describing which
|
* @param subscriptionOpts An OrdersChannelSubscriptionOpts instance describing which
|
||||||
* token pair to subscribe to
|
* assetData pair to subscribe to
|
||||||
*/
|
*/
|
||||||
public subscribe(subscriptionOpts: OrderbookChannelSubscriptionOpts): void {
|
public subscribe(subscriptionOpts: OrdersChannelSubscriptionOpts): void {
|
||||||
assert.isOrderbookChannelSubscriptionOpts('subscriptionOpts', subscriptionOpts);
|
assert.isOrdersChannelSubscriptionOpts('subscriptionOpts', subscriptionOpts);
|
||||||
assert.assert(this._client.readyState === WebSocket.w3cwebsocket.OPEN, 'WebSocket connection is closed');
|
assert.assert(this._client.readyState === WebSocket.w3cwebsocket.OPEN, 'WebSocket connection is closed');
|
||||||
this._subscriptionOptsList.push(subscriptionOpts);
|
const requestId = uuid();
|
||||||
// TODO: update requestId management to use UUIDs for v2
|
this._subscriptionOptsMap[requestId] = subscriptionOpts;
|
||||||
const subscribeMessage = {
|
const subscribeMessage = {
|
||||||
type: 'subscribe',
|
type: 'subscribe',
|
||||||
channel: 'orderbook',
|
channel: 'orders',
|
||||||
requestId: this._subscriptionOptsList.length - 1,
|
requestId,
|
||||||
payload: subscriptionOpts,
|
payload: subscriptionOpts,
|
||||||
};
|
};
|
||||||
this._client.send(JSON.stringify(subscribeMessage));
|
this._client.send(JSON.stringify(subscribeMessage));
|
||||||
@@ -72,8 +72,8 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const data = message.data;
|
const data = message.data;
|
||||||
const parserResult = orderbookChannelMessageParser.parse(data);
|
const parserResult = ordersChannelMessageParser.parse(data);
|
||||||
const subscriptionOpts = this._subscriptionOptsList[parserResult.requestId];
|
const subscriptionOpts = this._subscriptionOptsMap[parserResult.requestId];
|
||||||
if (_.isUndefined(subscriptionOpts)) {
|
if (_.isUndefined(subscriptionOpts)) {
|
||||||
this._handler.onError(
|
this._handler.onError(
|
||||||
this,
|
this,
|
||||||
@@ -82,11 +82,7 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (parserResult.type) {
|
switch (parserResult.type) {
|
||||||
case OrderbookChannelMessageTypes.Snapshot: {
|
case OrdersChannelMessageTypes.Update: {
|
||||||
this._handler.onSnapshot(this, subscriptionOpts, parserResult.payload);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case OrderbookChannelMessageTypes.Update: {
|
|
||||||
this._handler.onUpdate(this, subscriptionOpts, parserResult.payload);
|
this._handler.onUpdate(this, subscriptionOpts, parserResult.payload);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
21
packages/connect/test/fixtures/standard_relayer_api/asset_pairs.json
vendored
Normal file
21
packages/connect/test/fixtures/standard_relayer_api/asset_pairs.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"total": 43,
|
||||||
|
"page": 1,
|
||||||
|
"perPage": 100,
|
||||||
|
"records": [
|
||||||
|
{
|
||||||
|
"assetDataA": {
|
||||||
|
"minAmount": "0",
|
||||||
|
"maxAmount": "10000000000000000000",
|
||||||
|
"precision": 5,
|
||||||
|
"assetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d"
|
||||||
|
},
|
||||||
|
"assetDataB": {
|
||||||
|
"minAmount": "0",
|
||||||
|
"maxAmount": "50000000000000000000",
|
||||||
|
"precision": 5,
|
||||||
|
"assetData": "0x0257179264389b814a946f3e92105513705ca6b990"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
25
packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts
vendored
Normal file
25
packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
|
import { AssetPairsResponse } from '../../../src/types';
|
||||||
|
|
||||||
|
export const assetDataPairsResponse: AssetPairsResponse = {
|
||||||
|
total: 43,
|
||||||
|
page: 1,
|
||||||
|
perPage: 100,
|
||||||
|
records: [
|
||||||
|
{
|
||||||
|
assetDataA: {
|
||||||
|
minAmount: new BigNumber('0'),
|
||||||
|
maxAmount: new BigNumber('10000000000000000000'),
|
||||||
|
precision: 5,
|
||||||
|
assetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
||||||
|
},
|
||||||
|
assetDataB: {
|
||||||
|
minAmount: new BigNumber('0'),
|
||||||
|
maxAmount: new BigNumber('50000000000000000000'),
|
||||||
|
precision: 5,
|
||||||
|
assetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
10
packages/connect/test/fixtures/standard_relayer_api/fee_recipients.json
vendored
Normal file
10
packages/connect/test/fixtures/standard_relayer_api/fee_recipients.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"total": 3,
|
||||||
|
"page": 1,
|
||||||
|
"perPage": 10,
|
||||||
|
"records": [
|
||||||
|
"0x6ec92694ea172ebc430c30fa31de87620967a082",
|
||||||
|
"0x9e56625509c2f60af937f23b7b532600390e8c8b",
|
||||||
|
"0xa2b31dacf30a9c50ca473337c01d8a201ae33e32"
|
||||||
|
]
|
||||||
|
}
|
12
packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts
vendored
Normal file
12
packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { FeeRecipientsResponse } from '../../../src/types';
|
||||||
|
|
||||||
|
export const feeRecipientsResponse: FeeRecipientsResponse = {
|
||||||
|
total: 3,
|
||||||
|
page: 1,
|
||||||
|
perPage: 10,
|
||||||
|
records: [
|
||||||
|
'0x6ec92694ea172ebc430c30fa31de87620967a082',
|
||||||
|
'0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
||||||
|
'0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
|
],
|
||||||
|
};
|
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"feeRecipient": "0x323b5d4c32345ced77393b3530b1eed0f346429d",
|
|
||||||
"makerFee": "10000000000000000",
|
|
||||||
"takerFee": "30000000000000000"
|
|
||||||
}
|
|
@@ -1,9 +0,0 @@
|
|||||||
import { BigNumber } from '@0xproject/utils';
|
|
||||||
|
|
||||||
import { FeesResponse } from '../../../src/types';
|
|
||||||
|
|
||||||
export const feesResponse: FeesResponse = {
|
|
||||||
feeRecipient: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
|
||||||
makerFee: new BigNumber('10000000000000000'),
|
|
||||||
takerFee: new BigNumber('30000000000000000'),
|
|
||||||
};
|
|
@@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"maker": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
|
"order": {
|
||||||
"taker": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
|
||||||
"makerFee": "100000000000000",
|
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
||||||
"takerFee": "200000000000000",
|
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
|
||||||
"makerTokenAmount": "10000000000000000",
|
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
||||||
"takerTokenAmount": "20000000000000000",
|
"makerAssetAmount": "10000000000000000",
|
||||||
"makerTokenAddress": "0x323b5d4c32345ced77393b3530b1eed0f346429d",
|
"takerAssetAmount": "20000000000000000",
|
||||||
"takerTokenAddress": "0xef7fff64389b814a946f3e92105513705ca6b990",
|
"makerFee": "100000000000000",
|
||||||
"salt": "256",
|
"takerFee": "200000000000000",
|
||||||
"feeRecipient": "0xb046140686d052fff581f63f8136cce132e857da",
|
"expirationTimeSeconds": "1532560590",
|
||||||
"exchangeContractAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
"salt": "1532559225",
|
||||||
"expirationUnixTimestampSec": "42",
|
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
||||||
"ecSignature": {
|
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
||||||
"v": 27,
|
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
||||||
"r": "0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33",
|
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
|
||||||
"s": "0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254"
|
},
|
||||||
}
|
"metaData": {}
|
||||||
}
|
}
|
||||||
|
@@ -1,21 +1,21 @@
|
|||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
export const orderResponse = {
|
export const orderResponse = {
|
||||||
maker: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
order: {
|
||||||
taker: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
||||||
makerFee: new BigNumber('100000000000000'),
|
takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
takerFee: new BigNumber('200000000000000'),
|
feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
|
||||||
makerTokenAmount: new BigNumber('10000000000000000'),
|
senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
takerTokenAmount: new BigNumber('20000000000000000'),
|
makerAssetAmount: new BigNumber('10000000000000000'),
|
||||||
makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
takerAssetAmount: new BigNumber('20000000000000000'),
|
||||||
takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990',
|
makerFee: new BigNumber('100000000000000'),
|
||||||
salt: new BigNumber('256'),
|
takerFee: new BigNumber('200000000000000'),
|
||||||
feeRecipient: '0xb046140686d052fff581f63f8136cce132e857da',
|
expirationTimeSeconds: new BigNumber('1532560590'),
|
||||||
exchangeContractAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
salt: new BigNumber('1532559225'),
|
||||||
expirationUnixTimestampSec: new BigNumber('42'),
|
makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
||||||
ecSignature: {
|
takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
||||||
v: 27,
|
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
||||||
r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
||||||
s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
|
|
||||||
},
|
},
|
||||||
|
metaData: {},
|
||||||
};
|
};
|
||||||
|
6
packages/connect/test/fixtures/standard_relayer_api/order_config.json
vendored
Normal file
6
packages/connect/test/fixtures/standard_relayer_api/order_config.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
||||||
|
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
|
||||||
|
"makerFee": "100000000000000",
|
||||||
|
"takerFee": "200000000000000"
|
||||||
|
}
|
10
packages/connect/test/fixtures/standard_relayer_api/order_config.ts
vendored
Normal file
10
packages/connect/test/fixtures/standard_relayer_api/order_config.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
|
import { OrderConfigResponse } from '../../../src/types';
|
||||||
|
|
||||||
|
export const orderConfigResponse: OrderConfigResponse = {
|
||||||
|
senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
|
feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
|
||||||
|
makerFee: new BigNumber('100000000000000'),
|
||||||
|
takerFee: new BigNumber('200000000000000'),
|
||||||
|
};
|
@@ -1,44 +1,54 @@
|
|||||||
{
|
{
|
||||||
"bids": [
|
"bids": {
|
||||||
{
|
"total": 325,
|
||||||
"maker": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
|
"page": 2,
|
||||||
"taker": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
"perPage": 100,
|
||||||
"makerFee": "100000000000000",
|
"records": [
|
||||||
"takerFee": "200000000000000",
|
{
|
||||||
"makerTokenAmount": "10000000000000000",
|
"order": {
|
||||||
"takerTokenAmount": "20000000000000000",
|
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
|
||||||
"makerTokenAddress": "0x323b5d4c32345ced77393b3530b1eed0f346429d",
|
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
||||||
"takerTokenAddress": "0xef7fff64389b814a946f3e92105513705ca6b990",
|
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
|
||||||
"salt": "256",
|
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
||||||
"feeRecipient": "0xb046140686d052fff581f63f8136cce132e857da",
|
"makerAssetAmount": "10000000000000000",
|
||||||
"exchangeContractAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
"takerAssetAmount": "20000000000000000",
|
||||||
"expirationUnixTimestampSec": "42",
|
"makerFee": "100000000000000",
|
||||||
"ecSignature": {
|
"takerFee": "200000000000000",
|
||||||
"v": 27,
|
"expirationTimeSeconds": "1532560590",
|
||||||
"r": "0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33",
|
"salt": "1532559225",
|
||||||
"s": "0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254"
|
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
||||||
|
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
||||||
|
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
||||||
|
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
|
||||||
|
},
|
||||||
|
"metaData": {}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
],
|
},
|
||||||
"asks": [
|
"asks": {
|
||||||
{
|
"total": 500,
|
||||||
"maker": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
|
"page": 2,
|
||||||
"taker": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
"perPage": 100,
|
||||||
"makerFee": "100000000000000",
|
"records": [
|
||||||
"takerFee": "200000000000000",
|
{
|
||||||
"makerTokenAmount": "10000000000000000",
|
"order": {
|
||||||
"takerTokenAmount": "20000000000000000",
|
"makerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
||||||
"makerTokenAddress": "0x323b5d4c32345ced77393b3530b1eed0f346429d",
|
"takerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
|
||||||
"takerTokenAddress": "0xef7fff64389b814a946f3e92105513705ca6b990",
|
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
|
||||||
"salt": "256",
|
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
||||||
"feeRecipient": "0xb046140686d052fff581f63f8136cce132e857da",
|
"makerAssetAmount": "20000000000000000",
|
||||||
"exchangeContractAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
"takerAssetAmount": "10000000000000000",
|
||||||
"expirationUnixTimestampSec": "42",
|
"makerFee": "200000000000000",
|
||||||
"ecSignature": {
|
"takerFee": "100000000000000",
|
||||||
"v": 27,
|
"expirationTimeSeconds": "1532560590",
|
||||||
"r": "0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33",
|
"salt": "1532559225",
|
||||||
"s": "0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254"
|
"makerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
||||||
|
"takerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
||||||
|
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
||||||
|
"signature": "0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891"
|
||||||
|
},
|
||||||
|
"metaData": {}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,46 +1,58 @@
|
|||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
export const orderbookResponse = {
|
import { OrderbookResponse } from '../../../src/types';
|
||||||
bids: [
|
|
||||||
{
|
export const orderbookResponse: OrderbookResponse = {
|
||||||
maker: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
bids: {
|
||||||
taker: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
total: 325,
|
||||||
makerFee: new BigNumber('100000000000000'),
|
page: 2,
|
||||||
takerFee: new BigNumber('200000000000000'),
|
perPage: 100,
|
||||||
makerTokenAmount: new BigNumber('10000000000000000'),
|
records: [
|
||||||
takerTokenAmount: new BigNumber('20000000000000000'),
|
{
|
||||||
makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
order: {
|
||||||
takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990',
|
makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
||||||
salt: new BigNumber('256'),
|
takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
feeRecipient: '0xb046140686d052fff581f63f8136cce132e857da',
|
feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
|
||||||
exchangeContractAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
expirationUnixTimestampSec: new BigNumber('42'),
|
makerAssetAmount: new BigNumber('10000000000000000'),
|
||||||
ecSignature: {
|
takerAssetAmount: new BigNumber('20000000000000000'),
|
||||||
v: 27,
|
makerFee: new BigNumber('100000000000000'),
|
||||||
r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
takerFee: new BigNumber('200000000000000'),
|
||||||
s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
|
expirationTimeSeconds: new BigNumber('1532560590'),
|
||||||
|
salt: new BigNumber('1532559225'),
|
||||||
|
makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
||||||
|
takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
||||||
|
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
||||||
|
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
||||||
|
},
|
||||||
|
metaData: {},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
asks: [
|
asks: {
|
||||||
{
|
total: 500,
|
||||||
maker: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
page: 2,
|
||||||
taker: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
perPage: 100,
|
||||||
makerFee: new BigNumber('100000000000000'),
|
records: [
|
||||||
takerFee: new BigNumber('200000000000000'),
|
{
|
||||||
makerTokenAmount: new BigNumber('10000000000000000'),
|
order: {
|
||||||
takerTokenAmount: new BigNumber('20000000000000000'),
|
makerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
takerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
||||||
takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990',
|
feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
|
||||||
salt: new BigNumber('256'),
|
senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
feeRecipient: '0xb046140686d052fff581f63f8136cce132e857da',
|
makerAssetAmount: new BigNumber('20000000000000000'),
|
||||||
exchangeContractAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
takerAssetAmount: new BigNumber('10000000000000000'),
|
||||||
expirationUnixTimestampSec: new BigNumber('42'),
|
makerFee: new BigNumber('200000000000000'),
|
||||||
ecSignature: {
|
takerFee: new BigNumber('100000000000000'),
|
||||||
v: 27,
|
expirationTimeSeconds: new BigNumber('1532560590'),
|
||||||
r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
salt: new BigNumber('1532559225'),
|
||||||
s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
|
makerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
||||||
|
takerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
||||||
|
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
||||||
|
signature: '0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891',
|
||||||
|
},
|
||||||
|
metaData: {},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
};
|
};
|
||||||
|
@@ -1,21 +1,26 @@
|
|||||||
[
|
{
|
||||||
{
|
"total": 984,
|
||||||
"maker": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
|
"page": 1,
|
||||||
"taker": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
"perPage": 100,
|
||||||
"makerFee": "100000000000000",
|
"records": [
|
||||||
"takerFee": "200000000000000",
|
{
|
||||||
"makerTokenAmount": "10000000000000000",
|
"order": {
|
||||||
"takerTokenAmount": "20000000000000000",
|
"makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
|
||||||
"makerTokenAddress": "0x323b5d4c32345ced77393b3530b1eed0f346429d",
|
"takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
||||||
"takerTokenAddress": "0xef7fff64389b814a946f3e92105513705ca6b990",
|
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
|
||||||
"salt": "256",
|
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
|
||||||
"feeRecipient": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
|
"makerAssetAmount": "10000000000000000",
|
||||||
"exchangeContractAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
|
"takerAssetAmount": "20000000000000000",
|
||||||
"expirationUnixTimestampSec": "42",
|
"makerFee": "100000000000000",
|
||||||
"ecSignature": {
|
"takerFee": "200000000000000",
|
||||||
"v": 27,
|
"expirationTimeSeconds": "1532560590",
|
||||||
"r": "0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33",
|
"salt": "1532559225",
|
||||||
"s": "0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254"
|
"makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
|
||||||
|
"takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
|
||||||
|
"exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
|
||||||
|
"signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
|
||||||
|
},
|
||||||
|
"metaData": {}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
|
@@ -1,23 +1,30 @@
|
|||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
export const ordersResponse = [
|
import { OrdersResponse } from '../../../src/types';
|
||||||
{
|
|
||||||
maker: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
export const ordersResponse: OrdersResponse = {
|
||||||
taker: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
total: 984,
|
||||||
makerFee: new BigNumber('100000000000000'),
|
page: 1,
|
||||||
takerFee: new BigNumber('200000000000000'),
|
perPage: 100,
|
||||||
makerTokenAmount: new BigNumber('10000000000000000'),
|
records: [
|
||||||
takerTokenAmount: new BigNumber('20000000000000000'),
|
{
|
||||||
makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
order: {
|
||||||
takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990',
|
makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
||||||
salt: new BigNumber('256'),
|
takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
feeRecipient: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
|
||||||
exchangeContractAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
expirationUnixTimestampSec: new BigNumber('42'),
|
makerAssetAmount: new BigNumber('10000000000000000'),
|
||||||
ecSignature: {
|
takerAssetAmount: new BigNumber('20000000000000000'),
|
||||||
v: 27,
|
makerFee: new BigNumber('100000000000000'),
|
||||||
r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
takerFee: new BigNumber('200000000000000'),
|
||||||
s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
|
expirationTimeSeconds: new BigNumber('1532560590'),
|
||||||
|
salt: new BigNumber('1532559225'),
|
||||||
|
makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
||||||
|
takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
||||||
|
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
||||||
|
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
||||||
|
},
|
||||||
|
metaData: {},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
];
|
};
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
import * as orderbookJSON from './orderbook.json';
|
|
||||||
|
|
||||||
const orderbookJsonString = JSON.stringify(orderbookJSON);
|
|
||||||
|
|
||||||
export const snapshotOrderbookChannelMessage = `{
|
|
||||||
"type": "snapshot",
|
|
||||||
"channel": "orderbook",
|
|
||||||
"requestId": 1,
|
|
||||||
"payload": ${orderbookJsonString}
|
|
||||||
}`;
|
|
||||||
|
|
||||||
export const malformedSnapshotOrderbookChannelMessage = `{
|
|
||||||
"type": "snapshot",
|
|
||||||
"channel": "orderbook",
|
|
||||||
"requestId": 1,
|
|
||||||
"payload": {}
|
|
||||||
}`;
|
|
@@ -1,16 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"tokenA": {
|
|
||||||
"address": "0x323b5d4c32345ced77393b3530b1eed0f346429d",
|
|
||||||
"minAmount": "0",
|
|
||||||
"maxAmount": "10000000000000000000",
|
|
||||||
"precision": 5
|
|
||||||
},
|
|
||||||
"tokenB": {
|
|
||||||
"address": "0xef7fff64389b814a946f3e92105513705ca6b990",
|
|
||||||
"minAmount": "0",
|
|
||||||
"maxAmount": "50000000000000000000",
|
|
||||||
"precision": 5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
@@ -1,20 +0,0 @@
|
|||||||
import { BigNumber } from '@0xproject/utils';
|
|
||||||
|
|
||||||
import { TokenPairsItem } from '../../../src/types';
|
|
||||||
|
|
||||||
export const tokenPairsResponse: TokenPairsItem[] = [
|
|
||||||
{
|
|
||||||
tokenA: {
|
|
||||||
address: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
|
||||||
minAmount: new BigNumber(0),
|
|
||||||
maxAmount: new BigNumber('10000000000000000000'),
|
|
||||||
precision: 5,
|
|
||||||
},
|
|
||||||
tokenB: {
|
|
||||||
address: '0xef7fff64389b814a946f3e92105513705ca6b990',
|
|
||||||
minAmount: new BigNumber(0),
|
|
||||||
maxAmount: new BigNumber('50000000000000000000'),
|
|
||||||
precision: 5,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
@@ -2,9 +2,9 @@ import * as orderResponseJSON from './order/0xabc67323774bdbd24d94f977fa9ac94a50
|
|||||||
|
|
||||||
const orderJSONString = JSON.stringify(orderResponseJSON);
|
const orderJSONString = JSON.stringify(orderResponseJSON);
|
||||||
|
|
||||||
export const unknownOrderbookChannelMessage = `{
|
export const unknownOrdersChannelMessage = `{
|
||||||
"type": "superGoodUpdate",
|
"type": "superGoodUpdate",
|
||||||
"channel": "orderbook",
|
"channel": "orderbook",
|
||||||
"requestId": 1,
|
"requestId": "6ce8c5a6-5c46-4027-a44a-51831c77b8a1",
|
||||||
"payload": ${orderJSONString}
|
"payload": [${orderJSONString}]
|
||||||
}`;
|
}`;
|
@@ -1,17 +0,0 @@
|
|||||||
import * as orderResponseJSON from './order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json';
|
|
||||||
|
|
||||||
const orderJSONString = JSON.stringify(orderResponseJSON);
|
|
||||||
|
|
||||||
export const updateOrderbookChannelMessage = `{
|
|
||||||
"type": "update",
|
|
||||||
"channel": "orderbook",
|
|
||||||
"requestId": 1,
|
|
||||||
"payload": ${orderJSONString}
|
|
||||||
}`;
|
|
||||||
|
|
||||||
export const malformedUpdateOrderbookChannelMessage = `{
|
|
||||||
"type": "update",
|
|
||||||
"channel": "orderbook",
|
|
||||||
"requestId": 1,
|
|
||||||
"payload": {}
|
|
||||||
}`;
|
|
17
packages/connect/test/fixtures/standard_relayer_api/update_orders_channel_message.ts
vendored
Normal file
17
packages/connect/test/fixtures/standard_relayer_api/update_orders_channel_message.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import * as apiOrderJSON from './order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json';
|
||||||
|
|
||||||
|
const apiOrderJSONString = JSON.stringify(apiOrderJSON);
|
||||||
|
|
||||||
|
export const updateOrdersChannelMessage = `{
|
||||||
|
"type": "update",
|
||||||
|
"channel": "orders",
|
||||||
|
"requestId": "5a1ce3a2-22b9-41e6-a615-68077512e9e2",
|
||||||
|
"payload": [${apiOrderJSONString}]
|
||||||
|
}`;
|
||||||
|
|
||||||
|
export const malformedUpdateOrdersChannelMessage = `{
|
||||||
|
"type": "update",
|
||||||
|
"channel": "orders",
|
||||||
|
"requestId": "4d8efcee-adde-4475-9601-f0b30962ca2b",
|
||||||
|
"payload": {}
|
||||||
|
}`;
|
@@ -1,4 +1,3 @@
|
|||||||
import { BigNumber } from '@0xproject/utils';
|
|
||||||
import * as chai from 'chai';
|
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';
|
||||||
@@ -7,16 +6,18 @@ import 'mocha';
|
|||||||
|
|
||||||
import { HttpClient } from '../src/index';
|
import { HttpClient } from '../src/index';
|
||||||
|
|
||||||
import { feesResponse } from './fixtures/standard_relayer_api/fees';
|
import { assetDataPairsResponse } from './fixtures/standard_relayer_api/asset_pairs';
|
||||||
import * as feesResponseJSON from './fixtures/standard_relayer_api/fees.json';
|
import * as assetDataPairsResponseJSON from './fixtures/standard_relayer_api/asset_pairs.json';
|
||||||
|
import { feeRecipientsResponse } from './fixtures/standard_relayer_api/fee_recipients';
|
||||||
|
import * as feeRecipientsResponseJSON from './fixtures/standard_relayer_api/fee_recipients.json';
|
||||||
import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
|
import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
|
||||||
import * as orderResponseJSON from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json';
|
import * as orderResponseJSON from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json';
|
||||||
|
import { orderConfigResponse } from './fixtures/standard_relayer_api/order_config';
|
||||||
|
import * as orderConfigResponseJSON from './fixtures/standard_relayer_api/order_config.json';
|
||||||
import { orderbookResponse } from './fixtures/standard_relayer_api/orderbook';
|
import { orderbookResponse } from './fixtures/standard_relayer_api/orderbook';
|
||||||
import * as orderbookJSON from './fixtures/standard_relayer_api/orderbook.json';
|
import * as orderbookJSON from './fixtures/standard_relayer_api/orderbook.json';
|
||||||
import { ordersResponse } from './fixtures/standard_relayer_api/orders';
|
import { ordersResponse } from './fixtures/standard_relayer_api/orders';
|
||||||
import * as ordersResponseJSON from './fixtures/standard_relayer_api/orders.json';
|
import * as ordersResponseJSON from './fixtures/standard_relayer_api/orders.json';
|
||||||
import { tokenPairsResponse } from './fixtures/standard_relayer_api/token_pairs';
|
|
||||||
import * as tokenPairsResponseJSON from './fixtures/standard_relayer_api/token_pairs.json';
|
|
||||||
|
|
||||||
chai.config.includeStack = true;
|
chai.config.includeStack = true;
|
||||||
chai.use(dirtyChai);
|
chai.use(dirtyChai);
|
||||||
@@ -26,7 +27,7 @@ const expect = chai.expect;
|
|||||||
describe('HttpClient', () => {
|
describe('HttpClient', () => {
|
||||||
const relayUrl = 'https://example.com';
|
const relayUrl = 'https://example.com';
|
||||||
const relayerClient = new HttpClient(relayUrl);
|
const relayerClient = new HttpClient(relayUrl);
|
||||||
afterEach(() => {
|
beforeEach(() => {
|
||||||
fetchMock.restore();
|
fetchMock.restore();
|
||||||
});
|
});
|
||||||
describe('#constructor', () => {
|
describe('#constructor', () => {
|
||||||
@@ -38,47 +39,47 @@ describe('HttpClient', () => {
|
|||||||
expect(sanitizedUrl).to.be.deep.equal(urlWithoutTrailingSlash);
|
expect(sanitizedUrl).to.be.deep.equal(urlWithoutTrailingSlash);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('#getTokenPairsAsync', () => {
|
describe('#getAssetPairsAsync', () => {
|
||||||
const url = `${relayUrl}/token_pairs`;
|
const url = `${relayUrl}/asset_pairs`;
|
||||||
it('gets token pairs with default options when none are provided', async () => {
|
it('gets assetData pairs with default options when none are provided', async () => {
|
||||||
const urlWithQuery = `${url}?page=1&per_page=100`;
|
fetchMock.get(url, assetDataPairsResponseJSON);
|
||||||
fetchMock.get(urlWithQuery, tokenPairsResponseJSON);
|
const assetDataPairs = await relayerClient.getAssetPairsAsync();
|
||||||
const tokenPairs = await relayerClient.getTokenPairsAsync();
|
expect(assetDataPairs).to.be.deep.equal(assetDataPairsResponse);
|
||||||
expect(tokenPairs).to.be.deep.equal(tokenPairsResponse);
|
|
||||||
});
|
});
|
||||||
it('gets token pairs with specified request options', async () => {
|
it('gets assetData pairs with specified request options', async () => {
|
||||||
const tokenAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
|
const assetData = '0xf47261b04c32345ced77393b3530b1eed0f346429d';
|
||||||
const tokenPairsRequestOpts = {
|
const assetPairsRequestOpts = {
|
||||||
tokenA: tokenAddress,
|
assetDataA: assetData,
|
||||||
page: 3,
|
page: 3,
|
||||||
perPage: 50,
|
perPage: 50,
|
||||||
|
networkdId: 42,
|
||||||
};
|
};
|
||||||
const urlWithQuery = `${url}?page=3&per_page=50&tokenA=${tokenAddress}`;
|
const urlWithQuery = `${url}?assetDataA=${assetData}&networkdId=42&page=3&perPage=50`;
|
||||||
fetchMock.get(urlWithQuery, tokenPairsResponseJSON);
|
fetchMock.get(urlWithQuery, assetDataPairsResponseJSON);
|
||||||
const tokenPairs = await relayerClient.getTokenPairsAsync(tokenPairsRequestOpts);
|
const assetDataPairs = await relayerClient.getAssetPairsAsync(assetPairsRequestOpts);
|
||||||
expect(tokenPairs).to.be.deep.equal(tokenPairsResponse);
|
expect(assetDataPairs).to.be.deep.equal(assetDataPairsResponse);
|
||||||
});
|
});
|
||||||
it('throws an error for invalid JSON response', async () => {
|
it('throws an error for invalid JSON response', async () => {
|
||||||
fetchMock.get(url, { test: 'dummy' });
|
fetchMock.get(url, { test: 'dummy' });
|
||||||
expect(relayerClient.getTokenPairsAsync()).to.be.rejected();
|
expect(relayerClient.getAssetPairsAsync()).to.be.rejected();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('#getOrdersAsync', () => {
|
describe('#getOrdersAsync', () => {
|
||||||
const url = `${relayUrl}/orders`;
|
const url = `${relayUrl}/orders`;
|
||||||
it('gets orders with default options when none are provided', async () => {
|
it('gets orders with default options when none are provided', async () => {
|
||||||
const urlWithQuery = `${url}?page=1&per_page=100`;
|
fetchMock.get(url, ordersResponseJSON);
|
||||||
fetchMock.get(urlWithQuery, ordersResponseJSON);
|
|
||||||
const orders = await relayerClient.getOrdersAsync();
|
const orders = await relayerClient.getOrdersAsync();
|
||||||
expect(orders).to.be.deep.equal(ordersResponse);
|
expect(orders).to.be.deep.equal(ordersResponse);
|
||||||
});
|
});
|
||||||
it('gets orders with specified request options', async () => {
|
it('gets orders with specified request options', async () => {
|
||||||
const tokenAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
|
const assetDataAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
|
||||||
const ordersRequest = {
|
const ordersRequest = {
|
||||||
tokenAddress,
|
assetDataAddress,
|
||||||
page: 3,
|
page: 3,
|
||||||
perPage: 50,
|
perPage: 50,
|
||||||
|
networkdId: 42,
|
||||||
};
|
};
|
||||||
const urlWithQuery = `${url}?page=3&per_page=50&tokenAddress=${tokenAddress}`;
|
const urlWithQuery = `${url}?assetDataAddress=${assetDataAddress}&networkdId=42&page=3&perPage=50`;
|
||||||
fetchMock.get(urlWithQuery, ordersResponseJSON);
|
fetchMock.get(urlWithQuery, ordersResponseJSON);
|
||||||
const orders = await relayerClient.getOrdersAsync(ordersRequest);
|
const orders = await relayerClient.getOrdersAsync(ordersRequest);
|
||||||
expect(orders).to.be.deep.equal(ordersResponse);
|
expect(orders).to.be.deep.equal(ordersResponse);
|
||||||
@@ -103,26 +104,27 @@ describe('HttpClient', () => {
|
|||||||
});
|
});
|
||||||
describe('#getOrderBookAsync', () => {
|
describe('#getOrderBookAsync', () => {
|
||||||
const request = {
|
const request = {
|
||||||
baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
baseAssetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
||||||
quoteTokenAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
quoteAssetData: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
};
|
};
|
||||||
const url = `${relayUrl}/orderbook`;
|
const url = `${relayUrl}/orderbook`;
|
||||||
it('gets orderbook with default page options when none are provided', async () => {
|
it('gets orderbook with default page options when none are provided', async () => {
|
||||||
const urlWithQuery = `${url}?baseTokenAddress=${
|
const urlWithQuery = `${url}?baseAssetData=${request.baseAssetData}"eAssetData=${
|
||||||
request.baseTokenAddress
|
request.quoteAssetData
|
||||||
}&page=1&per_page=100"eTokenAddress=${request.quoteTokenAddress}`;
|
}`;
|
||||||
fetchMock.get(urlWithQuery, orderbookJSON);
|
fetchMock.get(urlWithQuery, orderbookJSON);
|
||||||
const orderbook = await relayerClient.getOrderbookAsync(request);
|
const orderbook = await relayerClient.getOrderbookAsync(request);
|
||||||
expect(orderbook).to.be.deep.equal(orderbookResponse);
|
expect(orderbook).to.be.deep.equal(orderbookResponse);
|
||||||
});
|
});
|
||||||
it('gets orderbook with specified page options', async () => {
|
it('gets orderbook with specified page options', async () => {
|
||||||
const urlWithQuery = `${url}?baseTokenAddress=${
|
const urlWithQuery = `${url}?baseAssetData=${
|
||||||
request.baseTokenAddress
|
request.baseAssetData
|
||||||
}&page=3&per_page=50"eTokenAddress=${request.quoteTokenAddress}`;
|
}&networkId=42&page=3&perPage=50"eAssetData=${request.quoteAssetData}`;
|
||||||
fetchMock.get(urlWithQuery, orderbookJSON);
|
fetchMock.get(urlWithQuery, orderbookJSON);
|
||||||
const pagedRequestOptions = {
|
const pagedRequestOptions = {
|
||||||
page: 3,
|
page: 3,
|
||||||
perPage: 50,
|
perPage: 50,
|
||||||
|
networkId: 42,
|
||||||
};
|
};
|
||||||
const orderbook = await relayerClient.getOrderbookAsync(request, pagedRequestOptions);
|
const orderbook = await relayerClient.getOrderbookAsync(request, pagedRequestOptions);
|
||||||
expect(orderbook).to.be.deep.equal(orderbookResponse);
|
expect(orderbook).to.be.deep.equal(orderbookResponse);
|
||||||
@@ -132,39 +134,59 @@ describe('HttpClient', () => {
|
|||||||
expect(relayerClient.getOrderbookAsync(request)).to.be.rejected();
|
expect(relayerClient.getOrderbookAsync(request)).to.be.rejected();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('#getFeesAsync', () => {
|
describe('#getOrderConfigAsync', () => {
|
||||||
const request = {
|
const request = {
|
||||||
exchangeContractAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
||||||
maker: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
|
takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
taker: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
makerAssetAmount: '10000000000000000',
|
||||||
makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
takerAssetAmount: '20000000000000000',
|
||||||
takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990',
|
expirationTimeSeconds: '1532560590',
|
||||||
makerTokenAmount: new BigNumber('10000000000000000000'),
|
makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
|
||||||
takerTokenAmount: new BigNumber('30000000000000000000'),
|
takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
|
||||||
salt: new BigNumber('256'),
|
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
|
||||||
expirationUnixTimestampSec: new BigNumber('42'),
|
|
||||||
};
|
};
|
||||||
const url = `${relayUrl}/fees`;
|
const url = `${relayUrl}/order_config`;
|
||||||
it('gets fees', async () => {
|
it('gets order config', async () => {
|
||||||
fetchMock.post(url, feesResponseJSON);
|
fetchMock.post(url, orderConfigResponseJSON);
|
||||||
const fees = await relayerClient.getFeesAsync(request);
|
const fees = await relayerClient.getOrderConfigAsync(request);
|
||||||
expect(fees).to.be.deep.equal(feesResponse);
|
expect(fees).to.be.deep.equal(orderConfigResponse);
|
||||||
});
|
});
|
||||||
it('does not mutate input', async () => {
|
it('does not mutate input', async () => {
|
||||||
fetchMock.post(url, feesResponseJSON);
|
fetchMock.post(url, orderConfigResponseJSON);
|
||||||
const makerTokenAmountBefore = new BigNumber(request.makerTokenAmount);
|
const makerAssetAmountBefore = request.makerAssetAmount;
|
||||||
const takerTokenAmountBefore = new BigNumber(request.takerTokenAmount);
|
const takerAssetAmountBefore = request.takerAssetAmount;
|
||||||
const saltBefore = new BigNumber(request.salt);
|
const expirationTimeSecondsBefore = request.expirationTimeSeconds;
|
||||||
const expirationUnixTimestampSecBefore = new BigNumber(request.expirationUnixTimestampSec);
|
await relayerClient.getOrderConfigAsync(request);
|
||||||
await relayerClient.getFeesAsync(request);
|
expect(makerAssetAmountBefore).to.be.deep.equal(request.makerAssetAmount);
|
||||||
expect(makerTokenAmountBefore).to.be.deep.equal(request.makerTokenAmount);
|
expect(takerAssetAmountBefore).to.be.deep.equal(request.takerAssetAmount);
|
||||||
expect(takerTokenAmountBefore).to.be.deep.equal(request.takerTokenAmount);
|
expect(expirationTimeSecondsBefore).to.be.deep.equal(request.expirationTimeSeconds);
|
||||||
expect(saltBefore).to.be.deep.equal(request.salt);
|
|
||||||
expect(expirationUnixTimestampSecBefore).to.be.deep.equal(request.expirationUnixTimestampSec);
|
|
||||||
});
|
});
|
||||||
it('throws an error for invalid JSON response', async () => {
|
it('throws an error for invalid JSON response', async () => {
|
||||||
fetchMock.post(url, { test: 'dummy' });
|
fetchMock.post(url, { test: 'dummy' });
|
||||||
expect(relayerClient.getFeesAsync(request)).to.be.rejected();
|
expect(relayerClient.getOrderConfigAsync(request)).to.be.rejected();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('#getFeeRecipientsAsync', () => {
|
||||||
|
const url = `${relayUrl}/fee_recipients`;
|
||||||
|
it('gets fee recipients with default page options when none are provided', async () => {
|
||||||
|
fetchMock.get(url, feeRecipientsResponseJSON);
|
||||||
|
const feeRecipients = await relayerClient.getFeeRecipientsAsync();
|
||||||
|
expect(feeRecipients).to.be.deep.equal(feeRecipientsResponse);
|
||||||
|
});
|
||||||
|
it('gets fee recipient with specified page options', async () => {
|
||||||
|
const urlWithQuery = `${url}?networkId=42&page=3&perPage=50`;
|
||||||
|
fetchMock.get(urlWithQuery, feeRecipientsResponseJSON);
|
||||||
|
const pagedRequestOptions = {
|
||||||
|
page: 3,
|
||||||
|
perPage: 50,
|
||||||
|
networkId: 42,
|
||||||
|
};
|
||||||
|
const feeRecipients = await relayerClient.getFeeRecipientsAsync(pagedRequestOptions);
|
||||||
|
expect(feeRecipients).to.be.deep.equal(feeRecipientsResponse);
|
||||||
|
});
|
||||||
|
it('throws an error for invalid JSON response', async () => {
|
||||||
|
fetchMock.get(url, { test: 'dummy' });
|
||||||
|
expect(relayerClient.getFeeRecipientsAsync()).to.be.rejected();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,45 +0,0 @@
|
|||||||
import * as chai from 'chai';
|
|
||||||
import * as dirtyChai from 'dirty-chai';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
import 'mocha';
|
|
||||||
|
|
||||||
import { orderbookChannelFactory } from '../src/orderbook_channel_factory';
|
|
||||||
|
|
||||||
chai.config.includeStack = true;
|
|
||||||
chai.use(dirtyChai);
|
|
||||||
const expect = chai.expect;
|
|
||||||
const emptyOrderbookChannelHandler = {
|
|
||||||
onSnapshot: () => {
|
|
||||||
_.noop();
|
|
||||||
},
|
|
||||||
onUpdate: () => {
|
|
||||||
_.noop();
|
|
||||||
},
|
|
||||||
onError: () => {
|
|
||||||
_.noop();
|
|
||||||
},
|
|
||||||
onClose: () => {
|
|
||||||
_.noop();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('orderbookChannelFactory', () => {
|
|
||||||
const websocketUrl = 'ws://localhost:8080';
|
|
||||||
describe('#createWebSocketOrderbookChannelAsync', () => {
|
|
||||||
it('throws when input is not a url', () => {
|
|
||||||
const badUrlInput = 54;
|
|
||||||
expect(
|
|
||||||
orderbookChannelFactory.createWebSocketOrderbookChannelAsync(
|
|
||||||
badUrlInput as any,
|
|
||||||
emptyOrderbookChannelHandler,
|
|
||||||
),
|
|
||||||
).to.be.rejected();
|
|
||||||
});
|
|
||||||
it('throws when handler has the incorrect members', () => {
|
|
||||||
const badHandlerInput = {};
|
|
||||||
expect(
|
|
||||||
orderbookChannelFactory.createWebSocketOrderbookChannelAsync(websocketUrl, badHandlerInput as any),
|
|
||||||
).to.be.rejected();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,76 +0,0 @@
|
|||||||
import * as chai from 'chai';
|
|
||||||
import * as dirtyChai from 'dirty-chai';
|
|
||||||
import 'mocha';
|
|
||||||
|
|
||||||
import { orderbookChannelMessageParser } from '../src/utils/orderbook_channel_message_parser';
|
|
||||||
|
|
||||||
import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
|
|
||||||
import { orderbookResponse } from './fixtures/standard_relayer_api/orderbook';
|
|
||||||
import {
|
|
||||||
malformedSnapshotOrderbookChannelMessage,
|
|
||||||
snapshotOrderbookChannelMessage,
|
|
||||||
} from './fixtures/standard_relayer_api/snapshot_orderbook_channel_message';
|
|
||||||
import { unknownOrderbookChannelMessage } from './fixtures/standard_relayer_api/unknown_orderbook_channel_message';
|
|
||||||
import {
|
|
||||||
malformedUpdateOrderbookChannelMessage,
|
|
||||||
updateOrderbookChannelMessage,
|
|
||||||
} from './fixtures/standard_relayer_api/update_orderbook_channel_message';
|
|
||||||
|
|
||||||
chai.config.includeStack = true;
|
|
||||||
chai.use(dirtyChai);
|
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
describe('orderbookChannelMessageParser', () => {
|
|
||||||
describe('#parser', () => {
|
|
||||||
it('parses snapshot messages', () => {
|
|
||||||
const snapshotMessage = orderbookChannelMessageParser.parse(snapshotOrderbookChannelMessage);
|
|
||||||
expect(snapshotMessage.type).to.be.equal('snapshot');
|
|
||||||
expect(snapshotMessage.payload).to.be.deep.equal(orderbookResponse);
|
|
||||||
});
|
|
||||||
it('parses update messages', () => {
|
|
||||||
const updateMessage = orderbookChannelMessageParser.parse(updateOrderbookChannelMessage);
|
|
||||||
expect(updateMessage.type).to.be.equal('update');
|
|
||||||
expect(updateMessage.payload).to.be.deep.equal(orderResponse);
|
|
||||||
});
|
|
||||||
it('returns unknown message for messages with unsupported types', () => {
|
|
||||||
const unknownMessage = orderbookChannelMessageParser.parse(unknownOrderbookChannelMessage);
|
|
||||||
expect(unknownMessage.type).to.be.equal('unknown');
|
|
||||||
expect(unknownMessage.payload).to.be.undefined();
|
|
||||||
});
|
|
||||||
it('throws when message does not include a type', () => {
|
|
||||||
const typelessMessage = `{
|
|
||||||
"channel": "orderbook",
|
|
||||||
"requestId": 1,
|
|
||||||
"payload": {}
|
|
||||||
}`;
|
|
||||||
const badCall = () => orderbookChannelMessageParser.parse(typelessMessage);
|
|
||||||
expect(badCall).throws(`Message is missing a type parameter: ${typelessMessage}`);
|
|
||||||
});
|
|
||||||
it('throws when type is not a string', () => {
|
|
||||||
const messageWithBadType = `{
|
|
||||||
"type": 1,
|
|
||||||
"channel": "orderbook",
|
|
||||||
"requestId": 1,
|
|
||||||
"payload": {}
|
|
||||||
}`;
|
|
||||||
const badCall = () => orderbookChannelMessageParser.parse(messageWithBadType);
|
|
||||||
expect(badCall).throws('Expected type to be of type string, encountered: 1');
|
|
||||||
});
|
|
||||||
it('throws when snapshot message has malformed payload', () => {
|
|
||||||
const badCall = () => orderbookChannelMessageParser.parse(malformedSnapshotOrderbookChannelMessage);
|
|
||||||
// tslint:disable-next-line:max-line-length
|
|
||||||
const errMsg =
|
|
||||||
'Validation errors: instance.payload requires property "bids", instance.payload requires property "asks"';
|
|
||||||
expect(badCall).throws(errMsg);
|
|
||||||
});
|
|
||||||
it('throws when update message has malformed payload', () => {
|
|
||||||
const badCall = () => orderbookChannelMessageParser.parse(malformedUpdateOrderbookChannelMessage);
|
|
||||||
expect(badCall).throws(/^Expected message to conform to schema/);
|
|
||||||
});
|
|
||||||
it('throws when input message is not valid JSON', () => {
|
|
||||||
const nonJsonString = 'h93b{sdfs9fsd f';
|
|
||||||
const badCall = () => orderbookChannelMessageParser.parse(nonJsonString);
|
|
||||||
expect(badCall).throws('Unexpected token h in JSON at position 0');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
34
packages/connect/test/orders_channel_factory_test.ts
Normal file
34
packages/connect/test/orders_channel_factory_test.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import * as chai from 'chai';
|
||||||
|
import * as dirtyChai from 'dirty-chai';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
import 'mocha';
|
||||||
|
|
||||||
|
import { ordersChannelFactory } from '../src/orders_channel_factory';
|
||||||
|
|
||||||
|
chai.config.includeStack = true;
|
||||||
|
chai.use(dirtyChai);
|
||||||
|
const expect = chai.expect;
|
||||||
|
const emptyOrdersChannelHandler = {
|
||||||
|
onUpdate: _.noop.bind(_),
|
||||||
|
onError: _.noop.bind(_),
|
||||||
|
onClose: _.noop.bind(_),
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('ordersChannelFactory', () => {
|
||||||
|
const websocketUrl = 'ws://localhost:8080';
|
||||||
|
describe('#createWebSocketOrdersChannelAsync', () => {
|
||||||
|
it('throws when input is not a url', () => {
|
||||||
|
const badUrlInput = 54;
|
||||||
|
expect(
|
||||||
|
ordersChannelFactory.createWebSocketOrdersChannelAsync(badUrlInput as any, emptyOrdersChannelHandler),
|
||||||
|
).to.be.rejected();
|
||||||
|
});
|
||||||
|
it('throws when handler has the incorrect members', () => {
|
||||||
|
const badHandlerInput = {};
|
||||||
|
expect(
|
||||||
|
ordersChannelFactory.createWebSocketOrdersChannelAsync(websocketUrl, badHandlerInput as any),
|
||||||
|
).to.be.rejected();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
59
packages/connect/test/orders_channel_message_parsers_test.ts
Normal file
59
packages/connect/test/orders_channel_message_parsers_test.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import * as chai from 'chai';
|
||||||
|
import * as dirtyChai from 'dirty-chai';
|
||||||
|
import 'mocha';
|
||||||
|
|
||||||
|
import { ordersChannelMessageParser } from '../src/utils/orders_channel_message_parser';
|
||||||
|
|
||||||
|
import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
|
||||||
|
import { unknownOrdersChannelMessage } from './fixtures/standard_relayer_api/unknown_orders_channel_message';
|
||||||
|
import {
|
||||||
|
malformedUpdateOrdersChannelMessage,
|
||||||
|
updateOrdersChannelMessage,
|
||||||
|
} from './fixtures/standard_relayer_api/update_orders_channel_message';
|
||||||
|
|
||||||
|
chai.config.includeStack = true;
|
||||||
|
chai.use(dirtyChai);
|
||||||
|
const expect = chai.expect;
|
||||||
|
|
||||||
|
describe('ordersChannelMessageParser', () => {
|
||||||
|
describe('#parser', () => {
|
||||||
|
it('parses update messages', () => {
|
||||||
|
const updateMessage = ordersChannelMessageParser.parse(updateOrdersChannelMessage);
|
||||||
|
expect(updateMessage.type).to.be.equal('update');
|
||||||
|
expect(updateMessage.payload).to.be.deep.equal([orderResponse]);
|
||||||
|
});
|
||||||
|
it('returns unknown message for messages with unsupported types', () => {
|
||||||
|
const unknownMessage = ordersChannelMessageParser.parse(unknownOrdersChannelMessage);
|
||||||
|
expect(unknownMessage.type).to.be.equal('unknown');
|
||||||
|
expect(unknownMessage.payload).to.be.undefined();
|
||||||
|
});
|
||||||
|
it('throws when message does not include a type', () => {
|
||||||
|
const typelessMessage = `{
|
||||||
|
"channel": "orders",
|
||||||
|
"requestId": "4d8efcee-adde-4475-9601-f0b30962ca2b",
|
||||||
|
"payload": []
|
||||||
|
}`;
|
||||||
|
const badCall = () => ordersChannelMessageParser.parse(typelessMessage);
|
||||||
|
expect(badCall).throws(`Message is missing a type parameter: ${typelessMessage}`);
|
||||||
|
});
|
||||||
|
it('throws when type is not a string', () => {
|
||||||
|
const messageWithBadType = `{
|
||||||
|
"type": 1,
|
||||||
|
"channel": "orders",
|
||||||
|
"requestId": "4d8efcee-adde-4475-9601-f0b30962ca2b",
|
||||||
|
"payload": []
|
||||||
|
}`;
|
||||||
|
const badCall = () => ordersChannelMessageParser.parse(messageWithBadType);
|
||||||
|
expect(badCall).throws('Expected type to be of type string, encountered: 1');
|
||||||
|
});
|
||||||
|
it('throws when update message has malformed payload', () => {
|
||||||
|
const badCall = () => ordersChannelMessageParser.parse(malformedUpdateOrdersChannelMessage);
|
||||||
|
expect(badCall).throws(/^Expected message to conform to schema/);
|
||||||
|
});
|
||||||
|
it('throws when input message is not valid JSON', () => {
|
||||||
|
const nonJsonString = 'h93b{sdfs9fsd f';
|
||||||
|
const badCall = () => ordersChannelMessageParser.parse(nonJsonString);
|
||||||
|
expect(badCall).throws('Unexpected token h in JSON at position 0');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -1,59 +0,0 @@
|
|||||||
import * as chai from 'chai';
|
|
||||||
import * as dirtyChai from 'dirty-chai';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
import 'mocha';
|
|
||||||
import * as Sinon from 'sinon';
|
|
||||||
import * as WebSocket from 'websocket';
|
|
||||||
|
|
||||||
import { WebSocketOrderbookChannel } from '../src/ws_orderbook_channel';
|
|
||||||
|
|
||||||
chai.config.includeStack = true;
|
|
||||||
chai.use(dirtyChai);
|
|
||||||
const expect = chai.expect;
|
|
||||||
const emptyOrderbookChannelHandler = {
|
|
||||||
onSnapshot: () => {
|
|
||||||
_.noop();
|
|
||||||
},
|
|
||||||
onUpdate: () => {
|
|
||||||
_.noop();
|
|
||||||
},
|
|
||||||
onError: () => {
|
|
||||||
_.noop();
|
|
||||||
},
|
|
||||||
onClose: () => {
|
|
||||||
_.noop();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('WebSocketOrderbookChannel', () => {
|
|
||||||
const websocketUrl = 'ws://localhost:8080';
|
|
||||||
const openClient = new WebSocket.w3cwebsocket(websocketUrl);
|
|
||||||
Sinon.stub(openClient, 'readyState').get(() => WebSocket.w3cwebsocket.OPEN);
|
|
||||||
Sinon.stub(openClient, 'send').callsFake(_.noop.bind(_));
|
|
||||||
const openOrderbookChannel = new WebSocketOrderbookChannel(openClient, emptyOrderbookChannelHandler);
|
|
||||||
const subscriptionOpts = {
|
|
||||||
baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
|
||||||
quoteTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990',
|
|
||||||
snapshot: true,
|
|
||||||
limit: 100,
|
|
||||||
};
|
|
||||||
describe('#subscribe', () => {
|
|
||||||
it('throws when subscriptionOpts does not conform to schema', () => {
|
|
||||||
const badSubscribeCall = openOrderbookChannel.subscribe.bind(openOrderbookChannel, {});
|
|
||||||
expect(badSubscribeCall).throws(
|
|
||||||
'Expected subscriptionOpts to conform to schema /RelayerApiOrderbookChannelSubscribePayload\nEncountered: {}\nValidation errors: instance requires property "baseTokenAddress", instance requires property "quoteTokenAddress"',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('does not throw when inputs are of correct types', () => {
|
|
||||||
const goodSubscribeCall = openOrderbookChannel.subscribe.bind(openOrderbookChannel, subscriptionOpts);
|
|
||||||
expect(goodSubscribeCall).to.not.throw();
|
|
||||||
});
|
|
||||||
it('throws when client is closed', () => {
|
|
||||||
const closedClient = new WebSocket.w3cwebsocket(websocketUrl);
|
|
||||||
Sinon.stub(closedClient, 'readyState').get(() => WebSocket.w3cwebsocket.CLOSED);
|
|
||||||
const closedOrderbookChannel = new WebSocketOrderbookChannel(closedClient, emptyOrderbookChannelHandler);
|
|
||||||
const badSubscribeCall = closedOrderbookChannel.subscribe.bind(closedOrderbookChannel, subscriptionOpts);
|
|
||||||
expect(badSubscribeCall).throws('WebSocket connection is closed');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
49
packages/connect/test/ws_orders_channel_test.ts
Normal file
49
packages/connect/test/ws_orders_channel_test.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import * as chai from 'chai';
|
||||||
|
import * as dirtyChai from 'dirty-chai';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
import 'mocha';
|
||||||
|
import * as Sinon from 'sinon';
|
||||||
|
import * as WebSocket from 'websocket';
|
||||||
|
|
||||||
|
import { WebSocketOrdersChannel } from '../src/ws_orders_channel';
|
||||||
|
|
||||||
|
chai.config.includeStack = true;
|
||||||
|
chai.use(dirtyChai);
|
||||||
|
const expect = chai.expect;
|
||||||
|
const emptyOrdersChannelHandler = {
|
||||||
|
onUpdate: _.noop.bind(_),
|
||||||
|
onError: _.noop.bind(_),
|
||||||
|
onClose: _.noop.bind(_),
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('WebSocketOrdersChannel', () => {
|
||||||
|
const websocketUrl = 'ws://localhost:8080';
|
||||||
|
const openClient = new WebSocket.w3cwebsocket(websocketUrl);
|
||||||
|
Sinon.stub(openClient, 'readyState').get(() => WebSocket.w3cwebsocket.OPEN);
|
||||||
|
Sinon.stub(openClient, 'send').callsFake(_.noop.bind(_));
|
||||||
|
const openOrdersChannel = new WebSocketOrdersChannel(openClient, emptyOrdersChannelHandler);
|
||||||
|
const subscriptionOpts = {
|
||||||
|
baseAssetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
||||||
|
quoteAssetData: '0xef7fff64389b814a946f3e92105513705ca6b990',
|
||||||
|
limit: 100,
|
||||||
|
};
|
||||||
|
describe('#subscribe', () => {
|
||||||
|
it('throws when subscriptionOpts does not conform to schema', () => {
|
||||||
|
const badSubscribeCall = openOrdersChannel.subscribe.bind(openOrdersChannel, {
|
||||||
|
makerAssetData: 5,
|
||||||
|
});
|
||||||
|
expect(badSubscribeCall).throws();
|
||||||
|
});
|
||||||
|
it('does not throw when inputs are of correct types', () => {
|
||||||
|
const goodSubscribeCall = openOrdersChannel.subscribe.bind(openOrdersChannel, subscriptionOpts);
|
||||||
|
expect(goodSubscribeCall).to.not.throw();
|
||||||
|
});
|
||||||
|
it('throws when client is closed', () => {
|
||||||
|
const closedClient = new WebSocket.w3cwebsocket(websocketUrl);
|
||||||
|
Sinon.stub(closedClient, 'readyState').get(() => WebSocket.w3cwebsocket.CLOSED);
|
||||||
|
const closedOrdersChannel = new WebSocketOrdersChannel(closedClient, emptyOrdersChannelHandler);
|
||||||
|
const badSubscribeCall = closedOrdersChannel.subscribe.bind(closedOrdersChannel, subscriptionOpts);
|
||||||
|
expect(badSubscribeCall).throws('WebSocket connection is closed');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -1,4 +1,33 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "1.0.1-rc.5",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Fix missing `BlockParamLiteral` type import issue"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1535377027
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "1.0.1-rc.4",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Export missing types: `TransactionEncoder`, `ContractAbi`, `JSONRPCRequestPayload`, `JSONRPCResponsePayload`, `JSONRPCErrorCallback`, `AbiDefinition`, `FunctionAbi`, `EventAbi`, `EventParameter`, `DecodedLogArgs`, `MethodAbi`, `ConstructorAbi`, `FallbackAbi`, `DataItem`, `ConstructorStateMutability`, `StateMutability` & `ExchangeSignatureValidatorApprovalEventArgs`",
|
||||||
|
"pr": 924
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Remove superfluous exported types: `ContractEvent`, `Token`, `OrderFillRequest`, `ContractEventArgs`, `LogEvent`, `OnOrderStateChangeCallback`, `ECSignature`, `OrderStateValid`, `OrderStateInvalid`, `OrderState`, `FilterObject`, `TransactionReceipt` & `TransactionReceiptWithDecodedLogs`",
|
||||||
|
"pr": 924
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Added Transaction Encoder for use with 0x Exchange executeTransaction",
|
||||||
|
"pr": 975
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": 1535133899
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "1.0.1-rc.3",
|
"version": "1.0.1-rc.3",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@@ -5,7 +5,17 @@ Edit the package's CHANGELOG.json file only.
|
|||||||
|
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
## v1.0.1-rc.3 - _August 13, 2018_
|
## v1.0.1-rc.5 - _August 27, 2018_
|
||||||
|
|
||||||
|
* Fix missing `BlockParamLiteral` type import issue
|
||||||
|
|
||||||
|
## v1.0.1-rc.4 - _August 24, 2018_
|
||||||
|
|
||||||
|
* Export missing types: `TransactionEncoder`, `ContractAbi`, `JSONRPCRequestPayload`, `JSONRPCResponsePayload`, `JSONRPCErrorCallback`, `AbiDefinition`, `FunctionAbi`, `EventAbi`, `EventParameter`, `DecodedLogArgs`, `MethodAbi`, `ConstructorAbi`, `FallbackAbi`, `DataItem`, `ConstructorStateMutability`, `StateMutability` & `ExchangeSignatureValidatorApprovalEventArgs` (#924)
|
||||||
|
* Remove superfluous exported types: `ContractEvent`, `Token`, `OrderFillRequest`, `ContractEventArgs`, `LogEvent`, `OnOrderStateChangeCallback`, `ECSignature`, `OrderStateValid`, `OrderStateInvalid`, `OrderState`, `FilterObject`, `TransactionReceipt` & `TransactionReceiptWithDecodedLogs` (#924)
|
||||||
|
* Added Transaction Encoder for use with 0x Exchange executeTransaction (#975)
|
||||||
|
|
||||||
|
## v1.0.1-rc.3 - _August 14, 2018_
|
||||||
|
|
||||||
* Added strict encoding/decoding checks for sendTransaction and call (#915)
|
* Added strict encoding/decoding checks for sendTransaction and call (#915)
|
||||||
* Add ForwarderWrapper (#934)
|
* Add ForwarderWrapper (#934)
|
||||||
@@ -23,7 +33,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* Dependencies updated
|
* Dependencies updated
|
||||||
|
|
||||||
## v1.0.0-rc.1 - _July 19, 2018_
|
## v1.0.0-rc.1 - _July 20, 2018_
|
||||||
|
|
||||||
* Update blockstream to v5.0 and propogate up caught errors to active subscriptions (#815)
|
* Update blockstream to v5.0 and propogate up caught errors to active subscriptions (#815)
|
||||||
* Update to v2 of 0x rpotocol (#822)
|
* Update to v2 of 0x rpotocol (#822)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/contract-wrappers",
|
"name": "@0xproject/contract-wrappers",
|
||||||
"version": "1.0.1-rc.2",
|
"version": "1.0.1-rc.5",
|
||||||
"description": "Smart TS wrappers for 0x smart contracts",
|
"description": "Smart TS wrappers for 0x smart contracts",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"0xproject",
|
"0xproject",
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch_without_deps": "yarn pre_build && tsc -w",
|
"watch_without_deps": "yarn pre_build && tsc -w",
|
||||||
"build": "yarn pre_build && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
"build": "yarn pre_build && tsc",
|
||||||
"pre_build": "run-s update_artifacts_v2_beta update_artifacts_v2 generate_contract_wrappers copy_artifacts",
|
"pre_build": "run-s update_artifacts_v2_beta update_artifacts_v2 generate_contract_wrappers copy_artifacts",
|
||||||
"generate_contract_wrappers": "abi-gen --abis 'src/artifacts/@(Exchange|DummyERC20Token|DummyERC721Token|ZRXToken|ERC20Token|ERC721Token|WETH9|ERC20Proxy|ERC721Proxy|Forwarder).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers",
|
"generate_contract_wrappers": "abi-gen --abis 'src/artifacts/@(Exchange|DummyERC20Token|DummyERC721Token|ZRXToken|ERC20Token|ERC721Token|WETH9|ERC20Proxy|ERC721Proxy|Forwarder).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers",
|
||||||
"lint": "tslint --project . --exclude **/src/contract_wrappers/**/* --exclude **/lib/**/*",
|
"lint": "tslint --project . --exclude **/src/contract_wrappers/**/* --exclude **/lib/**/*",
|
||||||
@@ -24,13 +24,16 @@
|
|||||||
"update_artifacts_v2_beta": "for i in ${npm_package_config_contracts_v2_beta}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-beta-testnet/$i.json src/artifacts; done;",
|
"update_artifacts_v2_beta": "for i in ${npm_package_config_contracts_v2_beta}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-beta-testnet/$i.json src/artifacts; done;",
|
||||||
"update_artifacts_v2": "for i in ${npm_package_config_contracts_v2}; do copyfiles -u 4 ../migrations/artifacts/2.0.0/$i.json src/artifacts; done;",
|
"update_artifacts_v2": "for i in ${npm_package_config_contracts_v2}; do copyfiles -u 4 ../migrations/artifacts/2.0.0/$i.json src/artifacts; done;",
|
||||||
"copy_artifacts": "copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts",
|
"copy_artifacts": "copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts",
|
||||||
"clean": "shx rm -rf _bundles lib test_temp scripts test/artifacts src/contract_wrappers/generated src/artifacts",
|
"clean": "shx rm -rf _bundles lib test_temp test/artifacts src/contract_wrappers/generated src/artifacts generated_docs",
|
||||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
|
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
|
||||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"contracts_v2_beta": "Exchange ERC20Proxy ERC20Token ERC721Proxy ERC721Token WETH9 ZRXToken Forwarder",
|
"contracts_v2_beta": "AssetProxyOwner Exchange ERC20Proxy ERC20Token ERC721Proxy ERC721Token WETH9 ZRXToken Forwarder OrderValidator",
|
||||||
"contracts_v2": "DummyERC20Token DummyERC721Token"
|
"contracts_v2": "DummyERC20Token DummyERC721Token",
|
||||||
|
"postpublish": {
|
||||||
|
"assets": []
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -41,13 +44,11 @@
|
|||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/abi-gen": "^1.0.4",
|
"@0xproject/abi-gen": "^1.0.7",
|
||||||
"@0xproject/dev-utils": "^1.0.3",
|
"@0xproject/dev-utils": "^1.0.6",
|
||||||
"@0xproject/migrations": "^1.0.3",
|
"@0xproject/migrations": "^1.0.6",
|
||||||
"@0xproject/monorepo-scripts": "^1.0.4",
|
"@0xproject/subproviders": "^2.0.1",
|
||||||
"@0xproject/sol-compiler": "^1.0.4",
|
"@0xproject/tslint-config": "^1.0.6",
|
||||||
"@0xproject/subproviders": "^1.0.4",
|
|
||||||
"@0xproject/tslint-config": "^1.0.4",
|
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"@types/mocha": "^2.2.42",
|
"@types/mocha": "^2.2.42",
|
||||||
"@types/node": "^8.0.53",
|
"@types/node": "^8.0.53",
|
||||||
@@ -57,7 +58,7 @@
|
|||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"chai-as-promised": "^7.1.0",
|
"chai-as-promised": "^7.1.0",
|
||||||
"chai-bignumber": "^2.0.1",
|
"chai-bignumber": "^2.0.1",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "^2.0.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
"mocha": "^4.1.0",
|
"mocha": "^4.1.0",
|
||||||
@@ -68,20 +69,21 @@
|
|||||||
"sinon": "^4.0.0",
|
"sinon": "^4.0.0",
|
||||||
"source-map-support": "^0.5.0",
|
"source-map-support": "^0.5.0",
|
||||||
"tslint": "5.11.0",
|
"tslint": "5.11.0",
|
||||||
"typescript": "2.9.2",
|
"typedoc": "0.12.0",
|
||||||
|
"typescript": "3.0.1",
|
||||||
"web3-provider-engine": "14.0.6"
|
"web3-provider-engine": "14.0.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/assert": "^1.0.4",
|
"@0xproject/assert": "^1.0.7",
|
||||||
"@0xproject/base-contract": "^1.0.4",
|
"@0xproject/base-contract": "^2.0.1",
|
||||||
"@0xproject/fill-scenarios": "^1.0.1-rc.2",
|
"@0xproject/fill-scenarios": "^1.0.1-rc.5",
|
||||||
"@0xproject/json-schemas": "^1.0.1-rc.3",
|
"@0xproject/json-schemas": "^1.0.1-rc.6",
|
||||||
"@0xproject/order-utils": "^1.0.1-rc.2",
|
"@0xproject/order-utils": "^1.0.1-rc.6",
|
||||||
"@0xproject/types": "^1.0.1-rc.3",
|
"@0xproject/types": "^1.0.1-rc.6",
|
||||||
"@0xproject/typescript-typings": "^1.0.3",
|
"@0xproject/typescript-typings": "^1.0.5",
|
||||||
"@0xproject/utils": "^1.0.4",
|
"@0xproject/utils": "^1.0.7",
|
||||||
"@0xproject/web3-wrapper": "^1.1.2",
|
"@0xproject/web3-wrapper": "^2.0.1",
|
||||||
"ethereum-types": "^1.0.3",
|
"ethereum-types": "^1.0.5",
|
||||||
"ethereumjs-blockstream": "5.0.0",
|
"ethereumjs-blockstream": "5.0.0",
|
||||||
"ethereumjs-util": "^5.1.1",
|
"ethereumjs-util": "^5.1.1",
|
||||||
"ethers": "3.0.22",
|
"ethers": "3.0.22",
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { ContractArtifact } from '@0xproject/sol-compiler';
|
import { ContractArtifact } from 'ethereum-types';
|
||||||
|
|
||||||
import * as DummyERC20Token from './artifacts/DummyERC20Token.json';
|
import * as DummyERC20Token from './artifacts/DummyERC20Token.json';
|
||||||
import * as DummyERC721Token from './artifacts/DummyERC721Token.json';
|
import * as DummyERC721Token from './artifacts/DummyERC721Token.json';
|
||||||
|
@@ -1,7 +1,14 @@
|
|||||||
import { ContractArtifact } from '@0xproject/sol-compiler';
|
|
||||||
import { AbiDecoder, intervalUtils, logUtils } from '@0xproject/utils';
|
import { AbiDecoder, intervalUtils, logUtils } from '@0xproject/utils';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import { BlockParamLiteral, ContractAbi, FilterObject, LogEntry, LogWithDecodedArgs, RawLog } from 'ethereum-types';
|
import {
|
||||||
|
BlockParamLiteral,
|
||||||
|
ContractAbi,
|
||||||
|
ContractArtifact,
|
||||||
|
FilterObject,
|
||||||
|
LogEntry,
|
||||||
|
LogWithDecodedArgs,
|
||||||
|
RawLog,
|
||||||
|
} from 'ethereum-types';
|
||||||
import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream';
|
import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
@@ -16,6 +16,13 @@ export class ERC20ProxyWrapper extends ContractWrapper {
|
|||||||
public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi;
|
public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi;
|
||||||
private _erc20ProxyContractIfExists?: ERC20ProxyContract;
|
private _erc20ProxyContractIfExists?: ERC20ProxyContract;
|
||||||
private _contractAddressIfExists?: string;
|
private _contractAddressIfExists?: string;
|
||||||
|
/**
|
||||||
|
* Instantiate ERC20ProxyWrapper
|
||||||
|
* @param web3Wrapper Web3Wrapper instance to use
|
||||||
|
* @param networkId Desired networkId
|
||||||
|
* @param contractAddressIfExists The contract address to use. This is usually pulled from
|
||||||
|
* the artifacts but needs to be specified when using with your own custom testnet.
|
||||||
|
*/
|
||||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, contractAddressIfExists?: string) {
|
constructor(web3Wrapper: Web3Wrapper, networkId: number, contractAddressIfExists?: string) {
|
||||||
super(web3Wrapper, networkId);
|
super(web3Wrapper, networkId);
|
||||||
this._contractAddressIfExists = contractAddressIfExists;
|
this._contractAddressIfExists = contractAddressIfExists;
|
||||||
|
@@ -34,6 +34,13 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
public UNLIMITED_ALLOWANCE_IN_BASE_UNITS = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
|
public UNLIMITED_ALLOWANCE_IN_BASE_UNITS = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
|
||||||
private _tokenContractsByAddress: { [address: string]: ERC20TokenContract };
|
private _tokenContractsByAddress: { [address: string]: ERC20TokenContract };
|
||||||
private _erc20ProxyWrapper: ERC20ProxyWrapper;
|
private _erc20ProxyWrapper: ERC20ProxyWrapper;
|
||||||
|
/**
|
||||||
|
* Instantiate ERC20TokenWrapper
|
||||||
|
* @param web3Wrapper Web3Wrapper instance to use
|
||||||
|
* @param networkId Desired networkId
|
||||||
|
* @param erc20ProxyWrapper The ERC20ProxyWrapper instance to use
|
||||||
|
* @param blockPollingIntervalMs The block polling interval to use for active subscriptions
|
||||||
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
web3Wrapper: Web3Wrapper,
|
web3Wrapper: Web3Wrapper,
|
||||||
networkId: number,
|
networkId: number,
|
||||||
|
@@ -16,6 +16,13 @@ export class ERC721ProxyWrapper extends ContractWrapper {
|
|||||||
public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi;
|
public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi;
|
||||||
private _erc721ProxyContractIfExists?: ERC721ProxyContract;
|
private _erc721ProxyContractIfExists?: ERC721ProxyContract;
|
||||||
private _contractAddressIfExists?: string;
|
private _contractAddressIfExists?: string;
|
||||||
|
/**
|
||||||
|
* Instantiate ERC721ProxyWrapper
|
||||||
|
* @param web3Wrapper Web3Wrapper instance to use
|
||||||
|
* @param networkId Desired networkId
|
||||||
|
* @param contractAddressIfExists The contract address to use. This is usually pulled from
|
||||||
|
* the artifacts but needs to be specified when using with your own custom testnet.
|
||||||
|
*/
|
||||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, contractAddressIfExists?: string) {
|
constructor(web3Wrapper: Web3Wrapper, networkId: number, contractAddressIfExists?: string) {
|
||||||
super(web3Wrapper, networkId);
|
super(web3Wrapper, networkId);
|
||||||
this._contractAddressIfExists = contractAddressIfExists;
|
this._contractAddressIfExists = contractAddressIfExists;
|
||||||
|
@@ -33,6 +33,13 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
public abi: ContractAbi = artifacts.ERC721Token.compilerOutput.abi;
|
public abi: ContractAbi = artifacts.ERC721Token.compilerOutput.abi;
|
||||||
private _tokenContractsByAddress: { [address: string]: ERC721TokenContract };
|
private _tokenContractsByAddress: { [address: string]: ERC721TokenContract };
|
||||||
private _erc721ProxyWrapper: ERC721ProxyWrapper;
|
private _erc721ProxyWrapper: ERC721ProxyWrapper;
|
||||||
|
/**
|
||||||
|
* Instantiate ERC721TokenWrapper
|
||||||
|
* @param web3Wrapper Web3Wrapper instance to use
|
||||||
|
* @param networkId Desired networkId
|
||||||
|
* @param erc721ProxyWrapper The ERC721ProxyWrapper instance to use
|
||||||
|
* @param blockPollingIntervalMs The block polling interval to use for active subscriptions
|
||||||
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
web3Wrapper: Web3Wrapper,
|
web3Wrapper: Web3Wrapper,
|
||||||
networkId: number,
|
networkId: number,
|
||||||
|
@@ -24,6 +24,13 @@ export class EtherTokenWrapper extends ContractWrapper {
|
|||||||
[address: string]: WETH9Contract;
|
[address: string]: WETH9Contract;
|
||||||
} = {};
|
} = {};
|
||||||
private _erc20TokenWrapper: ERC20TokenWrapper;
|
private _erc20TokenWrapper: ERC20TokenWrapper;
|
||||||
|
/**
|
||||||
|
* Instantiate EtherTokenWrapper.
|
||||||
|
* @param web3Wrapper Web3Wrapper instance to use
|
||||||
|
* @param networkId Desired networkId
|
||||||
|
* @param erc20TokenWrapper The ERC20TokenWrapper instance to use
|
||||||
|
* @param blockPollingIntervalMs The block polling interval to use for active subscriptions
|
||||||
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
web3Wrapper: Web3Wrapper,
|
web3Wrapper: Web3Wrapper,
|
||||||
networkId: number,
|
networkId: number,
|
||||||
|
@@ -21,6 +21,7 @@ import {
|
|||||||
} from '../types';
|
} from '../types';
|
||||||
import { assert } from '../utils/assert';
|
import { assert } from '../utils/assert';
|
||||||
import { decorators } from '../utils/decorators';
|
import { decorators } from '../utils/decorators';
|
||||||
|
import { TransactionEncoder } from '../utils/transaction_encoder';
|
||||||
|
|
||||||
import { ContractWrapper } from './contract_wrapper';
|
import { ContractWrapper } from './contract_wrapper';
|
||||||
import { ExchangeContract, ExchangeEventArgs, ExchangeEvents } from './generated/exchange';
|
import { ExchangeContract, ExchangeEventArgs, ExchangeEvents } from './generated/exchange';
|
||||||
@@ -34,6 +35,16 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
private _exchangeContractIfExists?: ExchangeContract;
|
private _exchangeContractIfExists?: ExchangeContract;
|
||||||
private _contractAddressIfExists?: string;
|
private _contractAddressIfExists?: string;
|
||||||
private _zrxContractAddressIfExists?: string;
|
private _zrxContractAddressIfExists?: string;
|
||||||
|
/**
|
||||||
|
* Instantiate ExchangeWrapper
|
||||||
|
* @param web3Wrapper Web3Wrapper instance to use
|
||||||
|
* @param networkId Desired networkId
|
||||||
|
* @param contractAddressIfExists The exchange contract address to use. This is usually pulled from
|
||||||
|
* the artifacts but needs to be specified when using with your own custom testnet.
|
||||||
|
* @param zrxContractAddressIfExists The ZRXToken contract address to use. This is usually pulled from
|
||||||
|
* the artifacts but needs to be specified when using with your own custom testnet.
|
||||||
|
* @param blockPollingIntervalMs The block polling interval to use for active subscriptions
|
||||||
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
web3Wrapper: Web3Wrapper,
|
web3Wrapper: Web3Wrapper,
|
||||||
networkId: number,
|
networkId: number,
|
||||||
@@ -665,6 +676,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
* @param leftSignedOrder First order to match.
|
* @param leftSignedOrder First order to match.
|
||||||
* @param rightSignedOrder Second order to match.
|
* @param rightSignedOrder Second order to match.
|
||||||
* @param takerAddress The address that sends the transaction and gets the spread.
|
* @param takerAddress The address that sends the transaction and gets the spread.
|
||||||
|
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||||
* @return Transaction hash.
|
* @return Transaction hash.
|
||||||
*/
|
*/
|
||||||
@decorators.asyncZeroExErrorHandler
|
@decorators.asyncZeroExErrorHandler
|
||||||
@@ -723,6 +735,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
* @param signerAddress Address that should have signed the given hash.
|
* @param signerAddress Address that should have signed the given hash.
|
||||||
* @param signature Proof that the hash has been signed by signer.
|
* @param signature Proof that the hash has been signed by signer.
|
||||||
* @param senderAddress Address that should send the transaction.
|
* @param senderAddress Address that should send the transaction.
|
||||||
|
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||||
* @returns Transaction hash.
|
* @returns Transaction hash.
|
||||||
*/
|
*/
|
||||||
@decorators.asyncZeroExErrorHandler
|
@decorators.asyncZeroExErrorHandler
|
||||||
@@ -901,7 +914,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
/**
|
/**
|
||||||
* Cancel a given order.
|
* Cancel a given order.
|
||||||
* @param order An object that conforms to the Order or SignedOrder interface. The order you would like to cancel.
|
* @param order An object that conforms to the Order or SignedOrder interface. The order you would like to cancel.
|
||||||
* @param transactionOpts Optional arguments this method accepts.
|
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||||
* @return Transaction hash.
|
* @return Transaction hash.
|
||||||
*/
|
*/
|
||||||
@decorators.asyncZeroExErrorHandler
|
@decorators.asyncZeroExErrorHandler
|
||||||
@@ -1097,6 +1110,16 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxTokenAddress);
|
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxTokenAddress);
|
||||||
return zrxAssetData;
|
return zrxAssetData;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Returns a Transaction Encoder. Transaction messages exist for the purpose of calling methods on the Exchange contract
|
||||||
|
* in the context of another address.
|
||||||
|
* @return TransactionEncoder
|
||||||
|
*/
|
||||||
|
public async transactionEncoderAsync(): Promise<TransactionEncoder> {
|
||||||
|
const exchangeInstance = await this._getExchangeContractAsync();
|
||||||
|
const encoder = new TransactionEncoder(exchangeInstance);
|
||||||
|
return encoder;
|
||||||
|
}
|
||||||
// tslint:disable:no-unused-variable
|
// tslint:disable:no-unused-variable
|
||||||
private _invalidateContractInstances(): void {
|
private _invalidateContractInstances(): void {
|
||||||
this.unsubscribeAll();
|
this.unsubscribeAll();
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user