Compare commits
82 Commits
@0xproject
...
@0xproject
Author | SHA1 | Date | |
---|---|---|---|
|
631e7e9c58 | ||
|
c44f9e56ad | ||
|
2fe209d5ff | ||
|
7d8badc86e | ||
|
854d65b51b | ||
|
df773d07f3 | ||
|
efdbc1ff6c | ||
|
a9b5faa787 | ||
|
49a54c0ff6 | ||
|
70d403e6f8 | ||
|
eecf09f515 | ||
|
61fc3346c2 | ||
|
b7e98abc43 | ||
|
073bf738dd | ||
|
68e8d6f304 | ||
|
524e4707d2 | ||
|
a0fac663f7 | ||
|
277e58c2e5 | ||
|
774ab8a8ef | ||
|
21dc94b709 | ||
|
d6176872f7 | ||
|
c396be42b9 | ||
|
7f7ddee0f9 | ||
|
b99c797945 | ||
|
59edca4166 | ||
|
fbba5e054a | ||
|
ea47613d90 | ||
|
9d18f751c8 | ||
|
9745dfe2f4 | ||
|
29d38593d6 | ||
|
d76bc18bb7 | ||
|
cbe61ac315 | ||
|
250d97a7c4 | ||
|
249bf0163d | ||
|
674e56cea6 | ||
|
61809130a6 | ||
|
f5e6e0eaf7 | ||
|
b2c423dd84 | ||
|
4a9752d7cd | ||
|
7db9a01639 | ||
|
e9cb5c069a | ||
|
03e4205700 | ||
|
fd9278ac02 | ||
|
1b7c7037b8 | ||
|
913264c811 | ||
|
e70b6630f9 | ||
|
6d53947fd8 | ||
|
1c0d982398 | ||
|
a88b4040ff | ||
|
e8073cd6f2 | ||
|
8281be235c | ||
|
9ce03e3515 | ||
|
667938696d | ||
|
a165281dcf | ||
|
185f70f2dd | ||
|
cd3e14f45a | ||
|
dd87588dfe | ||
|
29042e1939 | ||
|
4dbf6559aa | ||
|
b987b5988d | ||
|
6ba6bec105 | ||
|
d95b1e2db4 | ||
|
c1d6c7ff66 | ||
|
6e12794765 | ||
|
0f4b05e374 | ||
|
695b697cdf | ||
|
3aea0e3b2f | ||
|
c0e92d511e | ||
|
51f2a20b2a | ||
|
333a23f222 | ||
|
3bf3f479f5 | ||
|
6241d06f27 | ||
|
9e81d3c87b | ||
|
a9b2838c5f | ||
|
fbc39614c0 | ||
|
b2d6ac8dba | ||
|
b090b7b1f2 | ||
|
ba0696a0d7 | ||
|
b57850a225 | ||
|
4d9029bb0e | ||
|
bc49dde4d5 | ||
|
afe07b2926 |
@@ -183,9 +183,9 @@ workflows:
|
||||
main:
|
||||
jobs:
|
||||
- build
|
||||
- test-installation:
|
||||
requires:
|
||||
- build
|
||||
# - test-installation:
|
||||
# requires:
|
||||
# - build
|
||||
- test-0xjs:
|
||||
requires:
|
||||
- build
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -79,6 +79,7 @@ packages/contracts/src/artifacts
|
||||
# generated contract wrappers
|
||||
packages/0x.js/src/contract_wrappers/generated/
|
||||
packages/contracts/src/contract_wrappers/generated/
|
||||
packages/metacoin/src/contract_wrappers
|
||||
|
||||
# solc-bin in deployer
|
||||
packages/deployer/solc_bin/
|
||||
|
@@ -56,6 +56,11 @@ Dedicated documentation pages:
|
||||
* [0x.js Library](https://0xproject.com/docs/0xjs)
|
||||
* [0x Connect](https://0xproject.com/docs/connect)
|
||||
* [Smart contracts](https://0xproject.com/docs/contracts)
|
||||
* [Subproviders](https://0xproject.com/docs/subproviders)
|
||||
* [Deployer](https://0xproject.com/docs/deployer)
|
||||
* [Web3-wrapper](https://0xproject.com/docs/web3-wrapper)
|
||||
* [JSON-schemas](https://0xproject.com/docs/json-schemas)
|
||||
* [Sol-cov](https://0xproject.com/docs/sol-cov)
|
||||
* [Standard Relayer API](https://github.com/0xProject/standard-relayer-api/blob/master/README.md)
|
||||
|
||||
Most of the packages require additional typings for external dependencies.
|
||||
@@ -90,14 +95,14 @@ yarn install
|
||||
Build all packages. You need to do this before working on any given package. Although these packages
|
||||
as independent, when run from within the monorepo, they are internally symlinked, to make development
|
||||
easier. You can change several packages and run the changes without publishing them first to NPM. When
|
||||
running `rebuild`, Lerna will figure out the dependency order of all the packages, and built them in
|
||||
running `rebuild`, Lerna will figure out the dependency order of all the packages, and build them in
|
||||
this order.
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
```
|
||||
|
||||
Continuously rebuild on change
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
|
@@ -18,6 +18,7 @@
|
||||
"lerna:rebuild": "run-s lerna:clean lerna:build",
|
||||
"lerna:publish": "run-s lerna:install lerna:rebuild script:publish",
|
||||
"lerna:publish:dry": "run-s lerna:install lerna:rebuild script:publish:dry",
|
||||
"lerna:stage_docs": "lerna run docs:stage",
|
||||
"script:publish": "node ./packages/monorepo-scripts/lib/publish.js",
|
||||
"script:publish:dry": "IS_DRY_RUN=true yarn script:publish"
|
||||
},
|
||||
|
@@ -1,4 +1,25 @@
|
||||
[
|
||||
{
|
||||
"version": "0.36.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Moved Web3.Provider to `@0xproject/types:Provider`",
|
||||
"pr": 501
|
||||
}
|
||||
],
|
||||
"timestamp": 1523462196
|
||||
},
|
||||
{
|
||||
"version": "0.35.0",
|
||||
"changes": [
|
||||
{
|
||||
"note":
|
||||
"Removed `ZeroExError.TransactionMiningTimeout` and moved it to '@0xproject/web3_wrapper' `Web3WrapperErrors.TransactionMiningTimeout`",
|
||||
"pr": 485
|
||||
}
|
||||
],
|
||||
"timestamp": 1522673609
|
||||
},
|
||||
{
|
||||
"version": "0.34.0",
|
||||
"changes": [
|
||||
@@ -35,8 +56,7 @@
|
||||
"pr": 456
|
||||
}
|
||||
],
|
||||
"timestamp": 1521298800,
|
||||
"isPublished": true
|
||||
"timestamp": 1521298800
|
||||
},
|
||||
{
|
||||
"version": "0.33.1",
|
||||
@@ -45,8 +65,7 @@
|
||||
"note": "Add missing EthersJs typescript typings as dependency"
|
||||
}
|
||||
],
|
||||
"timestamp": 1520434800,
|
||||
"isPublished": true
|
||||
"timestamp": 1520434800
|
||||
},
|
||||
{
|
||||
"version": "0.33.0",
|
||||
@@ -72,8 +91,7 @@
|
||||
"pr": 429
|
||||
}
|
||||
],
|
||||
"timestamp": 1520089200,
|
||||
"isPublished": true
|
||||
"timestamp": 1520089200
|
||||
},
|
||||
{
|
||||
"version": "0.32.2",
|
||||
@@ -83,8 +101,7 @@
|
||||
"pr": 389
|
||||
}
|
||||
],
|
||||
"timestamp": 1518102000,
|
||||
"isPublished": true
|
||||
"timestamp": 1518102000
|
||||
},
|
||||
{
|
||||
"version": "0.32.1",
|
||||
@@ -98,8 +115,7 @@
|
||||
"pr": 371
|
||||
}
|
||||
],
|
||||
"timestamp": 1517929200,
|
||||
"isPublished": true
|
||||
"timestamp": 1517929200
|
||||
},
|
||||
{
|
||||
"version": "0.32.0",
|
||||
@@ -114,8 +130,7 @@
|
||||
"pr": 366
|
||||
}
|
||||
],
|
||||
"timestamp": 1517756400,
|
||||
"isPublished": true
|
||||
"timestamp": 1517756400
|
||||
},
|
||||
{
|
||||
"version": "0.31.1",
|
||||
@@ -125,8 +140,7 @@
|
||||
"pr": 357
|
||||
}
|
||||
],
|
||||
"timestamp": 1517410800,
|
||||
"isPublished": true
|
||||
"timestamp": 1517410800
|
||||
},
|
||||
{
|
||||
"version": "0.31.0",
|
||||
@@ -137,8 +151,7 @@
|
||||
"pr": 349
|
||||
}
|
||||
],
|
||||
"timestamp": 1517238000,
|
||||
"isPublished": true
|
||||
"timestamp": 1517238000
|
||||
},
|
||||
{
|
||||
"version": "0.30.2",
|
||||
@@ -151,8 +164,7 @@
|
||||
"note": "Move @0xproject/types to dependencies from devDependencies fixing missing type errors"
|
||||
}
|
||||
],
|
||||
"timestamp": 1517151600,
|
||||
"isPublished": true
|
||||
"timestamp": 1517151600
|
||||
},
|
||||
{
|
||||
"version": "0.30.1",
|
||||
@@ -166,8 +178,7 @@
|
||||
"pr": 341
|
||||
}
|
||||
],
|
||||
"timestamp": 1516719600,
|
||||
"isPublished": true
|
||||
"timestamp": 1516719600
|
||||
},
|
||||
{
|
||||
"version": "0.30.0",
|
||||
@@ -186,8 +197,7 @@
|
||||
"pr": 321
|
||||
}
|
||||
],
|
||||
"timestamp": 1516114800,
|
||||
"isPublished": true
|
||||
"timestamp": 1516114800
|
||||
},
|
||||
{
|
||||
"version": "0.29.1",
|
||||
@@ -197,8 +207,7 @@
|
||||
"pr": 305
|
||||
}
|
||||
],
|
||||
"timestamp": 1515596400,
|
||||
"isPublished": true
|
||||
"timestamp": 1515596400
|
||||
},
|
||||
{
|
||||
"version": "0.29.0",
|
||||
@@ -212,8 +221,7 @@
|
||||
"pr": 287
|
||||
}
|
||||
],
|
||||
"timestamp": 1514386800,
|
||||
"isPublished": true
|
||||
"timestamp": 1514386800
|
||||
},
|
||||
{
|
||||
"version": "0.28.0",
|
||||
@@ -259,8 +267,7 @@
|
||||
"pr": 278
|
||||
}
|
||||
],
|
||||
"timestamp": 1513695600,
|
||||
"isPublished": true
|
||||
"timestamp": 1513695600
|
||||
},
|
||||
{
|
||||
"version": "0.27.1",
|
||||
@@ -269,8 +276,7 @@
|
||||
"note": "Export `TransactionOpts` type"
|
||||
}
|
||||
],
|
||||
"timestamp": 1511794800,
|
||||
"isPublished": true
|
||||
"timestamp": 1511794800
|
||||
},
|
||||
{
|
||||
"version": "0.27.0",
|
||||
@@ -315,8 +321,7 @@
|
||||
"pr": 236
|
||||
}
|
||||
],
|
||||
"timestamp": 1511794800,
|
||||
"isPublished": true
|
||||
"timestamp": 1511794800
|
||||
},
|
||||
{
|
||||
"version": "0.26.0",
|
||||
@@ -336,8 +341,7 @@
|
||||
"pr": 225
|
||||
}
|
||||
],
|
||||
"timestamp": 1511190000,
|
||||
"isPublished": true
|
||||
"timestamp": 1511190000
|
||||
},
|
||||
{
|
||||
"version": "0.25.1",
|
||||
@@ -356,8 +360,7 @@
|
||||
"pr": 200
|
||||
}
|
||||
],
|
||||
"timestamp": 1510498800,
|
||||
"isPublished": true
|
||||
"timestamp": 1510498800
|
||||
},
|
||||
{
|
||||
"version": "0.23.0",
|
||||
@@ -370,8 +373,7 @@
|
||||
"note": "Subscribe callbacks now receive an error object as their first argument"
|
||||
}
|
||||
],
|
||||
"timestamp": 1510412400,
|
||||
"isPublished": true
|
||||
"timestamp": 1510412400
|
||||
},
|
||||
{
|
||||
"version": "0.22.6",
|
||||
@@ -381,8 +383,7 @@
|
||||
"pr": 206
|
||||
}
|
||||
],
|
||||
"timestamp": 1510239600,
|
||||
"isPublished": true
|
||||
"timestamp": 1510239600
|
||||
},
|
||||
{
|
||||
"version": "0.22.5",
|
||||
@@ -391,8 +392,7 @@
|
||||
"note": "Re-publish v0.22.4 to fix publishing issue"
|
||||
}
|
||||
],
|
||||
"timestamp": 1509980400,
|
||||
"isPublished": true
|
||||
"timestamp": 1509980400
|
||||
},
|
||||
{
|
||||
"version": "0.22.4",
|
||||
@@ -401,8 +401,7 @@
|
||||
"note": "Upgraded bignumber.js to a new version that ships with native typings"
|
||||
}
|
||||
],
|
||||
"timestamp": 1508857200,
|
||||
"isPublished": true
|
||||
"timestamp": 1508857200
|
||||
},
|
||||
{
|
||||
"version": "0.22.3",
|
||||
@@ -412,8 +411,7 @@
|
||||
"pr": 199
|
||||
}
|
||||
],
|
||||
"timestamp": 1508857200,
|
||||
"isPublished": true
|
||||
"timestamp": 1508857200
|
||||
},
|
||||
{
|
||||
"version": "0.22.2",
|
||||
@@ -423,8 +421,7 @@
|
||||
"pr": 197
|
||||
}
|
||||
],
|
||||
"timestamp": 1508770800,
|
||||
"isPublished": true
|
||||
"timestamp": 1508770800
|
||||
},
|
||||
{
|
||||
"version": "0.22.0",
|
||||
@@ -439,8 +436,7 @@
|
||||
"pr": 187
|
||||
}
|
||||
],
|
||||
"timestamp": 1508079600,
|
||||
"isPublished": true
|
||||
"timestamp": 1508079600
|
||||
},
|
||||
{
|
||||
"version": "0.21.4",
|
||||
@@ -451,8 +447,7 @@
|
||||
"pr": 194
|
||||
}
|
||||
],
|
||||
"timestamp": 1507820400,
|
||||
"isPublished": true
|
||||
"timestamp": 1507820400
|
||||
},
|
||||
{
|
||||
"version": "0.21.3",
|
||||
@@ -462,8 +457,7 @@
|
||||
"pr": 193
|
||||
}
|
||||
],
|
||||
"timestamp": 1507734000,
|
||||
"isPublished": true
|
||||
"timestamp": 1507734000
|
||||
},
|
||||
{
|
||||
"version": "0.21.2",
|
||||
@@ -473,8 +467,7 @@
|
||||
"pr": 190
|
||||
}
|
||||
],
|
||||
"timestamp": 1507647600,
|
||||
"isPublished": true
|
||||
"timestamp": 1507647600
|
||||
},
|
||||
{
|
||||
"version": "0.21.1",
|
||||
@@ -484,8 +477,7 @@
|
||||
"pr": 189
|
||||
}
|
||||
],
|
||||
"timestamp": 1507647600,
|
||||
"isPublished": true
|
||||
"timestamp": 1507647600
|
||||
},
|
||||
{
|
||||
"version": "0.21.0",
|
||||
@@ -531,8 +523,7 @@
|
||||
"pr": 185
|
||||
}
|
||||
],
|
||||
"timestamp": 1507561200,
|
||||
"isPublished": true
|
||||
"timestamp": 1507561200
|
||||
},
|
||||
{
|
||||
"version": "0.20.0",
|
||||
@@ -550,8 +541,7 @@
|
||||
"pr": 181
|
||||
}
|
||||
],
|
||||
"timestamp": 1507129200,
|
||||
"isPublished": true
|
||||
"timestamp": 1507129200
|
||||
},
|
||||
{
|
||||
"version": "0.19.0",
|
||||
@@ -569,8 +559,7 @@
|
||||
"pr": 175
|
||||
}
|
||||
],
|
||||
"timestamp": 1506610800,
|
||||
"isPublished": true
|
||||
"timestamp": 1506610800
|
||||
},
|
||||
{
|
||||
"version": "0.18.0",
|
||||
@@ -580,8 +569,7 @@
|
||||
"pr": 170
|
||||
}
|
||||
],
|
||||
"timestamp": 1506351600,
|
||||
"isPublished": true
|
||||
"timestamp": 1506351600
|
||||
},
|
||||
{
|
||||
"version": "0.17.0",
|
||||
@@ -591,8 +579,7 @@
|
||||
"pr": 171
|
||||
}
|
||||
],
|
||||
"timestamp": 1506351600,
|
||||
"isPublished": true
|
||||
"timestamp": 1506351600
|
||||
},
|
||||
{
|
||||
"version": "0.16.0",
|
||||
@@ -615,8 +602,7 @@
|
||||
"pr": 165
|
||||
}
|
||||
],
|
||||
"timestamp": 1505833200,
|
||||
"isPublished": true
|
||||
"timestamp": 1505833200
|
||||
},
|
||||
{
|
||||
"version": "0.15.0",
|
||||
@@ -627,8 +613,7 @@
|
||||
"pr": 161
|
||||
}
|
||||
],
|
||||
"timestamp": 1504796400,
|
||||
"isPublished": true
|
||||
"timestamp": 1504796400
|
||||
},
|
||||
{
|
||||
"version": "0.14.2",
|
||||
@@ -638,8 +623,7 @@
|
||||
"pr": 160
|
||||
}
|
||||
],
|
||||
"timestamp": 1504710000,
|
||||
"isPublished": true
|
||||
"timestamp": 1504710000
|
||||
},
|
||||
{
|
||||
"version": "0.14.1",
|
||||
@@ -649,8 +633,7 @@
|
||||
"pr": 159
|
||||
}
|
||||
],
|
||||
"timestamp": 1504710000,
|
||||
"isPublished": true
|
||||
"timestamp": 1504710000
|
||||
},
|
||||
{
|
||||
"version": "0.14.0",
|
||||
@@ -668,8 +651,7 @@
|
||||
"pr": 157
|
||||
}
|
||||
],
|
||||
"timestamp": 1504623600,
|
||||
"isPublished": true
|
||||
"timestamp": 1504623600
|
||||
},
|
||||
{
|
||||
"version": "0.13.0",
|
||||
@@ -693,8 +675,7 @@
|
||||
"pr": 152
|
||||
}
|
||||
],
|
||||
"timestamp": 1504623600,
|
||||
"isPublished": true
|
||||
"timestamp": 1504623600
|
||||
},
|
||||
{
|
||||
"version": "0.12.1",
|
||||
@@ -712,8 +693,7 @@
|
||||
"pr": 139
|
||||
}
|
||||
],
|
||||
"timestamp": 1504278000,
|
||||
"isPublished": true
|
||||
"timestamp": 1504278000
|
||||
},
|
||||
{
|
||||
"version": "0.11.0",
|
||||
@@ -731,8 +711,7 @@
|
||||
"pr": 137
|
||||
}
|
||||
],
|
||||
"timestamp": 1503500400,
|
||||
"isPublished": true
|
||||
"timestamp": 1503500400
|
||||
},
|
||||
{
|
||||
"version": "0.10.4",
|
||||
@@ -742,8 +721,7 @@
|
||||
"pr": 135
|
||||
}
|
||||
],
|
||||
"timestamp": 1503500400,
|
||||
"isPublished": true
|
||||
"timestamp": 1503500400
|
||||
},
|
||||
{
|
||||
"version": "0.10.1",
|
||||
@@ -797,8 +775,7 @@
|
||||
"pr": 127
|
||||
}
|
||||
],
|
||||
"timestamp": 1503500400,
|
||||
"isPublished": true
|
||||
"timestamp": 1503500400
|
||||
},
|
||||
{
|
||||
"version": "0.9.3",
|
||||
@@ -808,8 +785,7 @@
|
||||
"pr": 118
|
||||
}
|
||||
],
|
||||
"timestamp": 1503327600,
|
||||
"isPublished": true
|
||||
"timestamp": 1503327600
|
||||
},
|
||||
{
|
||||
"version": "0.9.2",
|
||||
@@ -822,8 +798,7 @@
|
||||
"pr": 118
|
||||
}
|
||||
],
|
||||
"timestamp": 1503241200,
|
||||
"isPublished": true
|
||||
"timestamp": 1503241200
|
||||
},
|
||||
{
|
||||
"version": "0.9.1",
|
||||
@@ -833,8 +808,7 @@
|
||||
"pr": 120
|
||||
}
|
||||
],
|
||||
"timestamp": 1502809200,
|
||||
"isPublished": true
|
||||
"timestamp": 1502809200
|
||||
},
|
||||
{
|
||||
"version": "0.9.0",
|
||||
@@ -871,8 +845,7 @@
|
||||
"pr": 109
|
||||
}
|
||||
],
|
||||
"timestamp": 1500994800,
|
||||
"isPublished": true
|
||||
"timestamp": 1500994800
|
||||
},
|
||||
{
|
||||
"version": "0.8.0",
|
||||
@@ -914,8 +887,7 @@
|
||||
"note": "Fixed the bug where `zeroEx.setProviderAsync` didn't invalidate etherToken contract's instance"
|
||||
}
|
||||
],
|
||||
"timestamp": 1499094000,
|
||||
"isPublished": true
|
||||
"timestamp": 1499094000
|
||||
},
|
||||
{
|
||||
"version": "0.7.1",
|
||||
@@ -926,8 +898,7 @@
|
||||
"pr": 81
|
||||
}
|
||||
],
|
||||
"timestamp": 1498402800,
|
||||
"isPublished": true
|
||||
"timestamp": 1498402800
|
||||
},
|
||||
{
|
||||
"version": "0.7.0",
|
||||
@@ -949,8 +920,7 @@
|
||||
"Renamed type `LogCancelArgs` to `LogCancelContractEventArgs` and `LogFillArgs` to `LogFillContractEventArgs`"
|
||||
}
|
||||
],
|
||||
"timestamp": 1498057200,
|
||||
"isPublished": true
|
||||
"timestamp": 1498057200
|
||||
},
|
||||
{
|
||||
"version": "0.6.2",
|
||||
@@ -962,8 +932,7 @@
|
||||
"note": "Improved documentation"
|
||||
}
|
||||
],
|
||||
"timestamp": 1497970800,
|
||||
"isPublished": true
|
||||
"timestamp": 1497970800
|
||||
},
|
||||
{
|
||||
"version": "0.6.1",
|
||||
@@ -972,8 +941,7 @@
|
||||
"note": "Improved documentation"
|
||||
}
|
||||
],
|
||||
"timestamp": 1497798000,
|
||||
"isPublished": true
|
||||
"timestamp": 1497798000
|
||||
},
|
||||
{
|
||||
"version": "0.6.0",
|
||||
@@ -985,8 +953,7 @@
|
||||
"note": "Added types for contract event arguments"
|
||||
}
|
||||
],
|
||||
"timestamp": 1497798000,
|
||||
"isPublished": true
|
||||
"timestamp": 1497798000
|
||||
},
|
||||
{
|
||||
"version": "0.5.2",
|
||||
@@ -996,8 +963,7 @@
|
||||
"Fixed the bug in `postpublish` script that caused that only unminified UMD bundle was uploaded to release page"
|
||||
}
|
||||
],
|
||||
"timestamp": 1497452400,
|
||||
"isPublished": true
|
||||
"timestamp": 1497452400
|
||||
},
|
||||
{
|
||||
"version": "0.5.1",
|
||||
@@ -1006,7 +972,6 @@
|
||||
"note": "Added `postpublish` script to publish to Github Releases with assets."
|
||||
}
|
||||
],
|
||||
"timestamp": 1497452400,
|
||||
"isPublished": true
|
||||
"timestamp": 1497452400
|
||||
}
|
||||
]
|
||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.36.0 - _April 11, 2018_
|
||||
|
||||
* Moved Web3.Provider to `@0xproject/types:Provider` (#501)
|
||||
|
||||
## v0.35.0 - _April 2, 2018_
|
||||
|
||||
* Removed `ZeroExError.TransactionMiningTimeout` and moved it to '@0xproject/web3_wrapper' `Web3WrapperErrors.TransactionMiningTimeout` (#485)
|
||||
|
||||
## v0.34.0 - _April 2, 2018_
|
||||
|
||||
* Fix the bug causing `zeroEx.exchange.fillOrdersUpToAsync` validation to fail if there were some extra orders passed (#470)
|
||||
@@ -12,16 +20,16 @@ CHANGELOG
|
||||
* Add `zeroEx.createOrderStateWatcher` to allow creating arbitrary number of OrderStateWatchers (#488)
|
||||
* Added `stateLayer` setting to `OrderStateWatcherConfig` so OrderStateWatcher can be set to monitor different blockchain state layers (#488)
|
||||
|
||||
## v0.33.2 - _March 18, 2018_
|
||||
## v0.33.2 - _March 17, 2018_
|
||||
|
||||
* Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package (#452)
|
||||
* Consolidate `Order`, `SignedOrder`, and `ECSignature` into the `@0xproject/types` package (#456)
|
||||
|
||||
## v0.33.1 - _March 8, 2018_
|
||||
## v0.33.1 - _March 7, 2018_
|
||||
|
||||
* Add missing EthersJs typescript typings as dependency
|
||||
|
||||
## v0.33.0 - _March 4, 2018_
|
||||
## v0.33.0 - _March 3, 2018_
|
||||
|
||||
* Validate and lowercase all addresses in public methods (#373)
|
||||
* Improve validation to force passing contract addresses on private networks (#385)
|
||||
@@ -29,54 +37,54 @@ CHANGELOG
|
||||
* Rename all public `_unsubscribeAll` methods to `unsubscribeAll` (#415)
|
||||
* Move web3 typings from devDep to dep since cannot use this package without it (#429)
|
||||
|
||||
## v0.32.2 - _February 9, 2018_
|
||||
## v0.32.2 - _February 8, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.32.1 - _February 7, 2018_
|
||||
## v0.32.1 - _February 6, 2018_
|
||||
|
||||
* Reorganized `BlockParamLiteral` export into `@0xproject/types` package (#355)
|
||||
* Now using `abi-gen` package to generate ContractEventArgs types (#371)
|
||||
|
||||
## v0.32.0 - _February 5, 2018_
|
||||
## v0.32.0 - _February 4, 2018_
|
||||
|
||||
* Add `zeroEx.etherToken.getContractAddressIfExists` (#350)
|
||||
* Fixed the bug causing order watcher to throw if there is an event with the same signature but different indexed fields (#366)
|
||||
|
||||
## v0.31.1 - _February 1, 2018_
|
||||
## v0.31.1 - _January 31, 2018_
|
||||
|
||||
* Fix the bug causing order watcher to throw if makerToken === zrx (#357)
|
||||
|
||||
## v0.31.0 - _January 30, 2018_
|
||||
## v0.31.0 - _January 29, 2018_
|
||||
|
||||
* Add the `shouldAddPersonalMessagePrefix` parameter to `signOrderHashAsync` so that the caller can decide on whether to add the personalMessage prefix before relaying the request to the signer. Parity Signer, Ledger and TestRPC add the prefix themselves, Metamask expects it to have already been added. (#349)
|
||||
|
||||
## v0.30.2 - _January 29, 2018_
|
||||
## v0.30.2 - _January 28, 2018_
|
||||
|
||||
* Add Rinkeby testnet addresses to artifacts (#337)
|
||||
* Move @0xproject/types to dependencies from devDependencies fixing missing type errors
|
||||
|
||||
## v0.30.1 - _January 24, 2018_
|
||||
## v0.30.1 - _January 23, 2018_
|
||||
|
||||
* Fix a bug allowing negative fill values (#212)
|
||||
* Fix a bug that made it impossible to pass a custom ZRX address (#341)
|
||||
|
||||
## v0.30.0 - _January 17, 2018_
|
||||
## v0.30.0 - _January 16, 2018_
|
||||
|
||||
* Add an error parameter to the order watcher callback (#312)
|
||||
* Fix a bug making it impossible to catch some errors from awaitTransactionMinedAsync (#312)
|
||||
* Fix a bug in fillOrdersUpTo validation making it impossible to fill up to if user doesn't have enough balance to fully fill all the orders (#321)
|
||||
|
||||
## v0.29.1 - _January 11, 2018_
|
||||
## v0.29.1 - _January 10, 2018_
|
||||
|
||||
* Fixed bignumber config issue #301 (#305)
|
||||
|
||||
## v0.29.0 - _December 28, 2017_
|
||||
## v0.29.0 - _December 27, 2017_
|
||||
|
||||
* Assert baseUnit amount supplied to `toUnitAmount` is integer amount. (#287)
|
||||
* `toBaseUnitAmount` throws if amount supplied has too many decimals (#287)
|
||||
|
||||
## v0.28.0 - _December 20, 2017_
|
||||
## v0.28.0 - _December 19, 2017_
|
||||
|
||||
* Add `etherTokenAddress` arg to `depositAsync` and `withdrawAsync` methods on `zeroEx.etherToken` (#267)
|
||||
* Removed accidentally included `unsubscribeAll` method from `zeroEx.proxy`, `zeroEx.etherToken` and `zeroEx.tokenRegistry` (#267)
|
||||
@@ -88,11 +96,11 @@ CHANGELOG
|
||||
* Support `Deposit` and `Withdraw` events on etherToken (#277)
|
||||
* Improve the error message when taker is not a string (#278)
|
||||
|
||||
## v0.27.1 - _November 28, 2017_
|
||||
## v0.27.1 - _November 27, 2017_
|
||||
|
||||
* Export `TransactionOpts` type
|
||||
|
||||
## v0.27.0 - _November 28, 2017_
|
||||
## v0.27.0 - _November 27, 2017_
|
||||
|
||||
* Make `ZeroExConfig` required parameter of `ZeroEx` constructor (#233)
|
||||
* Add a required property `networkId` to `ZeroExConfig` (#233)
|
||||
@@ -104,65 +112,65 @@ CHANGELOG
|
||||
* All transaction sending methods now call `estimateGas` if no gas amount was supplied (#235)
|
||||
* Modify order validation methods to validate against the `latest` block, not against the `pending` block (#236)
|
||||
|
||||
## v0.26.0 - _November 21, 2017_
|
||||
## v0.26.0 - _November 20, 2017_
|
||||
|
||||
* Add post-formatter for logs converting `blockNumber`, `logIndex`, `transactionIndex` from hexes to numbers (#231)
|
||||
* Remove support for Async callback types when used in Subscribe functions (#222)
|
||||
* In OrderWatcher subscribe to ZRX Token Transfer and Approval events when maker token is different (#225)
|
||||
|
||||
## v0.25.1 - _November 13, 2017_
|
||||
## v0.25.1 - _November 12, 2017_
|
||||
|
||||
* Standardise on Cancelled over Canceled (#217)
|
||||
* Add missing `DecodedLogEvent` type to exported types (#205)
|
||||
* Normalized the transactionReceipt status to be `null|0|1`, 1 meaning transaction execution successful, 0 unsuccessful and `null` if it is a pre-byzantinium transaction. (#200)
|
||||
|
||||
## v0.23.0 - _November 12, 2017_
|
||||
## v0.23.0 - _November 11, 2017_
|
||||
|
||||
* Fixed unhandled promise rejection error in subscribe methods (#209)
|
||||
* Subscribe callbacks now receive an error object as their first argument
|
||||
|
||||
## v0.22.6 - _November 10, 2017_
|
||||
## v0.22.6 - _November 9, 2017_
|
||||
|
||||
* Add a timeout parameter to transaction awaiting (#206)
|
||||
|
||||
## v0.22.5 - _November 7, 2017_
|
||||
## v0.22.5 - _November 6, 2017_
|
||||
|
||||
* Re-publish v0.22.4 to fix publishing issue
|
||||
|
||||
## v0.22.4 - _October 25, 2017_
|
||||
## v0.22.4 - _October 24, 2017_
|
||||
|
||||
* Upgraded bignumber.js to a new version that ships with native typings
|
||||
|
||||
## v0.22.3 - _October 25, 2017_
|
||||
## v0.22.3 - _October 24, 2017_
|
||||
|
||||
* Fixed an issue with new version of testrpc and unlimited proxy allowance (#199)
|
||||
|
||||
## v0.22.2 - _October 24, 2017_
|
||||
## v0.22.2 - _October 23, 2017_
|
||||
|
||||
* Fixed rounding of maker fill amount and incorrect validation of partial fees (#197)
|
||||
|
||||
## v0.22.0 - _October 16, 2017_
|
||||
## v0.22.0 - _October 15, 2017_
|
||||
|
||||
* Started using `OrderFillRequest` interface instead of `OrderFillOrKillRequest` interface for `zeroEx.exchange.batchFillOrKill` (#187)
|
||||
* Removed `OrderFillOrKillRequest` (#187)
|
||||
|
||||
## v0.21.4 - _October 13, 2017_
|
||||
## v0.21.4 - _October 12, 2017_
|
||||
|
||||
* Made 0x.js more type-safe by making `getLogsAsync` and `subscribe/subscribeAsync` generics parametrized with arg type (#194)
|
||||
|
||||
## v0.21.3 - _October 12, 2017_
|
||||
## v0.21.3 - _October 11, 2017_
|
||||
|
||||
* Fixed a bug causing order fills to throw `INSUFFICIENT_TAKER_ALLOWANCE` (#193)
|
||||
|
||||
## v0.21.2 - _October 11, 2017_
|
||||
## v0.21.2 - _October 10, 2017_
|
||||
|
||||
* Exported `ContractEventArg` as a public type (#190)
|
||||
|
||||
## v0.21.1 - _October 11, 2017_
|
||||
## v0.21.1 - _October 10, 2017_
|
||||
|
||||
* Fixed a bug in subscriptions (#189)
|
||||
|
||||
## v0.21.0 - _October 10, 2017_
|
||||
## v0.21.0 - _October 9, 2017_
|
||||
|
||||
* Complete rewrite of subscription logic (#182)
|
||||
* Subscriptions no longer return historical logs. If you want them - use `getLogsAsync`
|
||||
@@ -177,27 +185,27 @@ CHANGELOG
|
||||
* Renamed `zeroEx.token.stopWatchingAllEventsAsync` to `zeroEx.token.unsubscribeAll`
|
||||
* Fixed the batch fills validation by emulating all balance & proxy allowance changes (#185)
|
||||
|
||||
## v0.20.0 - _October 5, 2017_
|
||||
## v0.20.0 - _October 4, 2017_
|
||||
|
||||
* Add `zeroEx.token.getLogsAsync` (#178)
|
||||
* Add `zeroEx.exchange.getLogsAsync` (#178)
|
||||
* Fixed fees validation when one of the tokens transferred is ZRX (#181)
|
||||
|
||||
## v0.19.0 - _September 29, 2017_
|
||||
## v0.19.0 - _September 28, 2017_
|
||||
|
||||
* Made order validation optional (#172)
|
||||
* Added Ropsten testnet support (#173)
|
||||
* Fixed a bug causing awaitTransactionMinedAsync to DDos backend nodes (#175)
|
||||
|
||||
## v0.18.0 - _September 26, 2017_
|
||||
## v0.18.0 - _September 25, 2017_
|
||||
|
||||
* Added `zeroEx.exchange.validateOrderFillableOrThrowAsync` to simplify orderbook pruning (#170)
|
||||
|
||||
## v0.17.0 - _September 26, 2017_
|
||||
## v0.17.0 - _September 25, 2017_
|
||||
|
||||
* Made `zeroEx.exchange.getZRXTokenAddressAsync` public (#171)
|
||||
|
||||
## v0.16.0 - _September 20, 2017_
|
||||
## v0.16.0 - _September 19, 2017_
|
||||
|
||||
* Added the ability to specify custom contract addresses to be used with 0x.js (#165)
|
||||
* ZeroExConfig.exchangeContractAddress
|
||||
@@ -205,48 +213,48 @@ CHANGELOG
|
||||
* ZeroExConfig.etherTokenContractAddress
|
||||
* Added `zeroEx.tokenRegistry.getContractAddressAsync` (#165)
|
||||
|
||||
## v0.15.0 - _September 8, 2017_
|
||||
## v0.15.0 - _September 7, 2017_
|
||||
|
||||
* Added the ability to specify a historical `blockNumber` at which to query the blockchain's state when calling a token or exchange method (#161)
|
||||
|
||||
## v0.14.2 - _September 7, 2017_
|
||||
## v0.14.2 - _September 6, 2017_
|
||||
|
||||
* Fixed an issue with bignumber.js types not found (#160)
|
||||
|
||||
## v0.14.1 - _September 7, 2017_
|
||||
## v0.14.1 - _September 6, 2017_
|
||||
|
||||
* Fixed an issue with Artifact type not found (#159)
|
||||
|
||||
## v0.14.0 - _September 6, 2017_
|
||||
## v0.14.0 - _September 5, 2017_
|
||||
|
||||
* Added `zeroEx.exchange.throwLogErrorsAsErrors` method to public interface (#157)
|
||||
* Fixed an issue with overlapping async intervals in `zeroEx.awaitTransactionMinedAsync` (#157)
|
||||
* Fixed an issue with log decoder returning `BigNumber`s as `strings` (#157)
|
||||
|
||||
## v0.13.0 - _September 6, 2017_
|
||||
## v0.13.0 - _September 5, 2017_
|
||||
|
||||
* Made all the functions submitting transactions to the network to immediately return transaction hash (#151)
|
||||
* Added `zeroEx.awaitTransactionMinedAsync` (#151)
|
||||
* Added `TransactionReceiptWithDecodedLogs`, `LogWithDecodedArgs`, `DecodedLogArgs` to public types (#151)
|
||||
* Added signature validation to `validateFillOrderThrowIfInvalidAsync` (#152)
|
||||
|
||||
## v0.12.1 - _September 2, 2017_
|
||||
## v0.12.1 - _September 1, 2017_
|
||||
|
||||
* Added the support for web3@1.x.x provider (#142)
|
||||
* Added the optional `zeroExConfig` parameter to the constructor of `ZeroEx` (#139)
|
||||
* Added the ability to specify `gasPrice` when instantiating `ZeroEx` (#139)
|
||||
|
||||
## v0.11.0 - _August 24, 2017_
|
||||
## v0.11.0 - _August 23, 2017_
|
||||
|
||||
* Added `zeroEx.token.setUnlimitedProxyAllowanceAsync` (#137)
|
||||
* Added `zeroEx.token.setUnlimitedAllowanceAsync` (#137)
|
||||
* Added `zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS` (#137)
|
||||
|
||||
## v0.10.4 - _August 24, 2017_
|
||||
## v0.10.4 - _August 23, 2017_
|
||||
|
||||
* Fixed a bug where checksummed addresses were being pulled from artifacts and not lower-cased. (#135)
|
||||
|
||||
## v0.10.1 - _August 24, 2017_
|
||||
## v0.10.1 - _August 23, 2017_
|
||||
|
||||
* Added `zeroEx.exchange.validateFillOrderThrowIfInvalidAsync` (#128)
|
||||
* Added `zeroEx.exchange.validateFillOrKillOrderThrowIfInvalidAsync` (#128)
|
||||
@@ -261,20 +269,20 @@ CHANGELOG
|
||||
* Added clear error message when checksummed address is passed to a public method (#124)
|
||||
* Fixes the description of `shouldThrowOnInsufficientBalanceOrAllowance` in docs (#127)
|
||||
|
||||
## v0.9.3 - _August 22, 2017_
|
||||
## v0.9.3 - _August 21, 2017_
|
||||
|
||||
* Update contract artifacts to include latest Kovan and Mainnet deploys (#118)
|
||||
|
||||
## v0.9.2 - _August 21, 2017_
|
||||
## v0.9.2 - _August 20, 2017_
|
||||
|
||||
* *This version was unpublished because of a publishing issue.*
|
||||
* Update contract artifacts to include latest Kovan and Mainnet deploys (#118)
|
||||
|
||||
## v0.9.1 - _August 16, 2017_
|
||||
## v0.9.1 - _August 15, 2017_
|
||||
|
||||
* Fixed the bug causing `zeroEx.token.getBalanceAsync()` to fail if no addresses available (#120)
|
||||
|
||||
## v0.9.0 - _July 26, 2017_
|
||||
## v0.9.0 - _July 25, 2017_
|
||||
|
||||
* Migrated to the new version of smart contracts (#101)
|
||||
* Removed the ability to call methods on multiple authorized Exchange smart contracts (#106)
|
||||
@@ -285,7 +293,7 @@ CHANGELOG
|
||||
* Updated to typescript v2.4 (#104)
|
||||
* Fixed an issue with incorrect balance/allowance validation when ZRX is one of the tokens traded (#109)
|
||||
|
||||
## v0.8.0 - _July 4, 2017_
|
||||
## v0.8.0 - _July 3, 2017_
|
||||
|
||||
* Added the ability to call methods on different authorized versions of the Exchange smart contract (#82)
|
||||
* Updated contract artifacts to reflect latest changes to the smart contracts (0xproject/contracts#59)
|
||||
@@ -298,35 +306,35 @@ CHANGELOG
|
||||
* `zeroEx.tokenRegistry.invalidateContractInstance`
|
||||
* Fixed the bug where `zeroEx.setProviderAsync` didn't invalidate etherToken contract's instance
|
||||
|
||||
## v0.7.1 - _June 26, 2017_
|
||||
## v0.7.1 - _June 25, 2017_
|
||||
|
||||
* Added the ability to convert Ether to wrapped Ether tokens and back via `zeroEx.etherToken.depostAsync` and `zeroEx.etherToken.withdrawAsync` (#81)
|
||||
|
||||
## v0.7.0 - _June 22, 2017_
|
||||
## v0.7.0 - _June 21, 2017_
|
||||
|
||||
* Added Kovan smart contract artifacts (#78)
|
||||
* Started returning fillAmount from `fillOrderAsync` and `fillUpToAsync` (#72)
|
||||
* Started returning cancelledAmount from `cancelOrderAsync` (#72)
|
||||
* Renamed type `LogCancelArgs` to `LogCancelContractEventArgs` and `LogFillArgs` to `LogFillContractEventArgs`
|
||||
|
||||
## v0.6.2 - _June 21, 2017_
|
||||
## v0.6.2 - _June 20, 2017_
|
||||
|
||||
* Reduced bundle size
|
||||
* Improved documentation
|
||||
|
||||
## v0.6.1 - _June 19, 2017_
|
||||
## v0.6.1 - _June 18, 2017_
|
||||
|
||||
* Improved documentation
|
||||
|
||||
## v0.6.0 - _June 19, 2017_
|
||||
## v0.6.0 - _June 18, 2017_
|
||||
|
||||
* Made `ZeroEx` class accept `Web3Provider` instance instead of `Web3` instance
|
||||
* Added types for contract event arguments
|
||||
|
||||
## v0.5.2 - _June 15, 2017_
|
||||
## v0.5.2 - _June 14, 2017_
|
||||
|
||||
* Fixed the bug in `postpublish` script that caused that only unminified UMD bundle was uploaded to release page
|
||||
|
||||
## v0.5.1 - _June 15, 2017_
|
||||
## v0.5.1 - _June 14, 2017_
|
||||
|
||||
* Added `postpublish` script to publish to Github Releases with assets.
|
||||
|
@@ -1,5 +1,9 @@
|
||||
## 0x.js
|
||||
|
||||
A TypeScript/Javascript library for interacting with the 0x protocol.
|
||||
|
||||
### Read the [Documentation](https://0xproject.com/docs/0xjs).
|
||||
|
||||
## Installation
|
||||
|
||||
0x.js ships as both a [UMD](https://github.com/umdjs/umd) module and a [CommonJS](https://en.wikipedia.org/wiki/CommonJS) package.
|
||||
@@ -38,10 +42,66 @@ Download the UMD module from our [releases page](https://github.com/0xProject/0x
|
||||
<script type="text/javascript" src="0x.js"></script>
|
||||
```
|
||||
|
||||
## Documentation
|
||||
## Contributing
|
||||
|
||||
Extensive documentation of 0x.js can be found on [our website][docs-url].
|
||||
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
|
||||
|
||||
[website-url]: https://0xproject.com/
|
||||
[whitepaper-url]: https://0xproject.com/pdfs/0x_white_paper.pdf
|
||||
[docs-url]: https://0xproject.com/docs/0xjs
|
||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
||||
|
||||
### Install dependencies
|
||||
|
||||
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
|
||||
|
||||
```bash
|
||||
yarn config set workspaces-experimental true
|
||||
```
|
||||
|
||||
Then install dependencies
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
You can also build this specific package by running the following from within its directory:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn build:watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
```bash
|
||||
yarn clean
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
```bash
|
||||
yarn lint
|
||||
```
|
||||
|
||||
### Run Tests
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "0x.js",
|
||||
"version": "0.34.0",
|
||||
"version": "0.35.0",
|
||||
"description": "A javascript library for interacting with the 0x protocol",
|
||||
"keywords": [
|
||||
"0x.js",
|
||||
@@ -27,6 +27,7 @@
|
||||
"build:commonjs": "tsc && copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"test:commonjs": "run-s build:commonjs run_mocha",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js --timeout 10000 --bail --exit",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
|
||||
"docs:stage": "yarn build && 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"
|
||||
@@ -59,15 +60,14 @@
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/abi-gen": "^0.2.8",
|
||||
"@0xproject/dev-utils": "^0.3.3",
|
||||
"@0xproject/monorepo-scripts": "^0.1.15",
|
||||
"@0xproject/tslint-config": "^0.4.13",
|
||||
"@0xproject/dev-utils": "^0.3.4",
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@types/bintrees": "^1.0.2",
|
||||
"@types/jsonschema": "^1.1.1",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/node": "^8.0.53",
|
||||
"@types/request": "2.47.0",
|
||||
"@types/sinon": "^2.2.2",
|
||||
"@types/uuid": "^3.4.2",
|
||||
"awesome-typescript-loader": "^3.1.3",
|
||||
@@ -83,26 +83,23 @@
|
||||
"opn-cli": "^3.1.0",
|
||||
"prettier": "^1.11.1",
|
||||
"request": "^2.81.0",
|
||||
"request-promise-native": "^1.0.5",
|
||||
"shx": "^0.2.2",
|
||||
"sinon": "^4.0.0",
|
||||
"source-map-support": "^0.5.0",
|
||||
"truffle-hdwallet-provider": "^0.0.3",
|
||||
"tslint": "5.8.0",
|
||||
"typedoc": "0xProject/typedoc",
|
||||
"types-bn": "^0.0.1",
|
||||
"typescript": "2.7.1",
|
||||
"web3-provider-engine": "^13.0.1",
|
||||
"webpack": "^3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.2.4",
|
||||
"@0xproject/base-contract": "^0.0.6",
|
||||
"@0xproject/json-schemas": "^0.7.18",
|
||||
"@0xproject/types": "^0.4.2",
|
||||
"@0xproject/typescript-typings": "^0.0.2",
|
||||
"@0xproject/utils": "^0.4.4",
|
||||
"@0xproject/web3-wrapper": "^0.4.0",
|
||||
"@0xproject/assert": "^0.2.5",
|
||||
"@0xproject/base-contract": "^0.1.0",
|
||||
"@0xproject/json-schemas": "^0.7.19",
|
||||
"@0xproject/types": "^0.5.0",
|
||||
"@0xproject/typescript-typings": "^0.0.3",
|
||||
"@0xproject/utils": "^0.5.0",
|
||||
"@0xproject/web3-wrapper": "^0.5.0",
|
||||
"bintrees": "^1.0.2",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereumjs-abi": "^0.6.4",
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { schemas, SchemaValidator } from '@0xproject/json-schemas';
|
||||
import { ECSignature, Order, SignedOrder, TransactionReceiptWithDecodedLogs } from '@0xproject/types';
|
||||
import { ECSignature, Order, Provider, SignedOrder, TransactionReceiptWithDecodedLogs } from '@0xproject/types';
|
||||
import { AbiDecoder, BigNumber, intervalUtils } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
@@ -15,7 +15,7 @@ import { OrderStateWatcher } from './order_watcher/order_state_watcher';
|
||||
import { zeroExConfigSchema } from './schemas/zero_ex_config_schema';
|
||||
import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema';
|
||||
import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema';
|
||||
import { OrderStateWatcherConfig, Web3Provider, ZeroExConfig, ZeroExError } from './types';
|
||||
import { OrderStateWatcherConfig, ZeroExConfig, ZeroExError } from './types';
|
||||
import { assert } from './utils/assert';
|
||||
import { constants } from './utils/constants';
|
||||
import { decorators } from './utils/decorators';
|
||||
@@ -58,7 +58,6 @@ export class ZeroEx {
|
||||
*/
|
||||
public proxy: TokenTransferProxyWrapper;
|
||||
private _web3Wrapper: Web3Wrapper;
|
||||
private _abiDecoder: AbiDecoder;
|
||||
/**
|
||||
* Verifies that the elliptic curve signature `signature` was generated
|
||||
* by signing `data` with the private key corresponding to the `signerAddress` address.
|
||||
@@ -116,10 +115,8 @@ export class ZeroEx {
|
||||
public static toUnitAmount(amount: BigNumber, decimals: number): BigNumber {
|
||||
assert.isValidBaseUnitAmount('amount', amount);
|
||||
assert.isNumber('decimals', decimals);
|
||||
|
||||
const aUnit = new BigNumber(10).pow(decimals);
|
||||
const unit = amount.div(aUnit);
|
||||
return unit;
|
||||
const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);
|
||||
return unitAmount;
|
||||
}
|
||||
/**
|
||||
* A baseUnit is defined as the smallest denomination of a token. An amount expressed in baseUnits
|
||||
@@ -132,13 +129,7 @@ export class ZeroEx {
|
||||
public static toBaseUnitAmount(amount: BigNumber, decimals: number): BigNumber {
|
||||
assert.isBigNumber('amount', amount);
|
||||
assert.isNumber('decimals', decimals);
|
||||
|
||||
const unit = new BigNumber(10).pow(decimals);
|
||||
const baseUnitAmount = amount.times(unit);
|
||||
const hasDecimals = baseUnitAmount.decimalPlaces() !== 0;
|
||||
if (hasDecimals) {
|
||||
throw new Error(`Invalid unit amount: ${amount.toString()} - Too many decimal places`);
|
||||
}
|
||||
const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amount, decimals);
|
||||
return baseUnitAmount;
|
||||
}
|
||||
/**
|
||||
@@ -154,12 +145,12 @@ export class ZeroEx {
|
||||
}
|
||||
/**
|
||||
* Instantiates a new ZeroEx instance that provides the public interface to the 0x.js library.
|
||||
* @param provider The Web3.js Provider instance you would like the 0x.js library to use for interacting with
|
||||
* @param provider The Provider instance you would like the 0x.js library to use for interacting with
|
||||
* 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: Web3Provider, config: ZeroExConfig) {
|
||||
constructor(provider: Provider, config: ZeroExConfig) {
|
||||
assert.isWeb3Provider('provider', provider);
|
||||
assert.doesConformToSchema('config', config, zeroExConfigSchema, [
|
||||
zeroExPrivateNetworkConfigSchema,
|
||||
@@ -167,21 +158,22 @@ export class ZeroEx {
|
||||
]);
|
||||
const artifactJSONs = _.values(artifacts);
|
||||
const abiArrays = _.map(artifactJSONs, artifact => artifact.abi);
|
||||
this._abiDecoder = new AbiDecoder(abiArrays);
|
||||
const defaults = {
|
||||
gasPrice: config.gasPrice,
|
||||
};
|
||||
this._web3Wrapper = new Web3Wrapper(provider, defaults);
|
||||
_.forEach(abiArrays, abi => {
|
||||
this._web3Wrapper.abiDecoder.addABI(abi);
|
||||
});
|
||||
this.proxy = new TokenTransferProxyWrapper(
|
||||
this._web3Wrapper,
|
||||
config.networkId,
|
||||
config.tokenTransferProxyContractAddress,
|
||||
);
|
||||
this.token = new TokenWrapper(this._web3Wrapper, config.networkId, this._abiDecoder, this.proxy);
|
||||
this.token = new TokenWrapper(this._web3Wrapper, config.networkId, this.proxy);
|
||||
this.exchange = new ExchangeWrapper(
|
||||
this._web3Wrapper,
|
||||
config.networkId,
|
||||
this._abiDecoder,
|
||||
this.token,
|
||||
config.exchangeContractAddress,
|
||||
config.zrxContractAddress,
|
||||
@@ -191,7 +183,7 @@ export class ZeroEx {
|
||||
config.networkId,
|
||||
config.tokenRegistryContractAddress,
|
||||
);
|
||||
this.etherToken = new EtherTokenWrapper(this._web3Wrapper, config.networkId, this._abiDecoder, this.token);
|
||||
this.etherToken = new EtherTokenWrapper(this._web3Wrapper, config.networkId, this.token);
|
||||
}
|
||||
/**
|
||||
* Sets a new web3 provider for 0x.js. Updating the provider will stop all
|
||||
@@ -199,7 +191,7 @@ export class ZeroEx {
|
||||
* @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: Web3Provider, networkId: number): void {
|
||||
public setProvider(provider: Provider, networkId: number): void {
|
||||
this._web3Wrapper.setProvider(provider);
|
||||
(this.exchange as any)._invalidateContractInstances();
|
||||
(this.exchange as any)._setNetworkId(networkId);
|
||||
@@ -225,7 +217,7 @@ export class ZeroEx {
|
||||
* 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 Web3.Provider supplied to 0x.js.
|
||||
* must be available via the Provider supplied to 0x.js.
|
||||
* @param shouldAddPersonalMessagePrefix Some signers add the personal message prefix `\x19Ethereum Signed Message`
|
||||
* themselves (e.g Parity Signer, Ledger, TestRPC) and others expect it to already be done by the client
|
||||
* (e.g Metamask). Depending on which signer this request is going to, decide on whether to add the prefix
|
||||
@@ -285,44 +277,12 @@ export class ZeroEx {
|
||||
pollingIntervalMs = 1000,
|
||||
timeoutMs?: number,
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
let timeoutExceeded = false;
|
||||
if (timeoutMs) {
|
||||
setTimeout(() => (timeoutExceeded = true), timeoutMs);
|
||||
}
|
||||
|
||||
const txReceiptPromise = new Promise(
|
||||
(resolve: (receipt: TransactionReceiptWithDecodedLogs) => void, reject) => {
|
||||
const intervalId = intervalUtils.setAsyncExcludingInterval(
|
||||
async () => {
|
||||
if (timeoutExceeded) {
|
||||
intervalUtils.clearAsyncExcludingInterval(intervalId);
|
||||
return reject(ZeroExError.TransactionMiningTimeout);
|
||||
}
|
||||
|
||||
const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash);
|
||||
if (!_.isNull(transactionReceipt)) {
|
||||
intervalUtils.clearAsyncExcludingInterval(intervalId);
|
||||
const logsWithDecodedArgs = _.map(
|
||||
transactionReceipt.logs,
|
||||
this._abiDecoder.tryToDecodeLogOrNoop.bind(this._abiDecoder),
|
||||
);
|
||||
const transactionReceiptWithDecodedLogArgs: TransactionReceiptWithDecodedLogs = {
|
||||
...transactionReceipt,
|
||||
logs: logsWithDecodedArgs,
|
||||
};
|
||||
resolve(transactionReceiptWithDecodedLogArgs);
|
||||
}
|
||||
},
|
||||
pollingIntervalMs,
|
||||
(err: Error) => {
|
||||
intervalUtils.clearAsyncExcludingInterval(intervalId);
|
||||
reject(err);
|
||||
},
|
||||
);
|
||||
},
|
||||
const transactionReceiptWithDecodedLogs = await this._web3Wrapper.awaitTransactionMinedAsync(
|
||||
txHash,
|
||||
pollingIntervalMs,
|
||||
timeoutMs,
|
||||
);
|
||||
const txReceipt = await txReceiptPromise;
|
||||
return txReceipt;
|
||||
return transactionReceiptWithDecodedLogs;
|
||||
}
|
||||
/**
|
||||
* Instantiates and returns a new OrderStateWatcher instance.
|
||||
@@ -331,7 +291,7 @@ export class ZeroEx {
|
||||
* @return An instance of the 0x.js OrderStateWatcher class.
|
||||
*/
|
||||
public createOrderStateWatcher(config?: OrderStateWatcherConfig) {
|
||||
return new OrderStateWatcher(this._web3Wrapper, this._abiDecoder, this.token, this.exchange, config);
|
||||
return new OrderStateWatcher(this._web3Wrapper, this.token, this.exchange, config);
|
||||
}
|
||||
/*
|
||||
* HACK: `TokenWrapper` needs a token transfer proxy address. `TokenTransferProxy` address is fetched from
|
||||
|
@@ -32,7 +32,6 @@ const CONTRACT_NAME_TO_NOT_FOUND_ERROR: {
|
||||
export class ContractWrapper {
|
||||
protected _web3Wrapper: Web3Wrapper;
|
||||
protected _networkId: number;
|
||||
private _abiDecoder?: AbiDecoder;
|
||||
private _blockAndLogStreamerIfExists?: BlockAndLogStreamer;
|
||||
private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer;
|
||||
private _filters: { [filterToken: string]: FilterObject };
|
||||
@@ -41,10 +40,9 @@ export class ContractWrapper {
|
||||
};
|
||||
private _onLogAddedSubscriptionToken: string | undefined;
|
||||
private _onLogRemovedSubscriptionToken: string | undefined;
|
||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, abiDecoder?: AbiDecoder) {
|
||||
constructor(web3Wrapper: Web3Wrapper, networkId: number) {
|
||||
this._web3Wrapper = web3Wrapper;
|
||||
this._networkId = networkId;
|
||||
this._abiDecoder = abiDecoder;
|
||||
this._filters = {};
|
||||
this._filterCallbacks = {};
|
||||
this._blockAndLogStreamerIfExists = undefined;
|
||||
@@ -102,10 +100,10 @@ export class ContractWrapper {
|
||||
protected _tryToDecodeLogOrNoop<ArgsType extends ContractEventArgs>(
|
||||
log: LogEntry,
|
||||
): LogWithDecodedArgs<ArgsType> | RawLog {
|
||||
if (_.isUndefined(this._abiDecoder)) {
|
||||
if (_.isUndefined(this._web3Wrapper.abiDecoder)) {
|
||||
throw new Error(InternalZeroExError.NoAbiDecoder);
|
||||
}
|
||||
const logWithDecodedArgs = this._abiDecoder.tryToDecodeLogOrNoop(log);
|
||||
const logWithDecodedArgs = this._web3Wrapper.abiDecoder.tryToDecodeLogOrNoop(log);
|
||||
return logWithDecodedArgs;
|
||||
}
|
||||
protected async _getContractAbiAndAddressFromArtifactsAsync(
|
||||
|
@@ -21,8 +21,8 @@ export class EtherTokenWrapper extends ContractWrapper {
|
||||
[address: string]: EtherTokenContract;
|
||||
} = {};
|
||||
private _tokenWrapper: TokenWrapper;
|
||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, abiDecoder: AbiDecoder, tokenWrapper: TokenWrapper) {
|
||||
super(web3Wrapper, networkId, abiDecoder);
|
||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, tokenWrapper: TokenWrapper) {
|
||||
super(web3Wrapper, networkId);
|
||||
this._tokenWrapper = tokenWrapper;
|
||||
}
|
||||
/**
|
||||
@@ -191,7 +191,12 @@ export class EtherTokenWrapper extends ContractWrapper {
|
||||
artifacts.EtherTokenArtifact,
|
||||
etherTokenAddress,
|
||||
);
|
||||
const contractInstance = new EtherTokenContract(this._web3Wrapper, abi, address);
|
||||
const contractInstance = new EtherTokenContract(
|
||||
abi,
|
||||
address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
etherTokenContract = contractInstance;
|
||||
this._etherTokenContractsByAddress[etherTokenAddress] = etherTokenContract;
|
||||
return etherTokenContract;
|
||||
|
@@ -87,12 +87,11 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
constructor(
|
||||
web3Wrapper: Web3Wrapper,
|
||||
networkId: number,
|
||||
abiDecoder: AbiDecoder,
|
||||
tokenWrapper: TokenWrapper,
|
||||
contractAddressIfExists?: string,
|
||||
zrxContractAddressIfExists?: string,
|
||||
) {
|
||||
super(web3Wrapper, networkId, abiDecoder);
|
||||
super(web3Wrapper, networkId);
|
||||
this._tokenWrapper = tokenWrapper;
|
||||
this._orderValidationUtils = new OrderValidationUtils(this);
|
||||
this._contractAddressIfExists = contractAddressIfExists;
|
||||
@@ -171,7 +170,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
* @param shouldThrowOnInsufficientBalanceOrAllowance Whether or not you wish for the contract call to throw
|
||||
* if upon execution the tokens cannot be transferred.
|
||||
* @param takerAddress The user Ethereum address who would like to fill this order.
|
||||
* Must be available via the supplied Web3.Provider
|
||||
* Must be available via the supplied Provider
|
||||
* passed to 0x.js.
|
||||
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||
* @return Transaction hash.
|
||||
@@ -236,7 +235,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
* If set to false, the call will continue to fill subsequent
|
||||
* signedOrders even when some cannot be filled.
|
||||
* @param takerAddress The user Ethereum address who would like to fill these
|
||||
* orders. Must be available via the supplied Web3.Provider
|
||||
* orders. Must be available via the supplied Provider
|
||||
* passed to 0x.js.
|
||||
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||
* @return Transaction hash.
|
||||
@@ -336,7 +335,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
* cannot be filled.
|
||||
* @param takerAddress The user Ethereum address who would like to fill
|
||||
* these orders. Must be available via the supplied
|
||||
* Web3.Provider passed to 0x.js.
|
||||
* Provider passed to 0x.js.
|
||||
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||
* @return Transaction hash.
|
||||
*/
|
||||
@@ -417,7 +416,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
* signedOrder you wish to fill.
|
||||
* @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill.
|
||||
* @param takerAddress The user Ethereum address who would like to fill this order.
|
||||
* Must be available via the supplied Web3.Provider passed to 0x.js.
|
||||
* Must be available via the supplied Provider passed to 0x.js.
|
||||
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||
* @return Transaction hash.
|
||||
*/
|
||||
@@ -471,7 +470,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
* filled (each to the specified fillAmount) or aborted.
|
||||
* @param orderFillRequests An array of objects that conform to the OrderFillRequest interface.
|
||||
* @param takerAddress The user Ethereum address who would like to fill there orders.
|
||||
* Must be available via the supplied Web3.Provider passed to 0x.js.
|
||||
* Must be available via the supplied Provider passed to 0x.js.
|
||||
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||
* @return Transaction hash.
|
||||
*/
|
||||
@@ -766,7 +765,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
* signedOrder you wish to fill.
|
||||
* @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill.
|
||||
* @param takerAddress The user Ethereum address who would like to fill this order.
|
||||
* Must be available via the supplied Web3.Provider passed to 0x.js.
|
||||
* Must be available via the supplied Provider passed to 0x.js.
|
||||
*/
|
||||
public async validateFillOrderThrowIfInvalidAsync(
|
||||
signedOrder: SignedOrder,
|
||||
@@ -813,7 +812,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
* signedOrder you wish to fill.
|
||||
* @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill.
|
||||
* @param takerAddress The user Ethereum address who would like to fill this order.
|
||||
* Must be available via the supplied Web3.Provider passed to 0x.js.
|
||||
* Must be available via the supplied Provider passed to 0x.js.
|
||||
*/
|
||||
public async validateFillOrKillOrderThrowIfInvalidAsync(
|
||||
signedOrder: SignedOrder,
|
||||
@@ -921,7 +920,12 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
artifacts.ExchangeArtifact,
|
||||
this._contractAddressIfExists,
|
||||
);
|
||||
const contractInstance = new ExchangeContract(this._web3Wrapper, abi, address);
|
||||
const contractInstance = new ExchangeContract(
|
||||
abi,
|
||||
address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
this._exchangeContractIfExists = contractInstance;
|
||||
return this._exchangeContractIfExists;
|
||||
}
|
||||
|
@@ -121,7 +121,12 @@ export class TokenRegistryWrapper extends ContractWrapper {
|
||||
artifacts.TokenRegistryArtifact,
|
||||
this._contractAddressIfExists,
|
||||
);
|
||||
const contractInstance = new TokenRegistryContract(this._web3Wrapper, abi, address);
|
||||
const contractInstance = new TokenRegistryContract(
|
||||
abi,
|
||||
address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
this._tokenRegistryContractIfExists = contractInstance;
|
||||
return this._tokenRegistryContractIfExists;
|
||||
}
|
||||
|
@@ -63,7 +63,12 @@ export class TokenTransferProxyWrapper extends ContractWrapper {
|
||||
artifacts.TokenTransferProxyArtifact,
|
||||
this._contractAddressIfExists,
|
||||
);
|
||||
const contractInstance = new TokenTransferProxyContract(this._web3Wrapper, abi, address);
|
||||
const contractInstance = new TokenTransferProxyContract(
|
||||
abi,
|
||||
address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
this._tokenTransferProxyContractIfExists = contractInstance;
|
||||
return this._tokenTransferProxyContractIfExists;
|
||||
}
|
||||
|
@@ -22,13 +22,8 @@ export class TokenWrapper extends ContractWrapper {
|
||||
public UNLIMITED_ALLOWANCE_IN_BASE_UNITS = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
|
||||
private _tokenContractsByAddress: { [address: string]: TokenContract };
|
||||
private _tokenTransferProxyWrapper: TokenTransferProxyWrapper;
|
||||
constructor(
|
||||
web3Wrapper: Web3Wrapper,
|
||||
networkId: number,
|
||||
abiDecoder: AbiDecoder,
|
||||
tokenTransferProxyWrapper: TokenTransferProxyWrapper,
|
||||
) {
|
||||
super(web3Wrapper, networkId, abiDecoder);
|
||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, tokenTransferProxyWrapper: TokenTransferProxyWrapper) {
|
||||
super(web3Wrapper, networkId);
|
||||
this._tokenContractsByAddress = {};
|
||||
this._tokenTransferProxyWrapper = tokenTransferProxyWrapper;
|
||||
}
|
||||
@@ -426,7 +421,12 @@ export class TokenWrapper extends ContractWrapper {
|
||||
artifacts.TokenArtifact,
|
||||
normalizedTokenAddress,
|
||||
);
|
||||
const contractInstance = new TokenContract(this._web3Wrapper, abi, address);
|
||||
const contractInstance = new TokenContract(
|
||||
abi,
|
||||
address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
tokenContract = contractInstance;
|
||||
this._tokenContractsByAddress[normalizedTokenAddress] = tokenContract;
|
||||
return tokenContract;
|
||||
|
44
packages/0x.js/src/globals.d.ts
vendored
44
packages/0x.js/src/globals.d.ts
vendored
@@ -1,50 +1,6 @@
|
||||
declare module 'web3_beta';
|
||||
declare module 'chai-bignumber';
|
||||
declare module 'dirty-chai';
|
||||
declare module 'request-promise-native';
|
||||
declare module 'web3-provider-engine';
|
||||
declare module 'web3-provider-engine/subproviders/rpc';
|
||||
declare module 'publish-release';
|
||||
|
||||
// semver-sort declarations
|
||||
declare module 'semver-sort' {
|
||||
const desc: (versions: string[]) => string[];
|
||||
}
|
||||
|
||||
// HACK: In order to merge the bignumber declaration added by chai-bignumber to the chai Assertion
|
||||
// interface we must use `namespace` as the Chai definitelyTyped definition does. Since we otherwise
|
||||
// disallow `namespace`, we disable tslint for the following.
|
||||
/* tslint:disable */
|
||||
declare namespace Chai {
|
||||
interface Assertion {
|
||||
bignumber: Assertion;
|
||||
// HACK: In order to comply with chai-as-promised we make eventually a `PromisedAssertion` not an `Assertion`
|
||||
eventually: PromisedAssertion;
|
||||
}
|
||||
}
|
||||
/* tslint:enable */
|
||||
|
||||
declare module '*.json' {
|
||||
const json: any;
|
||||
/* tslint:disable */
|
||||
export default json;
|
||||
/* tslint:enable */
|
||||
}
|
||||
|
||||
declare module 'ethereumjs-abi' {
|
||||
const soliditySHA3: (argTypes: string[], args: any[]) => Buffer;
|
||||
}
|
||||
|
||||
// truffle-hdwallet-provider declarations
|
||||
declare module 'truffle-hdwallet-provider' {
|
||||
import { JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types';
|
||||
import * as Web3 from 'web3';
|
||||
class HDWalletProvider implements Web3.Provider {
|
||||
constructor(mnemonic: string, rpcUrl: string);
|
||||
public sendAsync(
|
||||
payload: JSONRPCRequestPayload,
|
||||
callback: (err: Error, result: JSONRPCResponsePayload) => void,
|
||||
): void;
|
||||
}
|
||||
export = HDWalletProvider;
|
||||
}
|
||||
|
23
packages/0x.js/src/globalsAugment.d.ts
vendored
23
packages/0x.js/src/globalsAugment.d.ts
vendored
@@ -1,23 +0,0 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
// HACK: This module overrides the Chai namespace so that we can use BigNumber types inside.
|
||||
// Source: https://github.com/Microsoft/TypeScript/issues/7352#issuecomment-191547232
|
||||
declare global {
|
||||
// HACK: In order to merge the bignumber declaration added by chai-bignumber to the chai Assertion
|
||||
// interface we must use `namespace` as the Chai definitelyTyped definition does. Since we otherwise
|
||||
// disallow `namespace`, we disable tslint for the following.
|
||||
/* tslint:disable */
|
||||
namespace Chai {
|
||||
interface NumberComparer {
|
||||
(value: number | BigNumber, message?: string): Assertion;
|
||||
}
|
||||
interface NumericComparison {
|
||||
greaterThan: NumberComparer;
|
||||
}
|
||||
}
|
||||
/* tslint:enable */
|
||||
interface DecodedLogArg {
|
||||
name: string;
|
||||
value: string | BigNumber;
|
||||
}
|
||||
}
|
@@ -11,7 +11,6 @@ export {
|
||||
OrderCancellationRequest,
|
||||
OrderFillRequest,
|
||||
ContractEventArgs,
|
||||
Web3Provider,
|
||||
ZeroExConfig,
|
||||
MethodOpts,
|
||||
OrderTransactionOpts,
|
||||
@@ -32,6 +31,7 @@ export {
|
||||
ContractEventArg,
|
||||
LogWithDecodedArgs,
|
||||
Order,
|
||||
Provider,
|
||||
SignedOrder,
|
||||
ECSignature,
|
||||
TransactionReceipt,
|
||||
|
@@ -69,7 +69,6 @@ export class OrderStateWatcher {
|
||||
private _callbackIfExists?: OnOrderStateChangeCallback;
|
||||
private _eventWatcher: EventWatcher;
|
||||
private _web3Wrapper: Web3Wrapper;
|
||||
private _abiDecoder: AbiDecoder;
|
||||
private _expirationWatcher: ExpirationWatcher;
|
||||
private _orderStateUtils: OrderStateUtils;
|
||||
private _orderFilledCancelledLazyStore: OrderFilledCancelledLazyStore;
|
||||
@@ -78,12 +77,10 @@ export class OrderStateWatcher {
|
||||
private _cleanupJobIntervalIdIfExists?: NodeJS.Timer;
|
||||
constructor(
|
||||
web3Wrapper: Web3Wrapper,
|
||||
abiDecoder: AbiDecoder,
|
||||
token: TokenWrapper,
|
||||
exchange: ExchangeWrapper,
|
||||
config?: OrderStateWatcherConfig,
|
||||
) {
|
||||
this._abiDecoder = abiDecoder;
|
||||
this._web3Wrapper = web3Wrapper;
|
||||
const pollingIntervalIfExistsMs = _.isUndefined(config) ? undefined : config.eventPollingIntervalMs;
|
||||
const stateLayer =
|
||||
@@ -230,7 +227,7 @@ export class OrderStateWatcher {
|
||||
return;
|
||||
}
|
||||
const log = logIfExists as LogEvent; // At this moment we are sure that no error occured and log is defined.
|
||||
const maybeDecodedLog = this._abiDecoder.tryToDecodeLogOrNoop<ContractEventArgs>(log);
|
||||
const maybeDecodedLog = this._web3Wrapper.abiDecoder.tryToDecodeLogOrNoop<ContractEventArgs>(log);
|
||||
const isLogDecoded = !_.isUndefined(((maybeDecodedLog as any) as LogWithDecodedArgs<ContractEventArgs>).event);
|
||||
if (!isLogDecoded) {
|
||||
return; // noop
|
||||
|
@@ -38,7 +38,6 @@ export enum ZeroExError {
|
||||
NoNetworkId = 'NO_NETWORK_ID',
|
||||
SubscriptionNotFound = 'SUBSCRIPTION_NOT_FOUND',
|
||||
SubscriptionAlreadyPresent = 'SUBSCRIPTION_ALREADY_PRESENT',
|
||||
TransactionMiningTimeout = 'TRANSACTION_MINING_TIMEOUT',
|
||||
}
|
||||
|
||||
export enum InternalZeroExError {
|
||||
@@ -155,14 +154,6 @@ export interface OrderFillRequest {
|
||||
export type AsyncMethod = (...args: any[]) => Promise<any>;
|
||||
export type SyncMethod = (...args: any[]) => any;
|
||||
|
||||
/**
|
||||
* We re-export the `Web3.Provider` type specified in the Web3 Typescript typings
|
||||
* since it is the type of the `provider` argument to the `ZeroEx` constructor.
|
||||
* It is however a `Web3` library type, not a native `0x.js` type. To learn more
|
||||
* about providers, visit https://0xproject.com/wiki#Web3-Provider-Explained
|
||||
*/
|
||||
export type Web3Provider = Web3.Provider;
|
||||
|
||||
/*
|
||||
* orderExpirationCheckingIntervalMs: How often to check for expired orders. Default: 50
|
||||
* eventPollingIntervalMs: How often to poll the Ethereum node for new events. Default: 200
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as chai from 'chai';
|
||||
import 'mocha';
|
||||
import * as Web3 from 'web3';
|
||||
@@ -59,7 +60,7 @@ describe('EtherTokenWrapper', () => {
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
addressWithETH = userAddresses[0];
|
||||
wethContractAddress = zeroEx.etherToken.getContractAddressIfExists() as string;
|
||||
depositWeiAmount = (zeroEx as any)._web3Wrapper.toWei(new BigNumber(5));
|
||||
depositWeiAmount = Web3Wrapper.toWei(new BigNumber(5));
|
||||
decimalPlaces = 7;
|
||||
addressWithoutFunds = userAddresses[1];
|
||||
});
|
||||
@@ -105,7 +106,7 @@ describe('EtherTokenWrapper', () => {
|
||||
it('should throw if user has insufficient ETH balance for deposit', async () => {
|
||||
const preETHBalance = await (zeroEx as any)._web3Wrapper.getBalanceInWeiAsync(addressWithETH);
|
||||
|
||||
const extraETHBalance = (zeroEx as any)._web3Wrapper.toWei(5, 'ether');
|
||||
const extraETHBalance = Web3Wrapper.toWei(new BigNumber(5));
|
||||
const overETHBalanceinWei = preETHBalance.add(extraETHBalance);
|
||||
|
||||
return expect(
|
||||
|
@@ -36,7 +36,12 @@ export class FillScenarios {
|
||||
for (const token of this._tokens) {
|
||||
if (token.symbol !== 'ZRX' && token.symbol !== 'WETH') {
|
||||
const defaults = {};
|
||||
const dummyToken = new DummyTokenContract(web3Wrapper, artifacts.DummyTokenArtifact.abi, token.address);
|
||||
const dummyToken = new DummyTokenContract(
|
||||
artifacts.DummyTokenArtifact.abi,
|
||||
token.address,
|
||||
web3Wrapper.getProvider(),
|
||||
web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const tokenSupply = ZeroEx.toBaseUnitAmount(INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS, token.decimals);
|
||||
const txHash = await dummyToken.setBalance.sendTransactionAsync(this._coinbase, tokenSupply, {
|
||||
from: this._coinbase,
|
||||
|
@@ -1,13 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "lib",
|
||||
"noImplicitThis": false
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*",
|
||||
"./test/**/*",
|
||||
"../../node_modules/types-bn/index.d.ts",
|
||||
"../../node_modules/types-ethereumjs-util/index.d.ts"
|
||||
]
|
||||
"include": ["./src/**/*", "./test/**/*"]
|
||||
}
|
||||
|
@@ -1,4 +1,22 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1523462196,
|
||||
"version": "0.2.10",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1522673609,
|
||||
"version": "0.2.9",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1522658513,
|
||||
"version": "0.2.8",
|
||||
@@ -16,8 +34,7 @@
|
||||
"pr": 452
|
||||
}
|
||||
],
|
||||
"timestamp": 1521298800,
|
||||
"isPublished": true
|
||||
"timestamp": 1521298800
|
||||
},
|
||||
{
|
||||
"version": "0.2.4",
|
||||
@@ -37,8 +54,7 @@
|
||||
"pr": 413
|
||||
}
|
||||
],
|
||||
"timestamp": 1520089200,
|
||||
"isPublished": true
|
||||
"timestamp": 1520089200
|
||||
},
|
||||
{
|
||||
"version": "0.2.1",
|
||||
@@ -48,8 +64,7 @@
|
||||
"pr": 389
|
||||
}
|
||||
],
|
||||
"timestamp": 1518102000,
|
||||
"isPublished": true
|
||||
"timestamp": 1518102000
|
||||
},
|
||||
{
|
||||
"version": "0.2.0",
|
||||
@@ -64,8 +79,7 @@
|
||||
"pr": 388
|
||||
}
|
||||
],
|
||||
"timestamp": 1517929200,
|
||||
"isPublished": true
|
||||
"timestamp": 1517929200
|
||||
},
|
||||
{
|
||||
"version": "0.1.0",
|
||||
@@ -83,7 +97,6 @@
|
||||
"pr": 304
|
||||
}
|
||||
],
|
||||
"timestamp": 1515596400,
|
||||
"isPublished": true
|
||||
"timestamp": 1515596400
|
||||
}
|
||||
]
|
||||
|
@@ -5,30 +5,38 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.2.10 - _April 11, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.9 - _April 2, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.8 - _April 2, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.5 - _March 18, 2018_
|
||||
## v0.2.5 - _March 17, 2018_
|
||||
|
||||
* Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package (#452)
|
||||
|
||||
## v0.2.4 - _March 4, 2018_
|
||||
## v0.2.4 - _March 3, 2018_
|
||||
|
||||
* Add a `backend` parameter that allows you to specify the Ethereum library you use in your templates (`web3` or `ethers`). Ethers auto-converts small ints to numbers whereas Web3 doesn't. Defaults to `web3` (#413)
|
||||
* Add support for [tuple types](https://solidity.readthedocs.io/en/develop/abi-spec.html#handling-tuple-types) (#413)
|
||||
* Add `hasReturnValue` to context data (#413)
|
||||
|
||||
## v0.2.1 - _February 9, 2018_
|
||||
## v0.2.1 - _February 8, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.2.0 - _February 7, 2018_
|
||||
## v0.2.0 - _February 6, 2018_
|
||||
|
||||
* Added CLI options for explicit specifying location of partials and main template (#346)
|
||||
* Added CLI option to specify networkId, adding support for the JSON artifact format found in @0xproject/contracts (#388)
|
||||
|
||||
## v0.1.0 - _January 11, 2018_
|
||||
## v0.1.0 - _January 10, 2018_
|
||||
|
||||
* Fixed array typings with union types (#295)
|
||||
* Add event ABIs to context data passed to templates (#302)
|
||||
|
@@ -57,3 +57,61 @@ See the [type definition](https://github.com/0xProject/0x-monorepo/tree/developm
|
||||
## Output files
|
||||
|
||||
Output files will be generated within an output folder with names converted to camel case and taken from abi file names. If you already have some files in that folder they will be overwritten.
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
|
||||
|
||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
||||
|
||||
### Install dependencies
|
||||
|
||||
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
|
||||
|
||||
```bash
|
||||
yarn config set workspaces-experimental true
|
||||
```
|
||||
|
||||
Then install dependencies
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
You can also build this specific package by running the following from within its directory:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn build:watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
```bash
|
||||
yarn clean
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
```bash
|
||||
yarn lint
|
||||
```
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/abi-gen",
|
||||
"version": "0.2.8",
|
||||
"version": "0.2.9",
|
||||
"description": "Generate contract wrappers from ABI and handlebars templates",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
@@ -8,7 +8,8 @@
|
||||
"build:watch": "tsc -w",
|
||||
"lint": "tslint --project . 'src/**/*.ts'",
|
||||
"clean": "shx rm -rf lib scripts",
|
||||
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts"
|
||||
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
||||
},
|
||||
"bin": {
|
||||
"abi-gen": "lib/index.js"
|
||||
@@ -23,9 +24,9 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/types": "^0.4.2",
|
||||
"@0xproject/typescript-typings": "^0.0.2",
|
||||
"@0xproject/utils": "^0.4.4",
|
||||
"@0xproject/types": "^0.5.0",
|
||||
"@0xproject/typescript-typings": "^0.0.3",
|
||||
"@0xproject/utils": "^0.5.0",
|
||||
"chalk": "^2.3.0",
|
||||
"glob": "^7.1.2",
|
||||
"handlebars": "^4.0.11",
|
||||
@@ -35,8 +36,8 @@
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.15",
|
||||
"@0xproject/tslint-config": "^0.4.13",
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@types/glob": "^5.0.33",
|
||||
"@types/handlebars": "^4.0.36",
|
||||
"@types/mkdirp": "^0.5.1",
|
||||
|
5
packages/abi-gen/src/globals.d.ts
vendored
5
packages/abi-gen/src/globals.d.ts
vendored
@@ -1,8 +1,3 @@
|
||||
declare function toSnakeCase(str: string): string;
|
||||
declare module 'to-snake-case' {
|
||||
export = toSnakeCase;
|
||||
}
|
||||
|
||||
declare module '*.json' {
|
||||
const json: any;
|
||||
/* tslint:disable */
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from '@0xproject/types';
|
||||
import { logUtils } from '@0xproject/utils';
|
||||
import { abiUtils, logUtils } from '@0xproject/utils';
|
||||
import chalk from 'chalk';
|
||||
import * as fs from 'fs';
|
||||
import { sync as globSync } from 'glob';
|
||||
@@ -12,7 +12,7 @@ import * as yargs from 'yargs';
|
||||
|
||||
import toSnakeCase = require('to-snake-case');
|
||||
|
||||
import { ContextData, ContractsBackend, ParamKind } from './types';
|
||||
import { ContextData, ContractsBackend, Method, ParamKind } from './types';
|
||||
import { utils } from './utils';
|
||||
|
||||
const ABI_TYPE_CONSTRUCTOR = 'constructor';
|
||||
@@ -83,7 +83,6 @@ function writeOutputFile(name: string, renderedTsCode: string): void {
|
||||
|
||||
Handlebars.registerHelper('parameterType', utils.solTypeToTsType.bind(utils, ParamKind.Input, args.backend));
|
||||
Handlebars.registerHelper('returnType', utils.solTypeToTsType.bind(utils, ParamKind.Output, args.backend));
|
||||
|
||||
if (args.partials) {
|
||||
registerPartials(args.partials);
|
||||
}
|
||||
@@ -126,11 +125,12 @@ for (const abiFileName of abiFileNames) {
|
||||
}
|
||||
|
||||
const methodAbis = ABI.filter((abi: AbiDefinition) => abi.type === ABI_TYPE_METHOD) as MethodAbi[];
|
||||
const methodsData = _.map(methodAbis, methodAbi => {
|
||||
_.map(methodAbi.inputs, (input, i: number) => {
|
||||
const sanitizedMethodAbis = abiUtils.renameOverloadedMethods(methodAbis) as MethodAbi[];
|
||||
const methodsData = _.map(methodAbis, (methodAbi, methodAbiIndex: number) => {
|
||||
_.forEach(methodAbi.inputs, (input, inputIndex: number) => {
|
||||
if (_.isEmpty(input.name)) {
|
||||
// Auto-generated getters don't have parameter names
|
||||
input.name = `index_${i}`;
|
||||
input.name = `index_${inputIndex}`;
|
||||
}
|
||||
});
|
||||
// This will make templates simpler
|
||||
@@ -138,6 +138,8 @@ for (const abiFileName of abiFileNames) {
|
||||
...methodAbi,
|
||||
singleReturnValue: methodAbi.outputs.length === 1,
|
||||
hasReturnValue: methodAbi.outputs.length !== 0,
|
||||
tsName: sanitizedMethodAbis[methodAbiIndex].name,
|
||||
functionSignature: abiUtils.getFunctionSignature(methodAbi),
|
||||
};
|
||||
return methodData;
|
||||
});
|
||||
|
@@ -5,13 +5,6 @@ export enum ParamKind {
|
||||
Output = 'output',
|
||||
}
|
||||
|
||||
export enum AbiType {
|
||||
Function = 'function',
|
||||
Constructor = 'constructor',
|
||||
Event = 'event',
|
||||
Fallback = 'fallback',
|
||||
}
|
||||
|
||||
export enum ContractsBackend {
|
||||
Web3 = 'web3',
|
||||
Ethers = 'ethers',
|
||||
@@ -20,6 +13,8 @@ export enum ContractsBackend {
|
||||
export interface Method extends MethodAbi {
|
||||
singleReturnValue: boolean;
|
||||
hasReturnValue: boolean;
|
||||
tsName: string;
|
||||
functionSignature: string;
|
||||
}
|
||||
|
||||
export interface ContextData {
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { ConstructorAbi, DataItem } from '@0xproject/types';
|
||||
import { AbiType, ConstructorAbi, DataItem } from '@0xproject/types';
|
||||
import * as fs from 'fs';
|
||||
import * as _ from 'lodash';
|
||||
import * as path from 'path';
|
||||
|
||||
import { AbiType, ContractsBackend, ParamKind } from './types';
|
||||
import { ContractsBackend, ParamKind } from './types';
|
||||
|
||||
export const utils = {
|
||||
solTypeToTsType(paramKind: ParamKind, backend: ContractsBackend, solType: string, components?: DataItem[]): string {
|
||||
|
@@ -1,4 +1,22 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1523462196,
|
||||
"version": "0.2.6",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1522673609,
|
||||
"version": "0.2.5",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1522658513,
|
||||
"version": "0.2.4",
|
||||
@@ -16,8 +34,7 @@
|
||||
"pr": 412
|
||||
}
|
||||
],
|
||||
"timestamp": 1520434800,
|
||||
"isPublished": true
|
||||
"timestamp": 1520434800
|
||||
},
|
||||
{
|
||||
"version": "0.1.0",
|
||||
@@ -31,8 +48,7 @@
|
||||
"pr": 385
|
||||
}
|
||||
],
|
||||
"timestamp": 1520089200,
|
||||
"isPublished": true
|
||||
"timestamp": 1520089200
|
||||
},
|
||||
{
|
||||
"version": "0.0.18",
|
||||
@@ -42,8 +58,7 @@
|
||||
"pr": 389
|
||||
}
|
||||
],
|
||||
"timestamp": 1486566000,
|
||||
"isPublished": true
|
||||
"timestamp": 1486566000
|
||||
},
|
||||
{
|
||||
"version": "0.0.4",
|
||||
@@ -56,7 +71,6 @@
|
||||
"Added assertion isValidBaseUnitAmount which checks both that the value is a valid bigNumber and that it does not contain decimals."
|
||||
}
|
||||
],
|
||||
"timestamp": 1510585200,
|
||||
"isPublished": true
|
||||
"timestamp": 1510585200
|
||||
}
|
||||
]
|
||||
|
@@ -5,24 +5,32 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.2.6 - _April 11, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.5 - _April 2, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.4 - _April 2, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.0 - _March 8, 2018_
|
||||
## v0.2.0 - _March 7, 2018_
|
||||
|
||||
* Rename `isHttpUrl` to `isWebUri` (#412)
|
||||
|
||||
## v0.1.0 - _March 4, 2018_
|
||||
## v0.1.0 - _March 3, 2018_
|
||||
|
||||
* Remove isETHAddressHex checksum address check and assume address will be lowercased (#373)
|
||||
* Add an optional parameter `subSchemas` to `doesConformToSchema` method (#385)
|
||||
|
||||
## v0.0.18 - _February 9, 2017_
|
||||
## v0.0.18 - _February 8, 2017_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.0.4 - _November 14, 2017_
|
||||
## v0.0.4 - _November 13, 2017_
|
||||
|
||||
* Re-publish Assert previously published under NPM package @0xproject/0x-assert
|
||||
* Added assertion isValidBaseUnitAmount which checks both that the value is a valid bigNumber and that it does not contain decimals.
|
||||
|
@@ -26,11 +26,11 @@ If your project is in [TypeScript](https://www.typescriptlang.org/), add the fol
|
||||
|
||||
## Contributing
|
||||
|
||||
We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
|
||||
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
|
||||
|
||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
||||
|
||||
### Install Dependencies
|
||||
### Install dependencies
|
||||
|
||||
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
|
||||
|
||||
@@ -46,10 +46,36 @@ yarn install
|
||||
|
||||
### Build
|
||||
|
||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
You can also build this specific package by running the following from within its directory:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn build:watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
```bash
|
||||
yarn clean
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
```bash
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/assert",
|
||||
"version": "0.2.4",
|
||||
"version": "0.2.5",
|
||||
"description": "Provides a standard way of performing type and schema validation across 0x projects",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
@@ -14,7 +14,8 @@
|
||||
"test": "run-s clean build run_mocha",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"test:circleci": "yarn test:coverage"
|
||||
"test:circleci": "yarn test:coverage",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
@@ -26,8 +27,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.15",
|
||||
"@0xproject/tslint-config": "^0.4.13",
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/valid-url": "^1.0.2",
|
||||
@@ -42,9 +43,9 @@
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/json-schemas": "^0.7.18",
|
||||
"@0xproject/typescript-typings": "^0.0.2",
|
||||
"@0xproject/utils": "^0.4.4",
|
||||
"@0xproject/json-schemas": "^0.7.19",
|
||||
"@0xproject/typescript-typings": "^0.0.3",
|
||||
"@0xproject/utils": "^0.5.0",
|
||||
"lodash": "^4.17.4",
|
||||
"valid-url": "^1.0.9"
|
||||
},
|
||||
|
2
packages/assert/src/globals.d.ts
vendored
2
packages/assert/src/globals.d.ts
vendored
@@ -1,5 +1,3 @@
|
||||
declare module 'dirty-chai';
|
||||
|
||||
declare module '*.json' {
|
||||
const json: any;
|
||||
/* tslint:disable */
|
||||
|
@@ -61,7 +61,7 @@ export const assert = {
|
||||
},
|
||||
isWeb3Provider(variableName: string, value: any): void {
|
||||
const isWeb3Provider = _.isFunction(value.send) || _.isFunction(value.sendAsync);
|
||||
this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Web3.Provider', value));
|
||||
this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Provider', value));
|
||||
},
|
||||
doesConformToSchema(variableName: string, value: any, schema: Schema, subSchemas?: Schema[]): void {
|
||||
const schemaValidator = new SchemaValidator();
|
||||
|
@@ -1,4 +1,32 @@
|
||||
[
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Contract wrappers now accept Provider and defaults instead of Web3Wrapper",
|
||||
"pr": 501
|
||||
}
|
||||
],
|
||||
"timestamp": 1523462196
|
||||
},
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add tests for traversing ABI tree",
|
||||
"pr": 485
|
||||
},
|
||||
{
|
||||
"note": "Fix ABI tuples traversing",
|
||||
"pr": 485
|
||||
},
|
||||
{
|
||||
"note": "Fix ABI arrays traversing",
|
||||
"pr": 485
|
||||
}
|
||||
],
|
||||
"timestamp": 1522673609
|
||||
},
|
||||
{
|
||||
"timestamp": 1522658513,
|
||||
"version": "0.0.6",
|
||||
@@ -15,7 +43,6 @@
|
||||
"note": "Initial release"
|
||||
}
|
||||
],
|
||||
"timestamp": 1520089200,
|
||||
"isPublished": true
|
||||
"timestamp": 1520089200
|
||||
}
|
||||
]
|
||||
|
@@ -5,10 +5,20 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.2.0 - _April 11, 2018_
|
||||
|
||||
* Contract wrappers now accept Provider and defaults instead of Web3Wrapper (#501)
|
||||
|
||||
## v0.1.0 - _April 2, 2018_
|
||||
|
||||
* Add tests for traversing ABI tree (#485)
|
||||
* Fix ABI tuples traversing (#485)
|
||||
* Fix ABI arrays traversing (#485)
|
||||
|
||||
## v0.0.6 - _April 2, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.2 - _March 4, 2018_
|
||||
## v0.0.2 - _March 3, 2018_
|
||||
|
||||
* Initial release
|
||||
|
0
packages/base-contract/coverage/.gitkeep
Normal file
0
packages/base-contract/coverage/.gitkeep
Normal file
@@ -1,14 +1,20 @@
|
||||
{
|
||||
"name": "@0xproject/base-contract",
|
||||
"version": "0.0.6",
|
||||
"version": "0.1.0",
|
||||
"description": "0x Base TS contract",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
"scripts": {
|
||||
"build:watch": "tsc -w",
|
||||
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
||||
"clean": "shx rm -rf lib scripts",
|
||||
"lint": "tslint --project . 'src/**/*.ts'"
|
||||
"test": "run-s clean build run_mocha",
|
||||
"test:circleci": "yarn test:coverage",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js --bail --exit",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"lint": "tslint --project .",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
@@ -20,19 +26,22 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.15",
|
||||
"@0xproject/tslint-config": "^0.4.13",
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@types/lodash": "4.14.104",
|
||||
"chai": "^4.0.1",
|
||||
"copyfiles": "^1.2.0",
|
||||
"mocha": "^4.0.1",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.8.0",
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/types": "^0.4.2",
|
||||
"@0xproject/typescript-typings": "^0.0.2",
|
||||
"@0xproject/web3-wrapper": "^0.4.0",
|
||||
"@0xproject/types": "^0.5.0",
|
||||
"@0xproject/typescript-typings": "^0.0.3",
|
||||
"@0xproject/utils": "^0.5.0",
|
||||
"@0xproject/web3-wrapper": "^0.5.0",
|
||||
"ethers-contracts": "^2.2.1",
|
||||
"lodash": "^4.17.4"
|
||||
},
|
||||
|
@@ -1,40 +1,44 @@
|
||||
import { ContractAbi, DataItem, TxData, TxDataPayable } from '@0xproject/types';
|
||||
import {
|
||||
AbiDefinition,
|
||||
AbiType,
|
||||
ContractAbi,
|
||||
DataItem,
|
||||
MethodAbi,
|
||||
Provider,
|
||||
TxData,
|
||||
TxDataPayable,
|
||||
} from '@0xproject/types';
|
||||
import { abiUtils, BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as ethersContracts from 'ethers-contracts';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { formatABIDataItem } from './utils';
|
||||
|
||||
export interface EthersInterfaceByFunctionSignature {
|
||||
[key: string]: ethersContracts.Interface;
|
||||
}
|
||||
|
||||
export class BaseContract {
|
||||
protected _ethersInterface: ethersContracts.Interface;
|
||||
protected _ethersInterfacesByFunctionSignature: EthersInterfaceByFunctionSignature;
|
||||
protected _web3Wrapper: Web3Wrapper;
|
||||
public abi: ContractAbi;
|
||||
public address: string;
|
||||
protected static _transformABIData(
|
||||
protected static _formatABIDataItemList(
|
||||
abis: DataItem[],
|
||||
values: any[],
|
||||
transformation: (type: string, value: any) => any,
|
||||
formatter: (type: string, value: any) => any,
|
||||
): any {
|
||||
return _.map(values, (value: any, i: number) =>
|
||||
BaseContract._transformTypedData(abis[i].type, value, transformation),
|
||||
);
|
||||
return _.map(values, (value: any, i: number) => formatABIDataItem(abis[i], value, formatter));
|
||||
}
|
||||
protected static _lowercaseAddress(type: string, value: string): string {
|
||||
return type === 'address' ? value.toLowerCase() : value;
|
||||
}
|
||||
protected static _bigNumberToString(type: string, value: string): string {
|
||||
return _.isObject(value) && (value as any).isBigNumber ? value.toString() : value;
|
||||
protected static _bigNumberToString(type: string, value: any): any {
|
||||
return _.isObject(value) && value.isBigNumber ? value.toString() : value;
|
||||
}
|
||||
private static _transformTypedData(
|
||||
type: string,
|
||||
values: any,
|
||||
transformation: (type: string, value: any) => any,
|
||||
): any {
|
||||
const trailingArrayRegex = /\[\d*\]$/;
|
||||
if (type.match(trailingArrayRegex)) {
|
||||
const arrayItemType = type.replace(trailingArrayRegex, '');
|
||||
return _.map(values, value => this._transformTypedData(arrayItemType, value, transformation));
|
||||
} else {
|
||||
return transformation(type, values);
|
||||
}
|
||||
protected static _bnToBigNumber(type: string, value: any): any {
|
||||
return _.isObject(value) && value._bn ? new BigNumber(value.toString()) : value;
|
||||
}
|
||||
protected async _applyDefaultsToTxDataAsync<T extends Partial<TxData | TxDataPayable>>(
|
||||
txData: T,
|
||||
@@ -58,10 +62,37 @@ export class BaseContract {
|
||||
}
|
||||
return txDataWithDefaults;
|
||||
}
|
||||
constructor(web3Wrapper: Web3Wrapper, abi: ContractAbi, address: string) {
|
||||
this._web3Wrapper = web3Wrapper;
|
||||
protected _lookupEthersInterface(functionSignature: string): ethersContracts.Interface {
|
||||
const ethersInterface = this._ethersInterfacesByFunctionSignature[functionSignature];
|
||||
if (_.isUndefined(ethersInterface)) {
|
||||
throw new Error(`Failed to lookup method with function signature '${functionSignature}'`);
|
||||
}
|
||||
return ethersInterface;
|
||||
}
|
||||
protected _lookupAbi(functionSignature: string): MethodAbi {
|
||||
const methodAbi = _.find(this.abi, (abiDefinition: AbiDefinition) => {
|
||||
if (abiDefinition.type !== AbiType.Function) {
|
||||
return false;
|
||||
}
|
||||
const abiFunctionSignature = abiUtils.getFunctionSignature(abiDefinition);
|
||||
if (abiFunctionSignature === functionSignature) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}) as MethodAbi;
|
||||
return methodAbi;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial<TxData>) {
|
||||
this._web3Wrapper = new Web3Wrapper(provider, defaults);
|
||||
this.abi = abi;
|
||||
this.address = address;
|
||||
this._ethersInterface = new ethersContracts.Interface(abi);
|
||||
const methodAbis = this.abi.filter(
|
||||
(abiDefinition: AbiDefinition) => abiDefinition.type === AbiType.Function,
|
||||
) as MethodAbi[];
|
||||
this._ethersInterfacesByFunctionSignature = {};
|
||||
_.each(methodAbis, methodAbi => {
|
||||
const functionSignature = abiUtils.getFunctionSignature(methodAbi);
|
||||
this._ethersInterfacesByFunctionSignature[functionSignature] = new ethersContracts.Interface([methodAbi]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
25
packages/base-contract/src/utils.ts
Normal file
25
packages/base-contract/src/utils.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { DataItem } from '@0xproject/types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
// tslint:disable-next-line:completed-docs
|
||||
export function formatABIDataItem(abi: DataItem, value: any, formatter: (type: string, value: any) => any): any {
|
||||
const trailingArrayRegex = /\[\d*\]$/;
|
||||
if (abi.type.match(trailingArrayRegex)) {
|
||||
const arrayItemType = abi.type.replace(trailingArrayRegex, '');
|
||||
return _.map(value, val => {
|
||||
const arrayItemAbi = {
|
||||
...abi,
|
||||
type: arrayItemType,
|
||||
};
|
||||
return formatABIDataItem(arrayItemAbi, val, formatter);
|
||||
});
|
||||
} else if (abi.type === 'tuple') {
|
||||
const formattedTuple: { [componentName: string]: DataItem } = {};
|
||||
_.forEach(abi.components, componentABI => {
|
||||
formattedTuple[componentABI.name] = formatABIDataItem(componentABI, value[componentABI.name], formatter);
|
||||
});
|
||||
return formattedTuple;
|
||||
} else {
|
||||
return formatter(abi.type, value);
|
||||
}
|
||||
}
|
108
packages/base-contract/test/utils_test.ts
Normal file
108
packages/base-contract/test/utils_test.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import 'mocha';
|
||||
|
||||
import { formatABIDataItem } from '../src/utils';
|
||||
|
||||
const { expect } = chai;
|
||||
|
||||
describe('Utils tests', () => {
|
||||
describe('#formatABIDataItem', () => {
|
||||
it('correctly handles arrays', () => {
|
||||
const calls: Array<{ type: string; value: any }> = [];
|
||||
const abi = {
|
||||
name: 'values',
|
||||
type: 'uint256[]',
|
||||
};
|
||||
const val = [1, 2, 3];
|
||||
const formatted = formatABIDataItem(abi, val, (type: string, value: any) => {
|
||||
calls.push({ type, value });
|
||||
return value; // no-op
|
||||
});
|
||||
expect(formatted).to.be.deep.equal(val);
|
||||
expect(calls).to.be.deep.equal([
|
||||
{ type: 'uint256', value: 1 },
|
||||
{ type: 'uint256', value: 2 },
|
||||
{ type: 'uint256', value: 3 },
|
||||
]);
|
||||
});
|
||||
it('correctly handles tuples', () => {
|
||||
const calls: Array<{ type: string; value: any }> = [];
|
||||
const abi = {
|
||||
components: [
|
||||
{
|
||||
name: 'to',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'data',
|
||||
type: 'tuple',
|
||||
};
|
||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||
const val = { to: ZERO_ADDRESS, amount: new BigNumber(1) };
|
||||
const formatted = formatABIDataItem(abi, val, (type: string, value: any) => {
|
||||
calls.push({ type, value });
|
||||
return value; // no-op
|
||||
});
|
||||
expect(formatted).to.be.deep.equal(val);
|
||||
expect(calls).to.be.deep.equal([
|
||||
{
|
||||
type: 'address',
|
||||
value: val.to,
|
||||
},
|
||||
{
|
||||
type: 'uint256',
|
||||
value: val.amount,
|
||||
},
|
||||
]);
|
||||
});
|
||||
it('correctly handles nested arrays of tuples', () => {
|
||||
const calls: Array<{ type: string; value: any }> = [];
|
||||
const abi = {
|
||||
components: [
|
||||
{
|
||||
name: 'to',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'data',
|
||||
type: 'tuple[2][]',
|
||||
};
|
||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||
const val = [
|
||||
[{ to: ZERO_ADDRESS, amount: new BigNumber(1) }, { to: ZERO_ADDRESS, amount: new BigNumber(2) }],
|
||||
];
|
||||
const formatted = formatABIDataItem(abi, val, (type: string, value: any) => {
|
||||
calls.push({ type, value });
|
||||
return value; // no-op
|
||||
});
|
||||
expect(formatted).to.be.deep.equal(val);
|
||||
expect(calls).to.be.deep.equal([
|
||||
{
|
||||
type: 'address',
|
||||
value: val[0][0].to,
|
||||
},
|
||||
{
|
||||
type: 'uint256',
|
||||
value: val[0][0].amount,
|
||||
},
|
||||
{
|
||||
type: 'address',
|
||||
value: val[0][1].to,
|
||||
},
|
||||
{
|
||||
type: 'uint256',
|
||||
value: val[0][1].amount,
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
@@ -3,5 +3,5 @@
|
||||
"compilerOptions": {
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": ["./src/**/*"]
|
||||
"include": ["src/**/*", "test/**/*"]
|
||||
}
|
||||
|
@@ -1,4 +1,22 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1523462196,
|
||||
"version": "0.6.9",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1522673609,
|
||||
"version": "0.6.8",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1522658513,
|
||||
"version": "0.6.7",
|
||||
@@ -16,8 +34,7 @@
|
||||
"pr": 456
|
||||
}
|
||||
],
|
||||
"timestamp": 1521298800,
|
||||
"isPublished": true
|
||||
"timestamp": 1521298800
|
||||
},
|
||||
{
|
||||
"version": "0.6.2",
|
||||
@@ -27,8 +44,7 @@
|
||||
"pr": 407
|
||||
}
|
||||
],
|
||||
"timestamp": 1518706800,
|
||||
"isPublished": true
|
||||
"timestamp": 1518706800
|
||||
},
|
||||
{
|
||||
"version": "0.6.0",
|
||||
@@ -42,8 +58,7 @@
|
||||
"pr": 406
|
||||
}
|
||||
],
|
||||
"timestamp": 1518706800,
|
||||
"isPublished": true
|
||||
"timestamp": 1518706800
|
||||
},
|
||||
{
|
||||
"version": "0.5.7",
|
||||
@@ -53,8 +68,7 @@
|
||||
"pr": 389
|
||||
}
|
||||
],
|
||||
"timestamp": 1518102000,
|
||||
"isPublished": true
|
||||
"timestamp": 1518102000
|
||||
},
|
||||
{
|
||||
"version": "0.5.0",
|
||||
@@ -72,8 +86,7 @@
|
||||
"pr": 318
|
||||
}
|
||||
],
|
||||
"timestamp": 1516114800,
|
||||
"isPublished": true
|
||||
"timestamp": 1516114800
|
||||
},
|
||||
{
|
||||
"version": "0.4.0",
|
||||
@@ -83,8 +96,7 @@
|
||||
"pr": 296
|
||||
}
|
||||
],
|
||||
"timestamp": 1515596400,
|
||||
"isPublished": true
|
||||
"timestamp": 1515596400
|
||||
},
|
||||
{
|
||||
"version": "0.3.0",
|
||||
@@ -98,8 +110,7 @@
|
||||
"pr": 256
|
||||
}
|
||||
],
|
||||
"timestamp": 1512658800,
|
||||
"isPublished": true
|
||||
"timestamp": 1512658800
|
||||
},
|
||||
{
|
||||
"version": "0.2.0",
|
||||
@@ -114,8 +125,7 @@
|
||||
"note": "Remove dependency on 0x.js"
|
||||
}
|
||||
],
|
||||
"timestamp": 1511881200,
|
||||
"isPublished": true
|
||||
"timestamp": 1511881200
|
||||
},
|
||||
{
|
||||
"version": "0.1.0",
|
||||
@@ -124,7 +134,6 @@
|
||||
"note": "Provide a HttpClient class for interacting with standard relayer api compliant HTTP urls"
|
||||
}
|
||||
],
|
||||
"timestamp": 1511276400,
|
||||
"isPublished": true
|
||||
"timestamp": 1511276400
|
||||
}
|
||||
]
|
||||
|
@@ -5,48 +5,56 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.6.9 - _April 11, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.8 - _April 2, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.7 - _April 2, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.4 - _March 18, 2018_
|
||||
## v0.6.4 - _March 17, 2018_
|
||||
|
||||
* Consolidate `Order`, `SignedOrder`, and `ECSignature` into the `@0xproject/types` package (#456)
|
||||
|
||||
## v0.6.2 - _February 16, 2018_
|
||||
## v0.6.2 - _February 15, 2018_
|
||||
|
||||
* Fix JSON parse empty response (#407)
|
||||
|
||||
## v0.6.0 - _February 16, 2018_
|
||||
## v0.6.0 - _February 15, 2018_
|
||||
|
||||
* Add pagination options to HttpClient methods (#393)
|
||||
* Add heartbeat configuration to WebSocketOrderbookChannel constructor (#406)
|
||||
|
||||
## v0.5.7 - _February 9, 2018_
|
||||
## v0.5.7 - _February 8, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.5.0 - _January 17, 2018_
|
||||
## v0.5.0 - _January 16, 2018_
|
||||
|
||||
* Sanitize api endpoint url and remove trailing slashes (#318)
|
||||
* Improve error message text in HttpClient (#318)
|
||||
* Stop appending '/v0' to api endpoint url in HttpClient (#318)
|
||||
|
||||
## v0.4.0 - _January 11, 2018_
|
||||
## v0.4.0 - _January 10, 2018_
|
||||
|
||||
* Prevent getFeesAsync method on HttpClient from mutating input (#296)
|
||||
|
||||
## v0.3.0 - _December 8, 2017_
|
||||
## v0.3.0 - _December 7, 2017_
|
||||
|
||||
* Expose WebSocketOrderbookChannel and associated types to public interface (#251)
|
||||
* Remove tokenA and tokenB fields from OrdersRequest (#256)
|
||||
|
||||
## v0.2.0 - _November 29, 2017_
|
||||
## v0.2.0 - _November 28, 2017_
|
||||
|
||||
* Add SignedOrder and TokenTradeInfo to the public interface
|
||||
* Add ECSignature and Order to the public interface
|
||||
* Remove dependency on 0x.js
|
||||
|
||||
## v0.1.0 - _November 22, 2017_
|
||||
## v0.1.0 - _November 21, 2017_
|
||||
|
||||
* Provide a HttpClient class for interacting with standard relayer api compliant HTTP urls
|
||||
|
@@ -23,11 +23,11 @@ If your project is in [TypeScript](https://www.typescriptlang.org/), add the fol
|
||||
|
||||
## Contributing
|
||||
|
||||
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
|
||||
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
|
||||
|
||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
||||
|
||||
### Install Dependencies
|
||||
### Install dependencies
|
||||
|
||||
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
|
||||
|
||||
@@ -43,10 +43,36 @@ yarn install
|
||||
|
||||
### Build
|
||||
|
||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
You can also build this specific package by running the following from within its directory:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn build:watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
```bash
|
||||
yarn clean
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
```bash
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/connect",
|
||||
"version": "0.6.7",
|
||||
"version": "0.6.8",
|
||||
"description": "A javascript library for interacting with the standard relayer api",
|
||||
"keywords": [
|
||||
"connect",
|
||||
@@ -22,6 +22,7 @@
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"test:circleci": "yarn test:coverage",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
|
||||
"docs:stage": "yarn build && node ./scripts/stage_docs.js",
|
||||
"docs: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"
|
||||
@@ -49,19 +50,19 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.2.4",
|
||||
"@0xproject/json-schemas": "^0.7.18",
|
||||
"@0xproject/types": "^0.4.2",
|
||||
"@0xproject/typescript-typings": "^0.0.2",
|
||||
"@0xproject/utils": "^0.4.4",
|
||||
"@0xproject/assert": "^0.2.5",
|
||||
"@0xproject/json-schemas": "^0.7.19",
|
||||
"@0xproject/types": "^0.5.0",
|
||||
"@0xproject/typescript-typings": "^0.0.3",
|
||||
"@0xproject/utils": "^0.5.0",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"lodash": "^4.17.4",
|
||||
"query-string": "^5.0.1",
|
||||
"websocket": "^1.0.25"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.15",
|
||||
"@0xproject/tslint-config": "^0.4.13",
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@types/fetch-mock": "^5.12.1",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
|
3
packages/connect/src/globals.d.ts
vendored
3
packages/connect/src/globals.d.ts
vendored
@@ -1,6 +1,3 @@
|
||||
declare module 'async-child-process';
|
||||
declare module 'dirty-chai';
|
||||
|
||||
declare module '*.json' {
|
||||
const value: any;
|
||||
export default value;
|
||||
|
@@ -5,12 +5,11 @@
|
||||
// tslint:disable:no-consecutive-blank-lines
|
||||
// tslint:disable-next-line:no-unused-variable
|
||||
import { BaseContract } from '@0xproject/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, DataItem, MethodAbi, TxData, TxDataPayable } from '@0xproject/types';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, DataItem, MethodAbi, Provider, TxData, TxDataPayable } from '@0xproject/types';
|
||||
import { BigNumber, classUtils, promisify } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as ethersContracts from 'ethers-contracts';
|
||||
import * as _ from 'lodash';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
{{#if events}}
|
||||
export type {{contractName}}ContractEventArgs =
|
||||
@@ -40,8 +39,8 @@ export class {{contractName}}Contract extends BaseContract {
|
||||
{{> tx contractName=../contractName}}
|
||||
{{/this.constant}}
|
||||
{{/each}}
|
||||
constructor(web3Wrapper: Web3Wrapper, abi: ContractAbi, address: string) {
|
||||
super(web3Wrapper, abi, address);
|
||||
classUtils.bindAll(this, ['_ethersInterface', 'address', 'abi', '_web3Wrapper']);
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial<TxData>) {
|
||||
super(abi, address, provider, defaults);
|
||||
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
|
@@ -4,10 +4,10 @@ async callAsync(
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<{{> return_type outputs=outputs}}> {
|
||||
const self = this as {{contractName}}Contract;
|
||||
const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
|
||||
[{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
|
||||
const encodedData = self._ethersInterface.functions.{{this.name}}(
|
||||
const self = this as any as {{contractName}}Contract;
|
||||
const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
|
||||
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
|
||||
const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}(
|
||||
{{> params inputs=inputs}}
|
||||
).data;
|
||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
||||
@@ -19,7 +19,8 @@ async callAsync(
|
||||
const outputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).outputs;
|
||||
const outputParamsTypes = _.map(outputAbi, 'type');
|
||||
let resultArray = ethersContracts.Interface.decodeParams(outputParamsTypes, rawCallResult) as any;
|
||||
resultArray = BaseContract._transformABIData(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||
return resultArray{{#singleReturnValue}}[0]{{/singleReturnValue}};
|
||||
},
|
||||
{{/hasReturnValue}}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
public {{this.name}} = {
|
||||
public {{this.tsName}} = {
|
||||
async sendTransactionAsync(
|
||||
{{> typed_params inputs=inputs}}
|
||||
{{#this.payable}}
|
||||
@@ -8,18 +8,18 @@ public {{this.name}} = {
|
||||
txData: Partial<TxData> = {},
|
||||
{{/this.payable}}
|
||||
): Promise<string> {
|
||||
const self = this as {{contractName}}Contract;
|
||||
const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
|
||||
[{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
|
||||
const encodedData = self._ethersInterface.functions.{{this.name}}(
|
||||
const self = this as any as {{contractName}}Contract;
|
||||
const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
|
||||
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
|
||||
const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}(
|
||||
{{> params inputs=inputs}}
|
||||
).data
|
||||
).data;
|
||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self.{{this.name}}.estimateGasAsync.bind(
|
||||
self.{{this.tsName}}.estimateGasAsync.bind(
|
||||
self,
|
||||
{{> params inputs=inputs}}
|
||||
),
|
||||
@@ -31,12 +31,12 @@ public {{this.name}} = {
|
||||
{{> typed_params inputs=inputs}}
|
||||
txData: Partial<TxData> = {},
|
||||
): Promise<number> {
|
||||
const self = this as {{contractName}}Contract;
|
||||
const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
|
||||
[{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
|
||||
const encodedData = self._ethersInterface.functions.{{this.name}}(
|
||||
const self = this as any as {{contractName}}Contract;
|
||||
const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
|
||||
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
|
||||
const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}(
|
||||
{{> params inputs=inputs}}
|
||||
).data
|
||||
).data;
|
||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
...txData,
|
||||
@@ -49,12 +49,12 @@ public {{this.name}} = {
|
||||
getABIEncodedTransactionData(
|
||||
{{> typed_params inputs=inputs}}
|
||||
): string {
|
||||
const self = this as {{contractName}}Contract;
|
||||
const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
|
||||
[{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
|
||||
const abiEncodedTransactionData = self._ethersInterface.functions.{{this.name}}(
|
||||
const self = this as any as {{contractName}}Contract;
|
||||
const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
|
||||
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
|
||||
const abiEncodedTransactionData = self._lookupEthersInterface('{{this.name}}').functions.{{this.name}}(
|
||||
{{> params inputs=inputs}}
|
||||
).data
|
||||
).data;
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
{{> callAsync}}
|
||||
|
@@ -34,11 +34,25 @@ yarn install
|
||||
|
||||
### Build
|
||||
|
||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
You can also build this specific package by running the following from within its directory:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
or
|
||||
or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn build:watch
|
||||
|
29
packages/contracts/globals.d.ts
vendored
29
packages/contracts/globals.d.ts
vendored
@@ -1,35 +1,6 @@
|
||||
declare module 'chai-bignumber';
|
||||
declare module 'dirty-chai';
|
||||
|
||||
// HACK: In order to merge the bignumber declaration added by chai-bignumber to the chai Assertion
|
||||
// interface we must use `namespace` as the Chai definitelyTyped definition does. Since we otherwise
|
||||
// disallow `namespace`, we disable tslint for the following.
|
||||
/* tslint:disable */
|
||||
declare namespace Chai {
|
||||
interface Assertion {
|
||||
bignumber: Assertion;
|
||||
}
|
||||
}
|
||||
/* tslint:enable */
|
||||
|
||||
declare module '*.json' {
|
||||
const json: any;
|
||||
/* tslint:disable */
|
||||
export default json;
|
||||
/* tslint:enable */
|
||||
}
|
||||
|
||||
declare module 'solc' {
|
||||
export function compile(sources: any, optimizerEnabled: number, findImports: (importPath: string) => any): any;
|
||||
export function setupMethods(solcBin: any): any;
|
||||
}
|
||||
|
||||
declare module 'web3-eth-abi' {
|
||||
export function encodeParameters(typesArray: string[], parameters: any[]): string;
|
||||
}
|
||||
|
||||
declare module 'ethereumjs-abi' {
|
||||
const soliditySHA3: (argTypes: string[], args: any[]) => Buffer;
|
||||
const soliditySHA256: (argTypes: string[], args: any[]) => Buffer;
|
||||
const methodID: (name: string, types: string[]) => Buffer;
|
||||
}
|
||||
|
19
packages/contracts/globalsAugment.d.ts
vendored
19
packages/contracts/globalsAugment.d.ts
vendored
@@ -1,19 +0,0 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
// HACK: This module overrides the Chai namespace so that we can use BigNumber types inside.
|
||||
// Source: https://github.com/Microsoft/TypeScript/issues/7352#issuecomment-191547232
|
||||
declare global {
|
||||
// HACK: In order to merge the bignumber declaration added by chai-bignumber to the chai Assertion
|
||||
// interface we must use `namespace` as the Chai definitelyTyped definition does. Since we otherwise
|
||||
// disallow `namespace`, we disable tslint for the following.
|
||||
/* tslint:disable */
|
||||
namespace Chai {
|
||||
interface NumberComparer {
|
||||
(value: number | BigNumber, message?: string): Assertion;
|
||||
}
|
||||
interface NumericComparison {
|
||||
greaterThan: NumberComparer;
|
||||
}
|
||||
}
|
||||
/* tslint:enable */
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "contracts",
|
||||
"version": "2.1.20",
|
||||
"version": "2.1.21",
|
||||
"description": "Smart contract components of 0x protocol",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
@@ -16,7 +16,7 @@
|
||||
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
|
||||
"run_mocha": "mocha 'lib/test/**/*.js' --timeout 100000 --bail --exit",
|
||||
"compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846",
|
||||
"compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir src/artifacts",
|
||||
"compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contract-dirs src/contracts --artifacts-dir src/artifacts",
|
||||
"clean": "shx rm -rf ./lib",
|
||||
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
|
||||
"migrate": "yarn build && yarn compile && node ./lib/migrations/index.js",
|
||||
@@ -41,12 +41,10 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/dev-utils": "^0.3.3",
|
||||
"@0xproject/tslint-config": "^0.4.13",
|
||||
"@types/bluebird": "^3.5.3",
|
||||
"@0xproject/dev-utils": "^0.3.4",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/node": "^8.0.53",
|
||||
"@types/request-promise-native": "^1.0.2",
|
||||
"@types/yargs": "^10.0.0",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
@@ -59,28 +57,21 @@
|
||||
"shx": "^0.2.2",
|
||||
"solc": "^0.4.18",
|
||||
"tslint": "5.8.0",
|
||||
"types-bn": "^0.0.1",
|
||||
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
|
||||
"typescript": "2.7.1",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"0x.js": "^0.34.0",
|
||||
"@0xproject/deployer": "^0.3.4",
|
||||
"@0xproject/json-schemas": "^0.7.18",
|
||||
"@0xproject/types": "^0.4.2",
|
||||
"@0xproject/typescript-typings": "^0.0.2",
|
||||
"@0xproject/utils": "^0.4.4",
|
||||
"@0xproject/web3-wrapper": "^0.4.0",
|
||||
"bluebird": "^3.5.0",
|
||||
"0x.js": "^0.35.0",
|
||||
"@0xproject/deployer": "^0.3.5",
|
||||
"@0xproject/types": "^0.5.0",
|
||||
"@0xproject/typescript-typings": "^0.0.3",
|
||||
"@0xproject/utils": "^0.5.0",
|
||||
"@0xproject/web3-wrapper": "^0.5.0",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereumjs-abi": "^0.6.4",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"ethers-contracts": "^2.2.1",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"lodash": "^4.17.4",
|
||||
"request": "^2.81.0",
|
||||
"web3": "^0.20.0",
|
||||
"web3-eth-abi": "^1.0.0-beta.24"
|
||||
"web3": "^0.20.0"
|
||||
}
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ import { ContractName } from '../util/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -26,7 +26,7 @@ describe('EtherToken', () => {
|
||||
|
||||
const etherToken = await deployer.deployAsync(ContractName.EtherToken);
|
||||
etherTokenAddress = etherToken.address;
|
||||
zeroEx = new ZeroEx(web3.currentProvider, {
|
||||
zeroEx = new ZeroEx(provider, {
|
||||
gasPrice,
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
});
|
||||
@@ -51,7 +51,7 @@ describe('EtherToken', () => {
|
||||
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
|
||||
const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
|
||||
|
||||
const ethToDeposit = new BigNumber(web3.toWei(1, 'ether'));
|
||||
const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1)));
|
||||
|
||||
const txHash = await zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
|
||||
const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
@@ -76,7 +76,7 @@ describe('EtherToken', () => {
|
||||
});
|
||||
|
||||
it('should convert ether tokens to ether with sufficient balance', async () => {
|
||||
const ethToDeposit = new BigNumber(web3.toWei(1, 'ether'));
|
||||
const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1)));
|
||||
await zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
|
||||
const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
|
||||
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
|
||||
|
@@ -22,7 +22,7 @@ import { OrderFactory } from '../../util/order_factory';
|
||||
import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { deployer } from '../utils/deployer';
|
||||
import { web3, web3Wrapper } from '../utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -59,22 +59,22 @@ describe('Exchange', () => {
|
||||
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
|
||||
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
|
||||
]);
|
||||
rep = new DummyTokenContract(web3Wrapper, repInstance.abi, repInstance.address);
|
||||
dgd = new DummyTokenContract(web3Wrapper, dgdInstance.abi, dgdInstance.address);
|
||||
zrx = new DummyTokenContract(web3Wrapper, zrxInstance.abi, zrxInstance.address);
|
||||
rep = new DummyTokenContract(repInstance.abi, repInstance.address, provider);
|
||||
dgd = new DummyTokenContract(dgdInstance.abi, dgdInstance.address, provider);
|
||||
zrx = new DummyTokenContract(zrxInstance.abi, zrxInstance.address, provider);
|
||||
const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
tokenTransferProxy = new TokenTransferProxyContract(
|
||||
web3Wrapper,
|
||||
tokenTransferProxyInstance.abi,
|
||||
tokenTransferProxyInstance.address,
|
||||
provider,
|
||||
);
|
||||
const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
|
||||
zrx.address,
|
||||
tokenTransferProxy.address,
|
||||
]);
|
||||
exchange = new ExchangeContract(web3Wrapper, exchangeInstance.abi, exchangeInstance.address);
|
||||
exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
|
||||
await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: accounts[0] });
|
||||
zeroEx = new ZeroEx(web3.currentProvider, {
|
||||
zeroEx = new ZeroEx(provider, {
|
||||
exchangeContractAddress: exchange.address,
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
});
|
||||
|
@@ -17,7 +17,7 @@ import { OrderFactory } from '../../util/order_factory';
|
||||
import { ContractName } from '../../util/types';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { deployer } from '../utils/deployer';
|
||||
import { web3, web3Wrapper } from '../utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -46,9 +46,9 @@ describe('Exchange', () => {
|
||||
zrx.address,
|
||||
tokenTransferProxy.address,
|
||||
]);
|
||||
const exchange = new ExchangeContract(web3Wrapper, exchangeInstance.abi, exchangeInstance.address);
|
||||
const exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
|
||||
await tokenTransferProxy.addAuthorizedAddress(exchange.address, { from: accounts[0] });
|
||||
const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID });
|
||||
const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
|
||||
exchangeWrapper = new ExchangeWrapper(exchange, zeroEx);
|
||||
const defaultOrderParams = {
|
||||
exchangeContractAddress: exchange.address,
|
||||
|
@@ -22,7 +22,7 @@ import { OrderFactory } from '../../util/order_factory';
|
||||
import { BalancesByOwner, ContractName } from '../../util/types';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { deployer } from '../utils/deployer';
|
||||
import { web3, web3Wrapper } from '../utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -59,28 +59,24 @@ describe('Exchange', () => {
|
||||
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
|
||||
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
|
||||
]);
|
||||
rep = new DummyTokenContract(web3Wrapper, repInstance.abi, repInstance.address);
|
||||
dgd = new DummyTokenContract(web3Wrapper, dgdInstance.abi, dgdInstance.address);
|
||||
zrx = new DummyTokenContract(web3Wrapper, zrxInstance.abi, zrxInstance.address);
|
||||
rep = new DummyTokenContract(repInstance.abi, repInstance.address, provider);
|
||||
dgd = new DummyTokenContract(dgdInstance.abi, dgdInstance.address, provider);
|
||||
zrx = new DummyTokenContract(zrxInstance.abi, zrxInstance.address, provider);
|
||||
const tokenRegistryInstance = await deployer.deployAsync(ContractName.TokenRegistry);
|
||||
tokenRegistry = new TokenRegistryContract(
|
||||
web3Wrapper,
|
||||
tokenRegistryInstance.abi,
|
||||
tokenRegistryInstance.address,
|
||||
);
|
||||
tokenRegistry = new TokenRegistryContract(tokenRegistryInstance.abi, tokenRegistryInstance.address, provider);
|
||||
const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
tokenTransferProxy = new TokenTransferProxyContract(
|
||||
web3Wrapper,
|
||||
tokenTransferProxyInstance.abi,
|
||||
tokenTransferProxyInstance.address,
|
||||
provider,
|
||||
);
|
||||
const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
|
||||
zrx.address,
|
||||
tokenTransferProxy.address,
|
||||
]);
|
||||
exchange = new ExchangeContract(web3Wrapper, exchangeInstance.abi, exchangeInstance.address);
|
||||
exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
|
||||
await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: accounts[0] });
|
||||
const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID });
|
||||
const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
|
||||
exWrapper = new ExchangeWrapper(exchange, zeroEx);
|
||||
|
||||
const defaultOrderParams = {
|
||||
|
@@ -15,13 +15,13 @@ import { ContractName, SubmissionContractEventArgs } from '../util/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
const MULTI_SIG_ABI = artifacts.MultiSigWalletWithTimeLockArtifact.networks[constants.TESTRPC_NETWORK_ID].abi;
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID });
|
||||
const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
|
||||
const abiDecoder = new AbiDecoder([MULTI_SIG_ABI]);
|
||||
|
||||
describe('MultiSigWalletWithTimeLock', () => {
|
||||
@@ -53,9 +53,9 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
0,
|
||||
]);
|
||||
multiSig = new MultiSigWalletWithTimeLockContract(
|
||||
web3Wrapper,
|
||||
multiSigInstance.abi,
|
||||
multiSigInstance.address,
|
||||
provider,
|
||||
);
|
||||
multiSigWrapper = new MultiSigWrapper((multiSig as any) as MultiSigWalletContract);
|
||||
|
||||
@@ -150,9 +150,9 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
SECONDS_TIME_LOCKED,
|
||||
]);
|
||||
multiSig = new MultiSigWalletWithTimeLockContract(
|
||||
web3Wrapper,
|
||||
multiSigInstance.abi,
|
||||
multiSigInstance.address,
|
||||
provider,
|
||||
);
|
||||
multiSigWrapper = new MultiSigWrapper((multiSig as any) as MultiSigWalletContract);
|
||||
|
||||
|
@@ -16,7 +16,7 @@ import { ContractName, SubmissionContractEventArgs, TransactionDataParams } from
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
const PROXY_ABI = artifacts.TokenTransferProxyArtifact.networks[constants.TESTRPC_NETWORK_ID].abi;
|
||||
const MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI =
|
||||
artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressArtifact.networks[constants.TESTRPC_NETWORK_ID]
|
||||
@@ -28,7 +28,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
const abiDecoder = new AbiDecoder([MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI]);
|
||||
|
||||
describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {
|
||||
const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID });
|
||||
const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
|
||||
let owners: string[];
|
||||
const requiredApprovals = 2;
|
||||
const SECONDS_TIME_LOCKED = 1000000;
|
||||
@@ -49,9 +49,9 @@ describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {
|
||||
const initialOwner = accounts[0];
|
||||
const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
tokenTransferProxy = new TokenTransferProxyContract(
|
||||
web3Wrapper,
|
||||
tokenTransferProxyInstance.abi,
|
||||
tokenTransferProxyInstance.address,
|
||||
provider,
|
||||
);
|
||||
await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(authorizedAddress, {
|
||||
from: initialOwner,
|
||||
@@ -61,9 +61,9 @@ describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {
|
||||
[owners, requiredApprovals, SECONDS_TIME_LOCKED, tokenTransferProxy.address],
|
||||
);
|
||||
multiSig = new MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract(
|
||||
web3Wrapper,
|
||||
multiSigInstance.abi,
|
||||
multiSigInstance.address,
|
||||
provider,
|
||||
);
|
||||
await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, {
|
||||
from: initialOwner,
|
||||
|
@@ -14,7 +14,7 @@ import { ContractName } from '../util/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -30,7 +30,7 @@ describe('TokenRegistry', () => {
|
||||
owner = accounts[0];
|
||||
notOwner = accounts[1];
|
||||
const tokenRegInstance = await deployer.deployAsync(ContractName.TokenRegistry);
|
||||
tokenReg = new TokenRegistryContract(web3Wrapper, tokenRegInstance.abi, tokenRegInstance.address);
|
||||
tokenReg = new TokenRegistryContract(tokenRegInstance.abi, tokenRegInstance.address, provider);
|
||||
tokenRegWrapper = new TokenRegWrapper(tokenReg);
|
||||
});
|
||||
beforeEach(async () => {
|
||||
|
@@ -8,7 +8,7 @@ import { constants } from '../../util/constants';
|
||||
import { ContractName } from '../../util/types';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { deployer } from '../utils/deployer';
|
||||
import { web3, web3Wrapper } from '../utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -25,9 +25,9 @@ describe('TokenTransferProxy', () => {
|
||||
notOwner = accounts[1];
|
||||
const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
tokenTransferProxy = new TokenTransferProxyContract(
|
||||
web3Wrapper,
|
||||
tokenTransferProxyInstance.abi,
|
||||
tokenTransferProxyInstance.address,
|
||||
provider,
|
||||
);
|
||||
});
|
||||
beforeEach(async () => {
|
||||
|
@@ -11,7 +11,7 @@ import { constants } from '../../util/constants';
|
||||
import { ContractName } from '../../util/types';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { deployer } from '../utils/deployer';
|
||||
import { web3, web3Wrapper } from '../utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -33,12 +33,12 @@ describe('TokenTransferProxy', () => {
|
||||
owner = notAuthorized = accounts[0];
|
||||
const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
tokenTransferProxy = new TokenTransferProxyContract(
|
||||
web3Wrapper,
|
||||
tokenTransferProxyInstance.abi,
|
||||
tokenTransferProxyInstance.address,
|
||||
provider,
|
||||
);
|
||||
const repInstance = await deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS);
|
||||
rep = new DummyTokenContract(web3Wrapper, repInstance.abi, repInstance.address);
|
||||
rep = new DummyTokenContract(repInstance.abi, repInstance.address, provider);
|
||||
|
||||
dmyBalances = new Balances([rep], [accounts[0], accounts[1]]);
|
||||
await Promise.all([
|
||||
|
@@ -17,7 +17,7 @@ import { OrderFactory } from '../../util/order_factory';
|
||||
import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { deployer } from '../utils/deployer';
|
||||
import { web3, web3Wrapper } from '../utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -69,18 +69,18 @@ describe('Arbitrage', () => {
|
||||
edTakerFee,
|
||||
edFeeRebate,
|
||||
]);
|
||||
etherDelta = new EtherDeltaContract(web3Wrapper, etherDeltaInstance.abi, etherDeltaInstance.address);
|
||||
etherDelta = new EtherDeltaContract(etherDeltaInstance.abi, etherDeltaInstance.address, provider);
|
||||
const tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
|
||||
const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
|
||||
zrx.address,
|
||||
tokenTransferProxy.address,
|
||||
]);
|
||||
await tokenTransferProxy.addAuthorizedAddress(exchangeInstance.address, { from: accounts[0] });
|
||||
zeroEx = new ZeroEx(web3.currentProvider, {
|
||||
zeroEx = new ZeroEx(provider, {
|
||||
exchangeContractAddress: exchangeInstance.address,
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
});
|
||||
const exchange = new ExchangeContract(web3Wrapper, exchangeInstance.abi, exchangeInstance.address);
|
||||
const exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
|
||||
exWrapper = new ExchangeWrapper(exchange, zeroEx);
|
||||
|
||||
makerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18);
|
||||
@@ -102,7 +102,7 @@ describe('Arbitrage', () => {
|
||||
etherDelta.address,
|
||||
tokenTransferProxy.address,
|
||||
]);
|
||||
arbitrage = new ArbitrageContract(web3Wrapper, arbitrageInstance.abi, arbitrageInstance.address);
|
||||
arbitrage = new ArbitrageContract(arbitrageInstance.abi, arbitrageInstance.address, provider);
|
||||
// Enable arbitrage and withdrawals of tokens
|
||||
await arbitrage.setAllowances.sendTransactionAsync(weth.address, { from: coinbase });
|
||||
await arbitrage.setAllowances.sendTransactionAsync(zrx.address, { from: coinbase });
|
||||
|
@@ -11,7 +11,7 @@ import { ContractName } from '../util/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -23,7 +23,7 @@ describe('UnlimitedAllowanceToken', () => {
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
const zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||
const zeroEx = new ZeroEx(provider, config);
|
||||
|
||||
const MAX_MINT_VALUE = new BigNumber(100000000000000000000);
|
||||
let tokenAddress: string;
|
||||
@@ -34,7 +34,7 @@ describe('UnlimitedAllowanceToken', () => {
|
||||
owner = accounts[0];
|
||||
spender = accounts[1];
|
||||
const tokenInstance = await deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS);
|
||||
token = new DummyTokenContract(web3Wrapper, tokenInstance.abi, tokenInstance.address);
|
||||
token = new DummyTokenContract(tokenInstance.abi, tokenInstance.address, provider);
|
||||
await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner });
|
||||
tokenAddress = token.address;
|
||||
});
|
||||
|
@@ -7,9 +7,8 @@ import { constants } from '../../util/constants';
|
||||
import { web3 } from './web3_wrapper';
|
||||
|
||||
const deployerOpts = {
|
||||
web3Provider: web3.currentProvider,
|
||||
provider: web3.currentProvider,
|
||||
artifactsDir: path.resolve('src', 'artifacts'),
|
||||
jsonrpcUrl: devConstants.RPC_URL,
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
defaults: {
|
||||
gas: devConstants.GAS_ESTIMATE,
|
||||
|
@@ -3,4 +3,5 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
|
||||
const web3ProviderConfig = { shouldUseInProcessGanache: true };
|
||||
export const web3 = web3Factory.create(web3ProviderConfig);
|
||||
export const web3Wrapper = new Web3Wrapper(web3.currentProvider);
|
||||
export const provider = web3.currentProvider;
|
||||
export const web3Wrapper = new Web3Wrapper(provider);
|
||||
|
@@ -11,7 +11,7 @@ import { ContractName } from '../util/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { deployer } from './utils/deployer';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -31,11 +31,11 @@ describe('ZRXToken', () => {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
owner = accounts[0];
|
||||
spender = accounts[1];
|
||||
zeroEx = new ZeroEx(web3.currentProvider, {
|
||||
zeroEx = new ZeroEx(provider, {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
});
|
||||
const zrxInstance = await deployer.deployAsync(ContractName.ZRXToken);
|
||||
zrx = new ZRXTokenContract(web3Wrapper, zrxInstance.abi, zrxInstance.address);
|
||||
zrx = new ZRXTokenContract(zrxInstance.abi, zrxInstance.address, provider);
|
||||
zrxAddress = zrx.address;
|
||||
MAX_UINT = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
|
||||
});
|
||||
|
@@ -4,17 +4,8 @@
|
||||
"outDir": "lib",
|
||||
"baseUrl": ".",
|
||||
"declaration": false,
|
||||
"noImplicitThis": false,
|
||||
"allowJs": true
|
||||
},
|
||||
"include": [
|
||||
"../../node_modules/types-ethereumjs-util/index.d.ts",
|
||||
"../../node_modules/types-bn/index.d.ts",
|
||||
"./globals.d.ts",
|
||||
"./src/**/*",
|
||||
"./util/**/*",
|
||||
"./test/**/*",
|
||||
"./migrations/**/*"
|
||||
],
|
||||
"include": ["./globals.d.ts", "./src/**/*", "./util/**/*", "./test/**/*", "./migrations/**/*"],
|
||||
"exclude": ["./deploy/solc/solc_bin"]
|
||||
}
|
||||
|
@@ -1,4 +1,24 @@
|
||||
[
|
||||
{
|
||||
"version": "0.4.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Changed the config key `web3Provider` to `provider` to be consistent with other tools",
|
||||
"pr": 501
|
||||
}
|
||||
],
|
||||
"timestamp": 1523462196
|
||||
},
|
||||
{
|
||||
"version": "0.3.5",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Don't try to write contract artifact if an error occured",
|
||||
"pr": 485
|
||||
}
|
||||
],
|
||||
"timestamp": 1522673609
|
||||
},
|
||||
{
|
||||
"version": "0.3.4",
|
||||
"changes": [
|
||||
@@ -16,8 +36,7 @@
|
||||
"note": "Add TS types for `yargs`"
|
||||
}
|
||||
],
|
||||
"timestamp": 1521298800,
|
||||
"isPublished": true
|
||||
"timestamp": 1521298800
|
||||
},
|
||||
{
|
||||
"version": "0.3.0",
|
||||
@@ -63,8 +82,7 @@
|
||||
"note": "Add `#!/usr/bin/env node` pragma above `cli.ts` script to fix command-line error."
|
||||
}
|
||||
],
|
||||
"timestamp": 1521298800,
|
||||
"isPublished": true
|
||||
"timestamp": 1521298800
|
||||
},
|
||||
{
|
||||
"version": "0.2.0",
|
||||
@@ -79,8 +97,7 @@
|
||||
"pr": 419
|
||||
}
|
||||
],
|
||||
"timestamp": 1520089200,
|
||||
"isPublished": true
|
||||
"timestamp": 1520089200
|
||||
},
|
||||
{
|
||||
"version": "0.1.0",
|
||||
@@ -90,8 +107,7 @@
|
||||
"pr": 400
|
||||
}
|
||||
],
|
||||
"timestamp": 1518706800,
|
||||
"isPublished": true
|
||||
"timestamp": 1518706800
|
||||
},
|
||||
{
|
||||
"version": "0.0.8",
|
||||
@@ -101,7 +117,6 @@
|
||||
"pr": 389
|
||||
}
|
||||
],
|
||||
"timestamp": 1518102000,
|
||||
"isPublished": true
|
||||
"timestamp": 1518102000
|
||||
}
|
||||
]
|
||||
|
@@ -5,15 +5,23 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.4.0 - _April 11, 2018_
|
||||
|
||||
* Changed the config key `web3Provider` to `provider` to be consistent with other tools (#501)
|
||||
|
||||
## v0.3.5 - _April 2, 2018_
|
||||
|
||||
* Don't try to write contract artifact if an error occured (#485)
|
||||
|
||||
## v0.3.4 - _April 2, 2018_
|
||||
|
||||
* Create solc_bin directory if does not exist before attempting to compile (#491)
|
||||
|
||||
## v0.3.1 - _March 18, 2018_
|
||||
## v0.3.1 - _March 17, 2018_
|
||||
|
||||
* Add TS types for `yargs`
|
||||
|
||||
## v0.3.0 - _March 18, 2018_
|
||||
## v0.3.0 - _March 17, 2018_
|
||||
|
||||
* Add support for Solidity 0.4.20 and 0.4.21
|
||||
* Replace `jsonrpcPort` config with `jsonrpcUrl` (#426)
|
||||
@@ -26,15 +34,15 @@ CHANGELOG
|
||||
* Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package (#452)
|
||||
* Add `#!/usr/bin/env node` pragma above `cli.ts` script to fix command-line error.
|
||||
|
||||
## v0.2.0 - _March 4, 2018_
|
||||
## v0.2.0 - _March 3, 2018_
|
||||
|
||||
* Check dependencies when determining if contracts should be recompiled (#408)
|
||||
* Improve an error message for when deployer is supplied with an incorrect number of constructor arguments (#419)
|
||||
|
||||
## v0.1.0 - _February 16, 2018_
|
||||
## v0.1.0 - _February 15, 2018_
|
||||
|
||||
* Add the ability to pass in specific contracts to compile in CLI (#400)
|
||||
|
||||
## v0.0.8 - _February 9, 2018_
|
||||
## v0.0.8 - _February 8, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
This repository contains a CLI tool that facilitates compiling and deployment of smart contracts.
|
||||
|
||||
### Read the [Documentation](0xproject.com/docs/deployer).
|
||||
### Read the [Documentation](https://0xproject.com/docs/deployer).
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -41,11 +41,11 @@ var Compiler = require('@0xproject/deployer').Compiler;
|
||||
|
||||
## Contributing
|
||||
|
||||
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
|
||||
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
|
||||
|
||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
||||
|
||||
### Install Dependencies
|
||||
### Install dependencies
|
||||
|
||||
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
|
||||
|
||||
@@ -61,16 +61,36 @@ yarn install
|
||||
|
||||
### Build
|
||||
|
||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
You can also build this specific package by running the following from within its directory:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
or
|
||||
or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn build:watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
```bash
|
||||
yarn clean
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
```bash
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/deployer",
|
||||
"version": "0.3.4",
|
||||
"version": "0.3.5",
|
||||
"description": "Smart contract deployer of 0x protocol",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
@@ -17,6 +17,7 @@
|
||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
||||
"test:circleci": "yarn test:coverage",
|
||||
"docs:stage": "yarn build && node ./scripts/stage_docs.js",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.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"
|
||||
},
|
||||
@@ -46,12 +47,14 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/deployer/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.15",
|
||||
"@0xproject/tslint-config": "^0.4.13",
|
||||
"@0xproject/dev-utils": "^0.2.1",
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@types/require-from-string": "^1.2.0",
|
||||
"@types/semver": "^5.5.0",
|
||||
"@types/yargs": "^11.0.0",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"copyfiles": "^1.2.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"mocha": "^4.0.1",
|
||||
@@ -65,11 +68,11 @@
|
||||
"web3-typescript-typings": "^0.10.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/json-schemas": "^0.7.18",
|
||||
"@0xproject/types": "^0.4.2",
|
||||
"@0xproject/typescript-typings": "^0.0.2",
|
||||
"@0xproject/utils": "^0.4.4",
|
||||
"@0xproject/web3-wrapper": "^0.4.0",
|
||||
"@0xproject/json-schemas": "^0.7.19",
|
||||
"@0xproject/types": "^0.5.0",
|
||||
"@0xproject/typescript-typings": "^0.0.3",
|
||||
"@0xproject/utils": "^0.5.0",
|
||||
"@0xproject/web3-wrapper": "^0.5.0",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"lodash": "^4.17.4",
|
||||
|
0
packages/deployer/solc_bin/.gitkeep
Normal file
0
packages/deployer/solc_bin/.gitkeep
Normal file
@@ -11,7 +11,7 @@ import * as yargs from 'yargs';
|
||||
import { commands } from './commands';
|
||||
import { constants } from './utils/constants';
|
||||
import { consoleReporter } from './utils/error_reporter';
|
||||
import { CliOptions, CompilerOptions, DeployerOptions } from './utils/types';
|
||||
import { CliOptions, CompilerOptions, ContractDirectory, DeployerOptions } from './utils/types';
|
||||
|
||||
const DEFAULT_OPTIMIZER_ENABLED = false;
|
||||
const DEFAULT_CONTRACTS_DIR = path.resolve('src/contracts');
|
||||
@@ -27,7 +27,7 @@ const DEFAULT_CONTRACTS_LIST = '*';
|
||||
*/
|
||||
async function onCompileCommandAsync(argv: CliOptions): Promise<void> {
|
||||
const opts: CompilerOptions = {
|
||||
contractsDir: argv.contractsDir,
|
||||
contractDirs: getContractDirectoriesFromList(argv.contractDirs),
|
||||
networkId: argv.networkId,
|
||||
optimizerEnabled: argv.shouldOptimize,
|
||||
artifactsDir: argv.artifactsDir,
|
||||
@@ -45,7 +45,7 @@ async function onDeployCommandAsync(argv: CliOptions): Promise<void> {
|
||||
const web3Wrapper = new Web3Wrapper(web3Provider);
|
||||
const networkId = await web3Wrapper.getNetworkIdAsync();
|
||||
const compilerOpts: CompilerOptions = {
|
||||
contractsDir: argv.contractsDir,
|
||||
contractDirs: getContractDirectoriesFromList(argv.contractDirs),
|
||||
networkId,
|
||||
optimizerEnabled: argv.shouldOptimize,
|
||||
artifactsDir: argv.artifactsDir,
|
||||
@@ -67,6 +67,29 @@ async function onDeployCommandAsync(argv: CliOptions): Promise<void> {
|
||||
const deployerArgs = deployerArgsString.split(',');
|
||||
await commands.deployAsync(argv.contract as string, deployerArgs, deployerOpts);
|
||||
}
|
||||
/**
|
||||
* Creates a set of contracts to compile.
|
||||
* @param contractDirectoriesList Comma separated list of contract directories
|
||||
* @return Set of contract directories
|
||||
*/
|
||||
function getContractDirectoriesFromList(contractDirectoriesList: string): Set<ContractDirectory> {
|
||||
const directories = new Set();
|
||||
const possiblyNamespacedDirectories = contractDirectoriesList.split(',');
|
||||
_.forEach(possiblyNamespacedDirectories, namespacedDirectory => {
|
||||
const directoryComponents = namespacedDirectory.split(':');
|
||||
if (directoryComponents.length === 1) {
|
||||
const directory = { namespace: '', path: directoryComponents[0] };
|
||||
directories.add(directory);
|
||||
} else if (directoryComponents.length === 2) {
|
||||
const directory = { namespace: directoryComponents[0], path: directoryComponents[1] };
|
||||
directories.add(directory);
|
||||
} else {
|
||||
throw new Error(`Unable to parse contracts directory: '${namespacedDirectory}'`);
|
||||
}
|
||||
});
|
||||
|
||||
return directories;
|
||||
}
|
||||
/**
|
||||
* Creates a set of contracts to compile.
|
||||
* @param contracts Comma separated list of contracts to compile
|
||||
@@ -78,8 +101,7 @@ function getContractsSetFromList(contracts: string): Set<string> {
|
||||
}
|
||||
const contractsArray = contracts.split(',');
|
||||
_.forEach(contractsArray, contractName => {
|
||||
const fileName = `${contractName}${constants.SOLIDITY_FILE_EXTENSION}`;
|
||||
specifiedContracts.add(fileName);
|
||||
specifiedContracts.add(contractName);
|
||||
});
|
||||
return specifiedContracts;
|
||||
}
|
||||
@@ -104,10 +126,11 @@ function deployCommandBuilder(yargsInstance: any) {
|
||||
(() => {
|
||||
const identityCommandBuilder = _.identity;
|
||||
return yargs
|
||||
.option('contracts-dir', {
|
||||
.option('contract-dirs', {
|
||||
type: 'string',
|
||||
default: DEFAULT_CONTRACTS_DIR,
|
||||
description: 'path of contracts directory to compile',
|
||||
description:
|
||||
"comma separated list of contract directories.\nTo avoid filename clashes, directories should be prefixed with a namespace as follows: 'namespace:/path/to/dir'.",
|
||||
})
|
||||
.option('network-id', {
|
||||
type: 'number',
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { ContractAbi } from '@0xproject/types';
|
||||
import { AbiType, ContractAbi, MethodAbi } from '@0xproject/types';
|
||||
import { logUtils, promisify } from '@0xproject/utils';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
import * as fs from 'fs';
|
||||
@@ -11,6 +11,8 @@ import solc = require('solc');
|
||||
|
||||
import { binPaths } from './solc/bin_paths';
|
||||
import {
|
||||
constructContractId,
|
||||
constructUniqueSourceFileId,
|
||||
createDirIfDoesNotExistAsync,
|
||||
findImportIfExist,
|
||||
getContractArtifactIfExistsAsync,
|
||||
@@ -23,11 +25,14 @@ import { fsWrapper } from './utils/fs_wrapper';
|
||||
import {
|
||||
CompilerOptions,
|
||||
ContractArtifact,
|
||||
ContractDirectory,
|
||||
ContractIdToSourceFileId,
|
||||
ContractNetworkData,
|
||||
ContractNetworks,
|
||||
ContractSourceData,
|
||||
ContractSourceDataByFileId,
|
||||
ContractSources,
|
||||
ContractSpecificSourceData,
|
||||
FunctionNameToSeenCount,
|
||||
} from './utils/types';
|
||||
import { utils } from './utils/utils';
|
||||
|
||||
@@ -39,21 +44,22 @@ const SOLC_BIN_DIR = path.join(__dirname, '..', '..', 'solc_bin');
|
||||
* to artifact files.
|
||||
*/
|
||||
export class Compiler {
|
||||
private _contractsDir: string;
|
||||
private _contractDirs: Set<ContractDirectory>;
|
||||
private _networkId: number;
|
||||
private _optimizerEnabled: boolean;
|
||||
private _artifactsDir: string;
|
||||
// This get's set in the beggining of `compileAsync` function. It's not called from a constructor, but it's the only public method of that class and could as well be.
|
||||
private _contractSources!: ContractSources;
|
||||
private _solcErrors: Set<string> = new Set();
|
||||
private _specifiedContracts: Set<string> = new Set();
|
||||
private _contractSourceData: ContractSourceData = {};
|
||||
private _contractSourceDataByFileId: ContractSourceDataByFileId = {};
|
||||
|
||||
/**
|
||||
* Recursively retrieves Solidity source code from directory.
|
||||
* @param dirPath Directory to search.
|
||||
* @return Mapping of contract fileName to contract source.
|
||||
* @param contractBaseDir Base contracts directory of search tree.
|
||||
* @return Mapping of sourceFilePath to the contract source.
|
||||
*/
|
||||
private static async _getContractSourcesAsync(dirPath: string): Promise<ContractSources> {
|
||||
private static async _getContractSourcesAsync(dirPath: string, contractBaseDir: string): Promise<ContractSources> {
|
||||
let dirContents: string[] = [];
|
||||
try {
|
||||
dirContents = await fsWrapper.readdirAsync(dirPath);
|
||||
@@ -69,14 +75,18 @@ export class Compiler {
|
||||
encoding: 'utf8',
|
||||
};
|
||||
const source = await fsWrapper.readFileAsync(contentPath, opts);
|
||||
sources[fileName] = source;
|
||||
logUtils.log(`Reading ${fileName} source...`);
|
||||
if (!_.startsWith(contentPath, contractBaseDir)) {
|
||||
throw new Error(`Expected content path '${contentPath}' to begin with '${contractBaseDir}'`);
|
||||
}
|
||||
const sourceFilePath = contentPath.slice(contractBaseDir.length);
|
||||
sources[sourceFilePath] = source;
|
||||
logUtils.log(`Reading ${sourceFilePath} source...`);
|
||||
} catch (err) {
|
||||
logUtils.log(`Could not find file at ${contentPath}`);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const nestedSources = await Compiler._getContractSourcesAsync(contentPath);
|
||||
const nestedSources = await Compiler._getContractSourcesAsync(contentPath, contractBaseDir);
|
||||
sources = {
|
||||
...sources,
|
||||
...nestedSources,
|
||||
@@ -94,7 +104,7 @@ export class Compiler {
|
||||
* @return An instance of the Compiler class.
|
||||
*/
|
||||
constructor(opts: CompilerOptions) {
|
||||
this._contractsDir = opts.contractsDir;
|
||||
this._contractDirs = opts.contractDirs;
|
||||
this._networkId = opts.networkId;
|
||||
this._optimizerEnabled = opts.optimizerEnabled;
|
||||
this._artifactsDir = opts.artifactsDir;
|
||||
@@ -106,28 +116,49 @@ export class Compiler {
|
||||
public async compileAsync(): Promise<void> {
|
||||
await createDirIfDoesNotExistAsync(this._artifactsDir);
|
||||
await createDirIfDoesNotExistAsync(SOLC_BIN_DIR);
|
||||
this._contractSources = await Compiler._getContractSourcesAsync(this._contractsDir);
|
||||
_.forIn(this._contractSources, this._setContractSpecificSourceData.bind(this));
|
||||
const fileNames = this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER)
|
||||
? _.keys(this._contractSources)
|
||||
: Array.from(this._specifiedContracts.values());
|
||||
for (const fileName of fileNames) {
|
||||
await this._compileContractAsync(fileName);
|
||||
this._contractSources = {};
|
||||
const contractIdToSourceFileId: ContractIdToSourceFileId = {};
|
||||
const contractDirs = Array.from(this._contractDirs.values());
|
||||
for (const contractDir of contractDirs) {
|
||||
const sources = await Compiler._getContractSourcesAsync(contractDir.path, contractDir.path);
|
||||
_.forIn(sources, (source, sourceFilePath) => {
|
||||
const sourceFileId = constructUniqueSourceFileId(contractDir.namespace, sourceFilePath);
|
||||
// Record the file's source and data
|
||||
if (!_.isUndefined(this._contractSources[sourceFileId])) {
|
||||
throw new Error(`Found duplicate source files with ID '${sourceFileId}'`);
|
||||
}
|
||||
this._contractSources[sourceFileId] = source;
|
||||
// Create a mapping between the contract id and its source file id
|
||||
const contractId = constructContractId(contractDir.namespace, sourceFilePath);
|
||||
if (!_.isUndefined(contractIdToSourceFileId[contractId])) {
|
||||
throw new Error(`Found duplicate contract with ID '${contractId}'`);
|
||||
}
|
||||
contractIdToSourceFileId[contractId] = sourceFileId;
|
||||
});
|
||||
}
|
||||
this._solcErrors.forEach(errMsg => {
|
||||
logUtils.log(errMsg);
|
||||
});
|
||||
_.forIn(this._contractSources, this._setContractSpecificSourceData.bind(this));
|
||||
const specifiedContractIds = this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER)
|
||||
? _.keys(contractIdToSourceFileId)
|
||||
: Array.from(this._specifiedContracts.values());
|
||||
await Promise.all(
|
||||
_.map(specifiedContractIds, async contractId =>
|
||||
this._compileContractAsync(contractIdToSourceFileId[contractId]),
|
||||
),
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Compiles contract and saves artifact to artifactsDir.
|
||||
* @param fileName Name of contract with '.sol' extension.
|
||||
* @param sourceFileId Unique ID of the source file.
|
||||
*/
|
||||
private async _compileContractAsync(fileName: string): Promise<void> {
|
||||
private async _compileContractAsync(sourceFileId: string): Promise<void> {
|
||||
if (_.isUndefined(this._contractSources)) {
|
||||
throw new Error('Contract sources not yet initialized');
|
||||
}
|
||||
const contractSpecificSourceData = this._contractSourceData[fileName];
|
||||
const currentArtifactIfExists = await getContractArtifactIfExistsAsync(this._artifactsDir, fileName);
|
||||
if (_.isUndefined(this._contractSourceDataByFileId[sourceFileId])) {
|
||||
throw new Error(`Contract source for ${sourceFileId} not yet initialized`);
|
||||
}
|
||||
const contractSpecificSourceData = this._contractSourceDataByFileId[sourceFileId];
|
||||
const currentArtifactIfExists = await getContractArtifactIfExistsAsync(this._artifactsDir, sourceFileId);
|
||||
const sourceHash = `0x${contractSpecificSourceData.sourceHash.toString('hex')}`;
|
||||
const sourceTreeHash = `0x${contractSpecificSourceData.sourceTreeHash.toString('hex')}`;
|
||||
|
||||
@@ -166,29 +197,43 @@ export class Compiler {
|
||||
}
|
||||
const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename));
|
||||
|
||||
logUtils.log(`Compiling ${fileName} with Solidity v${solcVersion}...`);
|
||||
const source = this._contractSources[fileName];
|
||||
logUtils.log(`Compiling ${sourceFileId} with Solidity v${solcVersion}...`);
|
||||
const source = this._contractSources[sourceFileId];
|
||||
const input = {
|
||||
[fileName]: source,
|
||||
[sourceFileId]: source,
|
||||
};
|
||||
const sourcesToCompile = {
|
||||
sources: input,
|
||||
};
|
||||
|
||||
const compiled = solcInstance.compile(sourcesToCompile, Number(this._optimizerEnabled), importPath =>
|
||||
findImportIfExist(this._contractSources, importPath),
|
||||
findImportIfExist(this._contractSources, sourceFileId, importPath),
|
||||
);
|
||||
|
||||
if (!_.isUndefined(compiled.errors)) {
|
||||
_.forEach(compiled.errors, errMsg => {
|
||||
const normalizedErrMsg = getNormalizedErrMsg(errMsg);
|
||||
this._solcErrors.add(normalizedErrMsg);
|
||||
});
|
||||
const SOLIDITY_WARNING_PREFIX = 'Warning';
|
||||
const isError = (errorOrWarning: string) => !errorOrWarning.includes(SOLIDITY_WARNING_PREFIX);
|
||||
const isWarning = (errorOrWarning: string) => errorOrWarning.includes(SOLIDITY_WARNING_PREFIX);
|
||||
const errors = _.filter(compiled.errors, isError);
|
||||
const warnings = _.filter(compiled.errors, isWarning);
|
||||
if (!_.isEmpty(errors)) {
|
||||
errors.forEach(errMsg => {
|
||||
const normalizedErrMsg = getNormalizedErrMsg(errMsg);
|
||||
logUtils.log(normalizedErrMsg);
|
||||
});
|
||||
process.exit(1);
|
||||
} else {
|
||||
warnings.forEach(errMsg => {
|
||||
const normalizedErrMsg = getNormalizedErrMsg(errMsg);
|
||||
logUtils.log(normalizedErrMsg);
|
||||
});
|
||||
}
|
||||
}
|
||||
const contractName = path.basename(fileName, constants.SOLIDITY_FILE_EXTENSION);
|
||||
const contractIdentifier = `${fileName}:${contractName}`;
|
||||
const contractName = path.basename(sourceFileId, constants.SOLIDITY_FILE_EXTENSION);
|
||||
const contractIdentifier = `${sourceFileId}:${contractName}`;
|
||||
if (_.isUndefined(compiled.contracts[contractIdentifier])) {
|
||||
throw new Error(
|
||||
`Contract ${contractName} not found in ${fileName}. Please make sure your contract has the same name as it's file name`,
|
||||
`Contract ${contractName} not found in ${sourceFileId}. Please make sure your contract has the same name as it's file name`,
|
||||
);
|
||||
}
|
||||
const abi: ContractAbi = JSON.parse(compiled.contracts[contractIdentifier].interface);
|
||||
@@ -198,6 +243,7 @@ export class Compiler {
|
||||
const sourceMapRuntime = compiled.contracts[contractIdentifier].srcmapRuntime;
|
||||
const sources = _.keys(compiled.sources);
|
||||
const updated_at = Date.now();
|
||||
|
||||
const contractNetworkData: ContractNetworkData = {
|
||||
solc_version: solcVersion,
|
||||
keccak256: sourceHash,
|
||||
@@ -234,28 +280,30 @@ export class Compiler {
|
||||
const artifactString = utils.stringifyWithFormatting(newArtifact);
|
||||
const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`;
|
||||
await fsWrapper.writeFileAsync(currentArtifactPath, artifactString);
|
||||
logUtils.log(`${fileName} artifact saved!`);
|
||||
logUtils.log(`${sourceFileId} artifact saved!`);
|
||||
}
|
||||
/**
|
||||
* Gets contract dependendencies and keccak256 hash from source.
|
||||
* @param source Source code of contract.
|
||||
* @param fileId FileId of the contract source file.
|
||||
* @return Object with contract dependencies and keccak256 hash of source.
|
||||
*/
|
||||
private _setContractSpecificSourceData(source: string, fileName: string): void {
|
||||
if (!_.isUndefined(this._contractSourceData[fileName])) {
|
||||
private _setContractSpecificSourceData(source: string, fileId: string): void {
|
||||
if (!_.isUndefined(this._contractSourceDataByFileId[fileId])) {
|
||||
return;
|
||||
}
|
||||
const sourceHash = ethUtil.sha3(source);
|
||||
const solcVersionRange = parseSolidityVersionRange(source);
|
||||
const dependencies = parseDependencies(source);
|
||||
const sourceTreeHash = this._getSourceTreeHash(fileName, sourceHash, dependencies);
|
||||
this._contractSourceData[fileName] = {
|
||||
const dependencies = parseDependencies(source, fileId);
|
||||
const sourceTreeHash = this._getSourceTreeHash(fileId, sourceHash, dependencies);
|
||||
this._contractSourceDataByFileId[fileId] = {
|
||||
dependencies,
|
||||
solcVersionRange,
|
||||
sourceHash,
|
||||
sourceTreeHash,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source tree hash for a file and its dependencies.
|
||||
* @param fileName Name of contract file.
|
||||
@@ -267,7 +315,7 @@ export class Compiler {
|
||||
const dependencySourceTreeHashes = _.map(dependencies, dependency => {
|
||||
const source = this._contractSources[dependency];
|
||||
this._setContractSpecificSourceData(source, dependency);
|
||||
const sourceData = this._contractSourceData[dependency];
|
||||
const sourceData = this._contractSourceDataByFileId[dependency];
|
||||
return this._getSourceTreeHash(dependency, sourceData.sourceHash, sourceData.dependencies);
|
||||
});
|
||||
const sourceTreeHashesBuffer = Buffer.concat([sourceHash, ...dependencySourceTreeHashes]);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { AbiType, ConstructorAbi, ContractAbi, TxData } from '@0xproject/types';
|
||||
import { AbiType, ConstructorAbi, ContractAbi, Provider, TxData } from '@0xproject/types';
|
||||
import { logUtils } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
@@ -38,15 +38,15 @@ export class Deployer {
|
||||
this._artifactsDir = opts.artifactsDir;
|
||||
this._networkId = opts.networkId;
|
||||
this._defaults = opts.defaults;
|
||||
let web3Provider: Web3.Provider;
|
||||
if (_.isUndefined((opts as ProviderDeployerOptions).web3Provider)) {
|
||||
let web3Provider: Provider;
|
||||
if (_.isUndefined((opts as ProviderDeployerOptions).provider)) {
|
||||
const jsonrpcUrl = (opts as UrlDeployerOptions).jsonrpcUrl;
|
||||
if (_.isUndefined(jsonrpcUrl)) {
|
||||
throw new Error(`Deployer options don't contain web3Provider nor jsonrpcUrl. Please pass one of them`);
|
||||
}
|
||||
web3Provider = new Web3.providers.HttpProvider(jsonrpcUrl);
|
||||
} else {
|
||||
web3Provider = (opts as ProviderDeployerOptions).web3Provider;
|
||||
web3Provider = (opts as ProviderDeployerOptions).provider;
|
||||
}
|
||||
this.web3Wrapper = new Web3Wrapper(web3Provider, this._defaults);
|
||||
}
|
||||
|
46
packages/deployer/src/globals.d.ts
vendored
46
packages/deployer/src/globals.d.ts
vendored
@@ -1,49 +1,3 @@
|
||||
declare module 'dirty-chai';
|
||||
|
||||
// tslint:disable:completed-docs
|
||||
declare module 'solc' {
|
||||
export interface ContractCompilationResult {
|
||||
srcmap: string;
|
||||
srcmapRuntime: string;
|
||||
bytecode: string;
|
||||
runtimeBytecode: string;
|
||||
interface: string;
|
||||
}
|
||||
export interface CompilationResult {
|
||||
errors: string[];
|
||||
contracts: {
|
||||
[contractIdentifier: string]: ContractCompilationResult;
|
||||
};
|
||||
sources: {
|
||||
[sourceName: string]: {
|
||||
AST: any;
|
||||
};
|
||||
};
|
||||
sourceList: string[];
|
||||
}
|
||||
export interface ImportContents {
|
||||
contents: string;
|
||||
}
|
||||
export interface InputSources {
|
||||
sources: {
|
||||
[fileName: string]: string;
|
||||
};
|
||||
}
|
||||
export interface SolcInstance {
|
||||
compile(
|
||||
sources: InputSources,
|
||||
optimizerEnabled: number,
|
||||
findImports: (importPath: string) => ImportContents,
|
||||
): CompilationResult;
|
||||
}
|
||||
export function loadRemoteVersion(versionName: string, cb: (err: Error | null, res?: SolcInstance) => void): void;
|
||||
export function setupMethods(solcBin: any): SolcInstance;
|
||||
}
|
||||
|
||||
declare module 'web3-eth-abi' {
|
||||
export function encodeParameters(typesArray: string[], parameters: any[]): string;
|
||||
}
|
||||
|
||||
declare module '*.json' {
|
||||
const json: any;
|
||||
/* tslint:disable */
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { AbiType, ContractAbi, MethodAbi } from '@0xproject/types';
|
||||
import { logUtils } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
import * as path from 'path';
|
||||
@@ -5,8 +6,48 @@ import * as solc from 'solc';
|
||||
|
||||
import { constants } from './constants';
|
||||
import { fsWrapper } from './fs_wrapper';
|
||||
import { ContractArtifact, ContractSources } from './types';
|
||||
import { ContractArtifact, ContractSources, FunctionNameToSeenCount } from './types';
|
||||
|
||||
/**
|
||||
* Constructs a system-wide unique identifier for a source file.
|
||||
* @param directoryNamespace Namespace of the source file's root contract directory.
|
||||
* @param sourceFilePath Path to a source file, relative to contractBaseDir.
|
||||
* @return sourceFileId A system-wide unique identifier for the source file.
|
||||
*/
|
||||
export function constructUniqueSourceFileId(directoryNamespace: string, sourceFilePath: string): string {
|
||||
const namespacePrefix = !_.isEmpty(directoryNamespace) ? `/${directoryNamespace}` : '';
|
||||
const sourceFilePathNoLeadingSlash = sourceFilePath.replace(/^\/+/g, '');
|
||||
const sourceFileId = `${namespacePrefix}/${sourceFilePathNoLeadingSlash}`;
|
||||
return sourceFileId;
|
||||
}
|
||||
/**
|
||||
* Constructs a system-wide unique identifier for a dependency file.
|
||||
* @param dependencyFilePath Path from a sourceFile to a dependency.
|
||||
* @param contractBaseDir Base contracts directory of search tree.
|
||||
* @return sourceFileId A system-wide unique identifier for the source file.
|
||||
*/
|
||||
export function constructDependencyFileId(dependencyFilePath: string, sourceFilePath: string): string {
|
||||
if (_.startsWith(dependencyFilePath, '/')) {
|
||||
// Path of the form /namespace/path/to/dependency.sol
|
||||
return dependencyFilePath;
|
||||
} else {
|
||||
// Dependency is relative to the source file: ./dependency.sol, ../../some/path/dependency.sol, etc.
|
||||
// Join the two paths to construct a valid source file id: /namespace/path/to/dependency.sol
|
||||
return path.join(path.dirname(sourceFilePath), dependencyFilePath);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Constructs a system-wide unique identifier for a contract.
|
||||
* @param directoryNamespace Namespace of the source file's root contract directory.
|
||||
* @param sourceFilePath Path to a source file, relative to contractBaseDir.
|
||||
* @return sourceFileId A system-wide unique identifier for contract.
|
||||
*/
|
||||
export function constructContractId(directoryNamespace: string, sourceFilePath: string): string {
|
||||
const namespacePrefix = !_.isEmpty(directoryNamespace) ? `${directoryNamespace}:` : '';
|
||||
const sourceFileName = path.basename(sourceFilePath, constants.SOLIDITY_FILE_EXTENSION);
|
||||
const contractId = `${namespacePrefix}${sourceFileName}`;
|
||||
return contractId;
|
||||
}
|
||||
/**
|
||||
* Gets contract data on network or returns if an artifact does not exist.
|
||||
* @param artifactsDir Path to the artifacts directory.
|
||||
@@ -82,9 +123,10 @@ export function getNormalizedErrMsg(errMsg: string): string {
|
||||
/**
|
||||
* Parses the contract source code and extracts the dendencies
|
||||
* @param source Contract source code
|
||||
* @param sourceFilePath File path of the source code.
|
||||
* @return List of dependendencies
|
||||
*/
|
||||
export function parseDependencies(source: string): string[] {
|
||||
export function parseDependencies(source: string, sourceFileId: string): string[] {
|
||||
// TODO: Use a proper parser
|
||||
const IMPORT_REGEX = /(import\s)/;
|
||||
const DEPENDENCY_PATH_REGEX = /"([^"]+)"/; // Source: https://github.com/BlockChainCompany/soljitsu/blob/master/lib/shared.js
|
||||
@@ -95,8 +137,8 @@ export function parseDependencies(source: string): string[] {
|
||||
const dependencyMatch = line.match(DEPENDENCY_PATH_REGEX);
|
||||
if (!_.isNull(dependencyMatch)) {
|
||||
const dependencyPath = dependencyMatch[1];
|
||||
const basenName = path.basename(dependencyPath);
|
||||
dependencies.push(basenName);
|
||||
const dependencyId = constructDependencyFileId(dependencyPath, sourceFileId);
|
||||
dependencies.push(dependencyId);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -107,14 +149,19 @@ export function parseDependencies(source: string): string[] {
|
||||
* Callback to resolve dependencies with `solc.compile`.
|
||||
* Throws error if contractSources not yet initialized.
|
||||
* @param contractSources Source codes of contracts.
|
||||
* @param importPath Path to an imported dependency.
|
||||
* @param sourceFileId ID of the source file.
|
||||
* @param importPath Path of dependency source file.
|
||||
* @return Import contents object containing source code of dependency.
|
||||
*/
|
||||
export function findImportIfExist(contractSources: ContractSources, importPath: string): solc.ImportContents {
|
||||
const fileName = path.basename(importPath);
|
||||
const source = contractSources[fileName];
|
||||
export function findImportIfExist(
|
||||
contractSources: ContractSources,
|
||||
sourceFileId: string,
|
||||
importPath: string,
|
||||
): solc.ImportContents {
|
||||
const dependencyFileId = constructDependencyFileId(importPath, sourceFileId);
|
||||
const source = contractSources[dependencyFileId];
|
||||
if (_.isUndefined(source)) {
|
||||
throw new Error(`Contract source not found for ${fileName}`);
|
||||
throw new Error(`Contract source not found for ${dependencyFileId}`);
|
||||
}
|
||||
const importContents: solc.ImportContents = {
|
||||
contents: source,
|
||||
|
@@ -1,11 +1,9 @@
|
||||
import { schemas, SchemaValidator } from '@0xproject/json-schemas';
|
||||
import { ContractAbi, EventAbi, FunctionAbi, MethodAbi, TxData } from '@0xproject/types';
|
||||
import { AbiType, ContractAbi, EventAbi, FunctionAbi, MethodAbi, TxData } from '@0xproject/types';
|
||||
import { promisify } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import { AbiType } from './types';
|
||||
|
||||
export class Contract implements Web3.ContractInstance {
|
||||
public address: string;
|
||||
public abi: ContractAbi;
|
||||
|
@@ -1,9 +1,7 @@
|
||||
import { AbiDefinition, ContractAbi, DataItem } from '@0xproject/types';
|
||||
import { AbiDefinition, AbiType, ContractAbi, DataItem } from '@0xproject/types';
|
||||
import * as _ from 'lodash';
|
||||
import * as web3Abi from 'web3-eth-abi';
|
||||
|
||||
import { AbiType } from './types';
|
||||
|
||||
export const encoder = {
|
||||
encodeConstructorArgsFromAbi(args: any[], abi: ContractAbi): string {
|
||||
const constructorTypes: string[] = [];
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { ContractAbi, TxData } from '@0xproject/types';
|
||||
import { ContractAbi, Provider, TxData } from '@0xproject/types';
|
||||
import * as Web3 from 'web3';
|
||||
import * as yargs from 'yargs';
|
||||
|
||||
@@ -18,6 +18,11 @@ export interface ContractNetworks {
|
||||
[key: number]: ContractNetworkData;
|
||||
}
|
||||
|
||||
export interface ContractDirectory {
|
||||
path: string;
|
||||
namespace: string;
|
||||
}
|
||||
|
||||
export interface ContractNetworkData {
|
||||
solc_version: string;
|
||||
optimizer_enabled: boolean;
|
||||
@@ -40,7 +45,7 @@ export interface SolcErrors {
|
||||
|
||||
export interface CliOptions extends yargs.Arguments {
|
||||
artifactsDir: string;
|
||||
contractsDir: string;
|
||||
contractDirs: string;
|
||||
jsonrpcUrl: string;
|
||||
networkId: number;
|
||||
shouldOptimize: boolean;
|
||||
@@ -51,7 +56,7 @@ export interface CliOptions extends yargs.Arguments {
|
||||
}
|
||||
|
||||
export interface CompilerOptions {
|
||||
contractsDir: string;
|
||||
contractDirs: Set<ContractDirectory>;
|
||||
networkId: number;
|
||||
optimizerEnabled: boolean;
|
||||
artifactsDir: string;
|
||||
@@ -65,7 +70,7 @@ export interface BaseDeployerOptions {
|
||||
}
|
||||
|
||||
export interface ProviderDeployerOptions extends BaseDeployerOptions {
|
||||
web3Provider: Web3.Provider;
|
||||
provider: Provider;
|
||||
}
|
||||
|
||||
export interface UrlDeployerOptions extends BaseDeployerOptions {
|
||||
@@ -78,7 +83,11 @@ export interface ContractSources {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
export interface ContractSourceData {
|
||||
export interface ContractIdToSourceFileId {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
export interface ContractSourceDataByFileId {
|
||||
[key: string]: ContractSpecificSourceData;
|
||||
}
|
||||
|
||||
@@ -98,4 +107,8 @@ export interface Token {
|
||||
swarmHash: string;
|
||||
}
|
||||
|
||||
export interface FunctionNameToSeenCount {
|
||||
[key: string]: number;
|
||||
}
|
||||
|
||||
export type DoneCallback = (err?: Error) => void;
|
||||
|
@@ -3,7 +3,13 @@ import 'mocha';
|
||||
|
||||
import { Compiler } from '../src/compiler';
|
||||
import { fsWrapper } from '../src/utils/fs_wrapper';
|
||||
import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } from '../src/utils/types';
|
||||
import {
|
||||
CompilerOptions,
|
||||
ContractArtifact,
|
||||
ContractDirectory,
|
||||
ContractNetworkData,
|
||||
DoneCallback,
|
||||
} from '../src/utils/types';
|
||||
|
||||
import { exchange_binary } from './fixtures/exchange_bin';
|
||||
import { constants } from './util/constants';
|
||||
@@ -13,11 +19,15 @@ const expect = chai.expect;
|
||||
describe('#Compiler', function() {
|
||||
this.timeout(constants.timeoutMs);
|
||||
const artifactsDir = `${__dirname}/fixtures/artifacts`;
|
||||
const contractsDir = `${__dirname}/fixtures/contracts`;
|
||||
const mainContractDir: ContractDirectory = { path: `${__dirname}/fixtures/contracts/main`, namespace: 'main' };
|
||||
const baseContractDir: ContractDirectory = { path: `${__dirname}/fixtures/contracts/base`, namespace: 'base' };
|
||||
const contractDirs: Set<ContractDirectory> = new Set();
|
||||
contractDirs.add(mainContractDir);
|
||||
contractDirs.add(baseContractDir);
|
||||
const exchangeArtifactPath = `${artifactsDir}/Exchange.json`;
|
||||
const compilerOpts: CompilerOptions = {
|
||||
artifactsDir,
|
||||
contractsDir,
|
||||
contractDirs,
|
||||
networkId: constants.networkId,
|
||||
optimizerEnabled: constants.optimizerEnabled,
|
||||
specifiedContracts: new Set(constants.specifiedContracts),
|
||||
|
@@ -47,28 +47,34 @@ describe('Compiler utils', () => {
|
||||
});
|
||||
describe('#parseDependencies', () => {
|
||||
it('correctly parses Exchange dependencies', async () => {
|
||||
const exchangeSource = await fsWrapper.readFileAsync(`${__dirname}/fixtures/contracts/Exchange.sol`, {
|
||||
const exchangeSource = await fsWrapper.readFileAsync(`${__dirname}/fixtures/contracts/main/Exchange.sol`, {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
expect(parseDependencies(exchangeSource)).to.be.deep.equal([
|
||||
'TokenTransferProxy.sol',
|
||||
'Token.sol',
|
||||
'SafeMath.sol',
|
||||
const sourceFileId = '/main/Exchange.sol';
|
||||
expect(parseDependencies(exchangeSource, sourceFileId)).to.be.deep.equal([
|
||||
'/main/TokenTransferProxy.sol',
|
||||
'/base/Token.sol',
|
||||
'/base/SafeMath.sol',
|
||||
]);
|
||||
});
|
||||
it('correctly parses TokenTransferProxy dependencies', async () => {
|
||||
const exchangeSource = await fsWrapper.readFileAsync(
|
||||
`${__dirname}/fixtures/contracts/TokenTransferProxy.sol`,
|
||||
`${__dirname}/fixtures/contracts/main/TokenTransferProxy.sol`,
|
||||
{
|
||||
encoding: 'utf8',
|
||||
},
|
||||
);
|
||||
expect(parseDependencies(exchangeSource)).to.be.deep.equal(['Token.sol', 'Ownable.sol']);
|
||||
const sourceFileId = '/main/TokenTransferProxy.sol';
|
||||
expect(parseDependencies(exchangeSource, sourceFileId)).to.be.deep.equal([
|
||||
'/base/Token.sol',
|
||||
'/base/Ownable.sol',
|
||||
]);
|
||||
});
|
||||
// TODO: For now that doesn't work. This will work after we switch to a grammar-based parser
|
||||
it.skip('correctly parses commented out dependencies', async () => {
|
||||
const contractWithCommentedOutDependencies = `// import "./TokenTransferProxy.sol";`;
|
||||
expect(parseDependencies(contractWithCommentedOutDependencies)).to.be.deep.equal([]);
|
||||
const sourceFileId = '/main/TokenTransferProxy.sol';
|
||||
expect(parseDependencies(contractWithCommentedOutDependencies, sourceFileId)).to.be.deep.equal([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -4,7 +4,13 @@ import 'mocha';
|
||||
import { Compiler } from '../src/compiler';
|
||||
import { Deployer } from '../src/deployer';
|
||||
import { fsWrapper } from '../src/utils/fs_wrapper';
|
||||
import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } from '../src/utils/types';
|
||||
import {
|
||||
CompilerOptions,
|
||||
ContractArtifact,
|
||||
ContractDirectory,
|
||||
ContractNetworkData,
|
||||
DoneCallback,
|
||||
} from '../src/utils/types';
|
||||
|
||||
import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
|
||||
import { constants } from './util/constants';
|
||||
@@ -13,11 +19,15 @@ const expect = chai.expect;
|
||||
|
||||
describe('#Deployer', () => {
|
||||
const artifactsDir = `${__dirname}/fixtures/artifacts`;
|
||||
const contractsDir = `${__dirname}/fixtures/contracts`;
|
||||
const exchangeArtifactPath = `${artifactsDir}/Exchange.json`;
|
||||
const mainContractDir: ContractDirectory = { path: `${__dirname}/fixtures/contracts/main`, namespace: '' };
|
||||
const baseContractDir: ContractDirectory = { path: `${__dirname}/fixtures/contracts/base`, namespace: 'base' };
|
||||
const contractDirs: Set<ContractDirectory> = new Set();
|
||||
contractDirs.add(mainContractDir);
|
||||
contractDirs.add(baseContractDir);
|
||||
const compilerOpts: CompilerOptions = {
|
||||
artifactsDir,
|
||||
contractsDir,
|
||||
contractDirs,
|
||||
networkId: constants.networkId,
|
||||
optimizerEnabled: constants.optimizerEnabled,
|
||||
specifiedContracts: new Set(constants.specifiedContracts),
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
Copyright 2017 ZeroEx Intl.
|
||||
Copyright 2018 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -19,8 +19,8 @@
|
||||
pragma solidity 0.4.14;
|
||||
|
||||
import "./TokenTransferProxy.sol";
|
||||
import "./base/Token.sol";
|
||||
import "./base/SafeMath.sol";
|
||||
import "/base/Token.sol";
|
||||
import "/base/SafeMath.sol";
|
||||
|
||||
/// @title Exchange - Facilitates exchange of ERC20 tokens.
|
||||
/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
Copyright 2017 ZeroEx Intl.
|
||||
Copyright 2018 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
pragma solidity 0.4.14;
|
||||
|
||||
import "./base/Token.sol";
|
||||
import "./base/Ownable.sol";
|
||||
import "/base/Token.sol";
|
||||
import "/base/Ownable.sol";
|
||||
|
||||
/// @title TokenTransferProxy - Transfers tokens on behalf of contracts that have been approved via decentralized governance.
|
||||
/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
|
@@ -5,7 +5,7 @@ export const constants = {
|
||||
jsonrpcUrl: 'http://localhost:8545',
|
||||
optimizerEnabled: false,
|
||||
gasPrice: new BigNumber(20000000000),
|
||||
timeoutMs: 20000,
|
||||
timeoutMs: 30000,
|
||||
zrxTokenAddress: '0xe41d2489571d322189246dafa5ebde1f4699f498',
|
||||
tokenTransferProxyAddress: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4',
|
||||
specifiedContracts: '*',
|
||||
|
@@ -4,10 +4,5 @@
|
||||
"outDir": "lib",
|
||||
"strictFunctionTypes": false
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*",
|
||||
"./test/**/*",
|
||||
"../../node_modules/types-bn/index.d.ts",
|
||||
"../../node_modules/types-ethereumjs-util/index.d.ts"
|
||||
]
|
||||
"include": ["./src/**/*", "./test/**/*"]
|
||||
}
|
||||
|
@@ -1,4 +1,22 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1523462196,
|
||||
"version": "0.3.5",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1522673609,
|
||||
"version": "0.3.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1522658513,
|
||||
"version": "0.3.3",
|
||||
@@ -18,8 +36,7 @@
|
||||
"note": "Move `@0xproject/web3_wrapper` to dependencies from devDependencies."
|
||||
}
|
||||
],
|
||||
"timestamp": 1521298800,
|
||||
"isPublished": true
|
||||
"timestamp": 1521298800
|
||||
},
|
||||
{
|
||||
"version": "0.3.0",
|
||||
@@ -37,8 +54,7 @@
|
||||
"pr": 426
|
||||
}
|
||||
],
|
||||
"timestamp": 1521298800,
|
||||
"isPublished": true
|
||||
"timestamp": 1521298800
|
||||
},
|
||||
{
|
||||
"version": "0.2.0",
|
||||
@@ -48,8 +64,7 @@
|
||||
"pr": 392
|
||||
}
|
||||
],
|
||||
"timestamp": 1518706800,
|
||||
"isPublished": true
|
||||
"timestamp": 1518706800
|
||||
},
|
||||
{
|
||||
"version": "0.0.12",
|
||||
@@ -59,8 +74,7 @@
|
||||
"pr": 389
|
||||
}
|
||||
],
|
||||
"timestamp": 1518102000,
|
||||
"isPublished": true
|
||||
"timestamp": 1518102000
|
||||
},
|
||||
{
|
||||
"version": "0.0.11",
|
||||
@@ -70,7 +84,6 @@
|
||||
"pr": 352
|
||||
}
|
||||
],
|
||||
"timestamp": 1517929200,
|
||||
"isPublished": true
|
||||
"timestamp": 1517929200
|
||||
}
|
||||
]
|
||||
|
@@ -5,29 +5,37 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.3.5 - _April 11, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.4 - _April 2, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.3 - _April 2, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.1 - _March 18, 2018_
|
||||
## v0.3.1 - _March 17, 2018_
|
||||
|
||||
* Reduce npm package size by adding an `.npmignore` file.
|
||||
* Move `@0xproject/web3_wrapper` to dependencies from devDependencies.
|
||||
|
||||
## v0.3.0 - _March 18, 2018_
|
||||
## v0.3.0 - _March 17, 2018_
|
||||
|
||||
* Add coverage subprovider if SOLIDITY_COVERAGE env variable is true (#426)
|
||||
* Refactor `BlockchainLifecycle` to work with in-process ganache (#426)
|
||||
* Remove `RPC` class and move it's logic to `Web3Wrapper` (#426)
|
||||
|
||||
## v0.2.0 - _February 16, 2018_
|
||||
## v0.2.0 - _February 15, 2018_
|
||||
|
||||
* Remove subproviders (#392)
|
||||
|
||||
## v0.0.12 - _February 9, 2018_
|
||||
## v0.0.12 - _February 8, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.0.11 - _February 7, 2018_
|
||||
## v0.0.11 - _February 6, 2018_
|
||||
|
||||
* Updated `types-ethereumjs-util` dev dependency (#352)
|
||||
|
@@ -26,3 +26,67 @@ If your project is in [TypeScript](https://www.typescriptlang.org/), add the fol
|
||||
"typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
|
||||
}
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
|
||||
|
||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
||||
|
||||
### Install dependencies
|
||||
|
||||
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
|
||||
|
||||
```bash
|
||||
yarn config set workspaces-experimental true
|
||||
```
|
||||
|
||||
Then install dependencies
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
You can also build this specific package by running the following from within its directory:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn build:watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
```bash
|
||||
yarn clean
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
```bash
|
||||
yarn lint
|
||||
```
|
||||
|
||||
### Run Tests
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/dev-utils",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.4",
|
||||
"description": "0x dev TS utils",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
@@ -13,7 +13,8 @@
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"clean": "shx rm -rf lib scripts",
|
||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'"
|
||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
@@ -25,8 +26,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/dev-utils/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.15",
|
||||
"@0xproject/tslint-config": "^0.4.13",
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"chai": "^4.0.1",
|
||||
@@ -36,20 +37,15 @@
|
||||
"nyc": "^11.0.1",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.8.0",
|
||||
"types-bn": "^0.0.1",
|
||||
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/sol-cov": "^0.0.5",
|
||||
"@0xproject/subproviders": "^0.8.3",
|
||||
"@0xproject/types": "^0.4.2",
|
||||
"@0xproject/typescript-typings": "^0.0.2",
|
||||
"@0xproject/utils": "^0.4.4",
|
||||
"@0xproject/web3-wrapper": "^0.4.0",
|
||||
"ethereumjs-util": "^5.1.2",
|
||||
"@0xproject/sol-cov": "^0.0.6",
|
||||
"@0xproject/subproviders": "^0.8.4",
|
||||
"@0xproject/types": "^0.5.0",
|
||||
"@0xproject/typescript-typings": "^0.0.3",
|
||||
"@0xproject/web3-wrapper": "^0.5.0",
|
||||
"lodash": "^4.17.4",
|
||||
"request-promise-native": "^1.0.5",
|
||||
"web3": "^0.20.0",
|
||||
"web3-provider-engine": "^13.0.1"
|
||||
},
|
||||
|
3
packages/dev-utils/src/globals.d.ts
vendored
3
packages/dev-utils/src/globals.d.ts
vendored
@@ -1,6 +1,3 @@
|
||||
declare module 'web3-provider-engine';
|
||||
declare module 'web3-provider-engine/subproviders/rpc';
|
||||
|
||||
declare module '*.json' {
|
||||
const json: any;
|
||||
/* tslint:disable */
|
||||
|
@@ -7,6 +7,7 @@ import ProviderEngine = require('web3-provider-engine');
|
||||
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
|
||||
|
||||
import { EmptyWalletSubprovider, FakeGasEstimateSubprovider, GanacheSubprovider } from '@0xproject/subproviders';
|
||||
import { Provider } from '@0xproject/types';
|
||||
import * as fs from 'fs';
|
||||
import * as _ from 'lodash';
|
||||
import * as process from 'process';
|
||||
@@ -34,7 +35,7 @@ export const web3Factory = {
|
||||
web3.setProvider(provider);
|
||||
return web3;
|
||||
},
|
||||
getRpcProvider(config: Web3Config = {}): Web3.Provider {
|
||||
getRpcProvider(config: Web3Config = {}): Provider {
|
||||
const provider = new ProviderEngine();
|
||||
const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage);
|
||||
if (isCoverageEnabled) {
|
||||
|
@@ -3,10 +3,5 @@
|
||||
"compilerOptions": {
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*",
|
||||
"./test/**/*",
|
||||
"../../node_modules/types-bn/index.d.ts",
|
||||
"../../node_modules/types-ethereumjs-util/index.d.ts"
|
||||
]
|
||||
"include": ["./src/**/*", "./test/**/*"]
|
||||
}
|
||||
|
@@ -1,4 +1,22 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1523462196,
|
||||
"version": "0.7.20",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1522673609,
|
||||
"version": "0.7.19",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1522658513,
|
||||
"version": "0.7.18",
|
||||
@@ -16,8 +34,7 @@
|
||||
"pr": 389
|
||||
}
|
||||
],
|
||||
"timestamp": 1518102000,
|
||||
"isPublished": true
|
||||
"timestamp": 1518102000
|
||||
},
|
||||
{
|
||||
"version": "0.7.0",
|
||||
@@ -27,8 +44,7 @@
|
||||
"pr": 272
|
||||
}
|
||||
],
|
||||
"timestamp": 1513695600,
|
||||
"isPublished": true
|
||||
"timestamp": 1513695600
|
||||
},
|
||||
{
|
||||
"version": "0.6.7",
|
||||
@@ -37,7 +53,6 @@
|
||||
"note": "Re-publish JSON-schema previously published under NPM package 0x-json-schemas"
|
||||
}
|
||||
],
|
||||
"timestamp": 1510585200,
|
||||
"isPublished": true
|
||||
"timestamp": 1510585200
|
||||
}
|
||||
]
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user