Compare commits
125 Commits
@0xproject
...
@0xproject
Author | SHA1 | Date | |
---|---|---|---|
|
85f28ade86 | ||
|
f6f2991a44 | ||
|
4ea222bbff | ||
|
f9f5e04b41 | ||
|
ea6706a2af | ||
|
64c5c5eb40 | ||
|
823f2db09f | ||
|
a71e511f82 | ||
|
12d5c35d14 | ||
|
1a161cc02e | ||
|
96f19ba8da | ||
|
a63dfb7995 | ||
|
97ea1e300a | ||
|
d87d93dfac | ||
|
3ffcb03d87 | ||
|
33b08b90a3 | ||
|
cbca2061f7 | ||
|
bf4873e519 | ||
|
8fc1b38ff2 | ||
|
7d957538b4 | ||
|
7a8edb5018 | ||
|
2193d9ae6e | ||
|
79d01fe2d7 | ||
|
0d02037a12 | ||
|
d263f7783f | ||
|
d8ef76fd5e | ||
|
bc3c7a30c4 | ||
|
7b318b3cc2 | ||
|
e5cf41b313 | ||
|
74012ad584 | ||
|
06b4f007f8 | ||
|
a9cf425410 | ||
|
5355da6cad | ||
|
38f7c4a0d2 | ||
|
1fcf3c5dc4 | ||
|
20b0afacf5 | ||
|
6dbe8dbc50 | ||
|
73e23996a6 | ||
|
e40bce253c | ||
|
74c279ea3a | ||
|
6c13b792f9 | ||
|
6be7466c4a | ||
|
1dbdd7ee1f | ||
|
eb89926cee | ||
|
7923ff4ac6 | ||
|
783314c037 | ||
|
15cf64318c | ||
|
442017f93a | ||
|
4dd9f29769 | ||
|
f2f9bd2e7a | ||
|
d95b8ef3e1 | ||
|
ed0c64fdcf | ||
|
9a91e39b3f | ||
|
ce3f25d48f | ||
|
b669508c34 | ||
|
364d8824af | ||
|
749354b1c0 | ||
|
be73084e04 | ||
|
5eb90697c8 | ||
|
faedd2fa0b | ||
|
c47fb8f9a8 | ||
|
27b915789e | ||
|
ddc6dca98c | ||
|
72aa3d3005 | ||
|
e8d4f6d532 | ||
|
3c84ce2050 | ||
|
9db1ce7ceb | ||
|
e472f7899f | ||
|
b053781453 | ||
|
f892b7dbf6 | ||
|
b146acc69e | ||
|
63b941fbaf | ||
|
29dc22e208 | ||
|
41bd0e30d6 | ||
|
40f4dd91e9 | ||
|
5bf43a3560 | ||
|
f0afc0ae45 | ||
|
916b4d3a26 | ||
|
6d1a587c5c | ||
|
bce97c2543 | ||
|
34446cf569 | ||
|
1e13e927d0 | ||
|
3c0fa0b7e6 | ||
|
ad894fbdbb | ||
|
7d9c6eafbf | ||
|
de6f757ec8 | ||
|
3eeb8f4d6d | ||
|
f44ef7ce59 | ||
|
b08c616713 | ||
|
3ad693d334 | ||
|
4aa67e2925 | ||
|
260ab2d413 | ||
|
a824957de7 | ||
|
4017c172a2 | ||
|
65b2c936ab | ||
|
eee190826a | ||
|
20a1deb187 | ||
|
9169913a2c | ||
|
bf0ef055fb | ||
|
4e4842a62f | ||
|
a34c9095c3 | ||
|
84a4b7d1c1 | ||
|
5b69cd4a22 | ||
|
c80b42712a | ||
|
8d76d74a17 | ||
|
6f72fed8b5 | ||
|
27575e9866 | ||
|
986ba175ce | ||
|
919b327fc5 | ||
|
e05b55d4a5 | ||
|
6f24337a53 | ||
|
0e8f5004d6 | ||
|
22fa5a57a5 | ||
|
e30c76b743 | ||
|
75a51af006 | ||
|
24454938e5 | ||
|
89a72ebf0d | ||
|
20aaab0847 | ||
|
3e648cfb7e | ||
|
2106d7476d | ||
|
43e07e7ce3 | ||
|
5e4e27fed5 | ||
|
6c02722f56 | ||
|
5cfebd2680 | ||
|
bd20b1747d |
@@ -124,6 +124,10 @@ jobs:
|
||||
key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/sol-cov/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-metacoin-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/metacoin/coverage/lcov.info
|
||||
lint:
|
||||
working_directory: ~/repo
|
||||
docker:
|
||||
@@ -177,15 +181,18 @@ jobs:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-metacoin-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run: yarn report_coverage
|
||||
workflows:
|
||||
version: 2
|
||||
main:
|
||||
jobs:
|
||||
- build
|
||||
# - test-installation:
|
||||
# requires:
|
||||
# - build
|
||||
- test-installation:
|
||||
requires:
|
||||
- build
|
||||
- test-0xjs:
|
||||
requires:
|
||||
- build
|
||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@@ -74,7 +74,10 @@ packages/react-docs/example/public/bundle*
|
||||
bin/
|
||||
|
||||
# generated contract artifacts
|
||||
packages/contracts/src/artifacts
|
||||
packages/sol-cov/test/fixtures/artifacts
|
||||
packages/metacoin/artifacts
|
||||
packages/0x.js/test/artifacts
|
||||
packages/migrations/src/artifacts
|
||||
|
||||
# generated contract wrappers
|
||||
packages/0x.js/src/contract_wrappers/generated/
|
||||
|
@@ -1,5 +1,7 @@
|
||||
lib
|
||||
.nyc_output
|
||||
/packages/contracts/src/artifacts
|
||||
/packages/metacoin/artifacts
|
||||
/packages/migrations/src/artifacts
|
||||
package.json
|
||||
scripts/postpublish_utils.js
|
||||
|
@@ -36,7 +36,6 @@
|
||||
|
||||
* [ ] Change requires a change to the documentation.
|
||||
* [ ] Added tests to cover my changes.
|
||||
* [ ] Added new entries to the relevant CHANGELOGs.
|
||||
* [ ] Updated the new versions of the changed packages in the relevant CHANGELOGs.
|
||||
* [ ] Added new entries to the relevant CHANGELOG.jsons.
|
||||
* [ ] Labeled this PR with the 'WIP' label if it is a work in progress.
|
||||
* [ ] Labeled this PR with the labels corresponding to the changed package.
|
||||
|
25
README.md
25
README.md
@@ -14,7 +14,6 @@ This repository is a monorepo including the 0x protocol smart contracts and nume
|
||||
[](https://chat.0xproject.com)
|
||||
[](https://gitter.im/0xProject/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
[](https://greenkeeper.io/)
|
||||
|
||||
### Published Packages
|
||||
|
||||
@@ -32,7 +31,7 @@ This repository is a monorepo including the 0x protocol smart contracts and nume
|
||||
| [`@0xproject/react-docs`](/packages/react-docs) | [](https://www.npmjs.com/package/@0xproject/react-docs) | React documentation component for rendering TypeDoc & Doxity generated JSON |
|
||||
| [`@0xproject/react-shared`](/packages/react-shared) | [](https://www.npmjs.com/package/@0xproject/react-shared) | 0x shared react components |
|
||||
| [`@0xproject/sra-report`](/packages/sra-report) | [](https://www.npmjs.com/package/@0xproject/sra-report) | Generate reports for standard relayer API compliance |
|
||||
| [`@0xproject/sol-cov`](/packages/sol-cov) | [](https://www.npmjs.com/package/@0xproject/sol-cov) | Solidity test coverage tool tool |
|
||||
| [`@0xproject/sol-cov`](/packages/sol-cov) | [](https://www.npmjs.com/package/@0xproject/sol-cov) | Solidity test coverage tool |
|
||||
| [`@0xproject/subproviders`](/packages/subproviders) | [](https://www.npmjs.com/package/@0xproject/subproviders) | Useful web3 subproviders (e.g LedgerSubprovider) |
|
||||
| [`@0xproject/tslint-config`](/packages/tslint-config) | [](https://www.npmjs.com/package/@0xproject/tslint-config) | Custom 0x development TSLint rules |
|
||||
| [`@0xproject/types`](/packages/types) | [](https://www.npmjs.com/package/@0xproject/types) | Shared type declarations |
|
||||
@@ -74,7 +73,7 @@ You can include those by prepending @0xproject/typescript-typings package to you
|
||||
|
||||
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
|
||||
|
||||
Please read our [contribution guidelines](./CONTRIBUTING.md) before getting started.
|
||||
#### Read our [contribution guidelines](./CONTRIBUTING.md).
|
||||
|
||||
### Install dependencies
|
||||
|
||||
@@ -118,24 +117,6 @@ yarn lerna:run lint
|
||||
|
||||
### Run Tests
|
||||
|
||||
Before running the tests, you will need to spin up a [TestRPC](https://www.npmjs.com/package/ethereumjs-testrpc) instance and deploy all the 0x smart contracts.
|
||||
|
||||
In a separate terminal, start TestRPC (a convenience command is provided as part of this repo)
|
||||
|
||||
```bash
|
||||
yarn testrpc
|
||||
```
|
||||
|
||||
Then in your main terminal run
|
||||
|
||||
```
|
||||
cd packages/contracts
|
||||
yarn migrate
|
||||
cd ..
|
||||
```
|
||||
|
||||
And finally from the root project directory run
|
||||
|
||||
```bash
|
||||
yarn lerna:run test
|
||||
yarn lerna:test
|
||||
```
|
||||
|
@@ -13,6 +13,7 @@
|
||||
"test:installation": "node ./packages/monorepo-scripts/lib/test_installation.js",
|
||||
"lerna:install": "yarn install",
|
||||
"lerna:run": "lerna run",
|
||||
"lerna:test": "lerna run test",
|
||||
"lerna:clean": "lerna run clean",
|
||||
"lerna:build": "lerna run build",
|
||||
"lerna:rebuild": "run-s lerna:clean lerna:build",
|
||||
|
@@ -1,10 +1,28 @@
|
||||
[
|
||||
{
|
||||
"version": "0.36.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Internal changes and refactoring"
|
||||
},
|
||||
{
|
||||
"note": "Fix redundant expired order removal bug",
|
||||
"pr": 527
|
||||
}
|
||||
],
|
||||
"timestamp": 1524044013
|
||||
},
|
||||
{
|
||||
"version": "0.36.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Moved Web3.Provider to `@0xproject/types:Provider`",
|
||||
"pr": 501
|
||||
},
|
||||
{
|
||||
"note":
|
||||
"Add `zeroEx.exchange.getOrderStateAsync` to allow obtaining current OrderState for a signedOrder",
|
||||
"pr": 510
|
||||
}
|
||||
],
|
||||
"timestamp": 1523462196
|
||||
@@ -14,7 +32,7 @@
|
||||
"changes": [
|
||||
{
|
||||
"note":
|
||||
"Removed `ZeroExError.TransactionMiningTimeout` and moved it to '@0xproject/web3_wrapper' `Web3WrapperErrors.TransactionMiningTimeout`",
|
||||
"Removed `ZeroExError.TransactionMiningTimeout` and moved it to '@0xproject/web3-wrapper' `Web3WrapperErrors.TransactionMiningTimeout`",
|
||||
"pr": 485
|
||||
}
|
||||
],
|
||||
|
@@ -5,13 +5,19 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.36.0 - _April 11, 2018_
|
||||
## v0.36.1 - _April 18, 2018_
|
||||
|
||||
* Internal changes and refactoring
|
||||
* Fix redundant expired order removal bug (#527)
|
||||
|
||||
## v0.36.0 - _April 12, 2018_
|
||||
|
||||
* Moved Web3.Provider to `@0xproject/types:Provider` (#501)
|
||||
* Add `zeroEx.exchange.getOrderStateAsync` to allow obtaining current OrderState for a signedOrder (#510)
|
||||
|
||||
## v0.35.0 - _April 2, 2018_
|
||||
|
||||
* Removed `ZeroExError.TransactionMiningTimeout` and moved it to '@0xproject/web3_wrapper' `Web3WrapperErrors.TransactionMiningTimeout` (#485)
|
||||
* Removed `ZeroExError.TransactionMiningTimeout` and moved it to '@0xproject/web3-wrapper' `Web3WrapperErrors.TransactionMiningTimeout` (#485)
|
||||
|
||||
## v0.34.0 - _April 2, 2018_
|
||||
|
||||
@@ -20,16 +26,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 17, 2018_
|
||||
## v0.33.2 - _March 18, 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 7, 2018_
|
||||
## v0.33.1 - _March 8, 2018_
|
||||
|
||||
* Add missing EthersJs typescript typings as dependency
|
||||
|
||||
## v0.33.0 - _March 3, 2018_
|
||||
## v0.33.0 - _March 4, 2018_
|
||||
|
||||
* Validate and lowercase all addresses in public methods (#373)
|
||||
* Improve validation to force passing contract addresses on private networks (#385)
|
||||
@@ -37,54 +43,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 8, 2018_
|
||||
## v0.32.2 - _February 9, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.32.1 - _February 6, 2018_
|
||||
## v0.32.1 - _February 7, 2018_
|
||||
|
||||
* Reorganized `BlockParamLiteral` export into `@0xproject/types` package (#355)
|
||||
* Now using `abi-gen` package to generate ContractEventArgs types (#371)
|
||||
|
||||
## v0.32.0 - _February 4, 2018_
|
||||
## v0.32.0 - _February 5, 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 - _January 31, 2018_
|
||||
## v0.31.1 - _February 1, 2018_
|
||||
|
||||
* Fix the bug causing order watcher to throw if makerToken === zrx (#357)
|
||||
|
||||
## v0.31.0 - _January 29, 2018_
|
||||
## v0.31.0 - _January 30, 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 28, 2018_
|
||||
## v0.30.2 - _January 29, 2018_
|
||||
|
||||
* Add Rinkeby testnet addresses to artifacts (#337)
|
||||
* Move @0xproject/types to dependencies from devDependencies fixing missing type errors
|
||||
|
||||
## v0.30.1 - _January 23, 2018_
|
||||
## v0.30.1 - _January 24, 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 16, 2018_
|
||||
## v0.30.0 - _January 17, 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 10, 2018_
|
||||
## v0.29.1 - _January 11, 2018_
|
||||
|
||||
* Fixed bignumber config issue #301 (#305)
|
||||
|
||||
## v0.29.0 - _December 27, 2017_
|
||||
## v0.29.0 - _December 28, 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 19, 2017_
|
||||
## v0.28.0 - _December 20, 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)
|
||||
@@ -96,11 +102,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 27, 2017_
|
||||
## v0.27.1 - _November 28, 2017_
|
||||
|
||||
* Export `TransactionOpts` type
|
||||
|
||||
## v0.27.0 - _November 27, 2017_
|
||||
## v0.27.0 - _November 28, 2017_
|
||||
|
||||
* Make `ZeroExConfig` required parameter of `ZeroEx` constructor (#233)
|
||||
* Add a required property `networkId` to `ZeroExConfig` (#233)
|
||||
@@ -112,65 +118,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 20, 2017_
|
||||
## v0.26.0 - _November 21, 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 12, 2017_
|
||||
## v0.25.1 - _November 13, 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 11, 2017_
|
||||
## v0.23.0 - _November 12, 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 9, 2017_
|
||||
## v0.22.6 - _November 10, 2017_
|
||||
|
||||
* Add a timeout parameter to transaction awaiting (#206)
|
||||
|
||||
## v0.22.5 - _November 6, 2017_
|
||||
## v0.22.5 - _November 7, 2017_
|
||||
|
||||
* Re-publish v0.22.4 to fix publishing issue
|
||||
|
||||
## v0.22.4 - _October 24, 2017_
|
||||
## v0.22.4 - _October 25, 2017_
|
||||
|
||||
* Upgraded bignumber.js to a new version that ships with native typings
|
||||
|
||||
## v0.22.3 - _October 24, 2017_
|
||||
## v0.22.3 - _October 25, 2017_
|
||||
|
||||
* Fixed an issue with new version of testrpc and unlimited proxy allowance (#199)
|
||||
|
||||
## v0.22.2 - _October 23, 2017_
|
||||
## v0.22.2 - _October 24, 2017_
|
||||
|
||||
* Fixed rounding of maker fill amount and incorrect validation of partial fees (#197)
|
||||
|
||||
## v0.22.0 - _October 15, 2017_
|
||||
## v0.22.0 - _October 16, 2017_
|
||||
|
||||
* Started using `OrderFillRequest` interface instead of `OrderFillOrKillRequest` interface for `zeroEx.exchange.batchFillOrKill` (#187)
|
||||
* Removed `OrderFillOrKillRequest` (#187)
|
||||
|
||||
## v0.21.4 - _October 12, 2017_
|
||||
## v0.21.4 - _October 13, 2017_
|
||||
|
||||
* Made 0x.js more type-safe by making `getLogsAsync` and `subscribe/subscribeAsync` generics parametrized with arg type (#194)
|
||||
|
||||
## v0.21.3 - _October 11, 2017_
|
||||
## v0.21.3 - _October 12, 2017_
|
||||
|
||||
* Fixed a bug causing order fills to throw `INSUFFICIENT_TAKER_ALLOWANCE` (#193)
|
||||
|
||||
## v0.21.2 - _October 10, 2017_
|
||||
## v0.21.2 - _October 11, 2017_
|
||||
|
||||
* Exported `ContractEventArg` as a public type (#190)
|
||||
|
||||
## v0.21.1 - _October 10, 2017_
|
||||
## v0.21.1 - _October 11, 2017_
|
||||
|
||||
* Fixed a bug in subscriptions (#189)
|
||||
|
||||
## v0.21.0 - _October 9, 2017_
|
||||
## v0.21.0 - _October 10, 2017_
|
||||
|
||||
* Complete rewrite of subscription logic (#182)
|
||||
* Subscriptions no longer return historical logs. If you want them - use `getLogsAsync`
|
||||
@@ -185,27 +191,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 4, 2017_
|
||||
## v0.20.0 - _October 5, 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 28, 2017_
|
||||
## v0.19.0 - _September 29, 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 25, 2017_
|
||||
## v0.18.0 - _September 26, 2017_
|
||||
|
||||
* Added `zeroEx.exchange.validateOrderFillableOrThrowAsync` to simplify orderbook pruning (#170)
|
||||
|
||||
## v0.17.0 - _September 25, 2017_
|
||||
## v0.17.0 - _September 26, 2017_
|
||||
|
||||
* Made `zeroEx.exchange.getZRXTokenAddressAsync` public (#171)
|
||||
|
||||
## v0.16.0 - _September 19, 2017_
|
||||
## v0.16.0 - _September 20, 2017_
|
||||
|
||||
* Added the ability to specify custom contract addresses to be used with 0x.js (#165)
|
||||
* ZeroExConfig.exchangeContractAddress
|
||||
@@ -213,48 +219,48 @@ CHANGELOG
|
||||
* ZeroExConfig.etherTokenContractAddress
|
||||
* Added `zeroEx.tokenRegistry.getContractAddressAsync` (#165)
|
||||
|
||||
## v0.15.0 - _September 7, 2017_
|
||||
## v0.15.0 - _September 8, 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 6, 2017_
|
||||
## v0.14.2 - _September 7, 2017_
|
||||
|
||||
* Fixed an issue with bignumber.js types not found (#160)
|
||||
|
||||
## v0.14.1 - _September 6, 2017_
|
||||
## v0.14.1 - _September 7, 2017_
|
||||
|
||||
* Fixed an issue with Artifact type not found (#159)
|
||||
|
||||
## v0.14.0 - _September 5, 2017_
|
||||
## v0.14.0 - _September 6, 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 5, 2017_
|
||||
## v0.13.0 - _September 6, 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 1, 2017_
|
||||
## v0.12.1 - _September 2, 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 23, 2017_
|
||||
## v0.11.0 - _August 24, 2017_
|
||||
|
||||
* Added `zeroEx.token.setUnlimitedProxyAllowanceAsync` (#137)
|
||||
* Added `zeroEx.token.setUnlimitedAllowanceAsync` (#137)
|
||||
* Added `zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS` (#137)
|
||||
|
||||
## v0.10.4 - _August 23, 2017_
|
||||
## v0.10.4 - _August 24, 2017_
|
||||
|
||||
* Fixed a bug where checksummed addresses were being pulled from artifacts and not lower-cased. (#135)
|
||||
|
||||
## v0.10.1 - _August 23, 2017_
|
||||
## v0.10.1 - _August 24, 2017_
|
||||
|
||||
* Added `zeroEx.exchange.validateFillOrderThrowIfInvalidAsync` (#128)
|
||||
* Added `zeroEx.exchange.validateFillOrKillOrderThrowIfInvalidAsync` (#128)
|
||||
@@ -269,20 +275,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 21, 2017_
|
||||
## v0.9.3 - _August 22, 2017_
|
||||
|
||||
* Update contract artifacts to include latest Kovan and Mainnet deploys (#118)
|
||||
|
||||
## v0.9.2 - _August 20, 2017_
|
||||
## v0.9.2 - _August 21, 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 15, 2017_
|
||||
## v0.9.1 - _August 16, 2017_
|
||||
|
||||
* Fixed the bug causing `zeroEx.token.getBalanceAsync()` to fail if no addresses available (#120)
|
||||
|
||||
## v0.9.0 - _July 25, 2017_
|
||||
## v0.9.0 - _July 26, 2017_
|
||||
|
||||
* Migrated to the new version of smart contracts (#101)
|
||||
* Removed the ability to call methods on multiple authorized Exchange smart contracts (#106)
|
||||
@@ -293,7 +299,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 3, 2017_
|
||||
## v0.8.0 - _July 4, 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)
|
||||
@@ -306,35 +312,35 @@ CHANGELOG
|
||||
* `zeroEx.tokenRegistry.invalidateContractInstance`
|
||||
* Fixed the bug where `zeroEx.setProviderAsync` didn't invalidate etherToken contract's instance
|
||||
|
||||
## v0.7.1 - _June 25, 2017_
|
||||
## v0.7.1 - _June 26, 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 21, 2017_
|
||||
## v0.7.0 - _June 22, 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 20, 2017_
|
||||
## v0.6.2 - _June 21, 2017_
|
||||
|
||||
* Reduced bundle size
|
||||
* Improved documentation
|
||||
|
||||
## v0.6.1 - _June 18, 2017_
|
||||
## v0.6.1 - _June 19, 2017_
|
||||
|
||||
* Improved documentation
|
||||
|
||||
## v0.6.0 - _June 18, 2017_
|
||||
## v0.6.0 - _June 19, 2017_
|
||||
|
||||
* Made `ZeroEx` class accept `Web3Provider` instance instead of `Web3` instance
|
||||
* Added types for contract event arguments
|
||||
|
||||
## v0.5.2 - _June 14, 2017_
|
||||
## v0.5.2 - _June 15, 2017_
|
||||
|
||||
* Fixed the bug in `postpublish` script that caused that only unminified UMD bundle was uploaded to release page
|
||||
|
||||
## v0.5.1 - _June 14, 2017_
|
||||
## v0.5.1 - _June 15, 2017_
|
||||
|
||||
* Added `postpublish` script to publish to Github Releases with assets.
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
A TypeScript/Javascript library for interacting with the 0x protocol.
|
||||
|
||||
### Read the [Documentation](https://0xproject.com/docs/0xjs).
|
||||
### Read the [Documentation](https://0xproject.com/docs/0x.js).
|
||||
|
||||
## Installation
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "0x.js",
|
||||
"version": "0.35.0",
|
||||
"version": "0.36.0",
|
||||
"description": "A javascript library for interacting with the 0x protocol",
|
||||
"keywords": [
|
||||
"0x.js",
|
||||
@@ -15,16 +15,16 @@
|
||||
"build:watch": "tsc -w",
|
||||
"prebuild": "run-s clean generate_contract_wrappers",
|
||||
"build": "run-p build:umd:prod build:commonjs; exit 0;",
|
||||
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
|
||||
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/compact_artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
|
||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
||||
"test:circleci": "run-s test:coverage",
|
||||
"test": "run-s clean test:commonjs",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"update_contracts": "for i in ${npm_package_config_artifacts}; do copyfiles -u 4 ../contracts/build/contracts/$i.json ../0x.js/src/artifacts; done;",
|
||||
"update_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/src/artifacts/$i.json test/artifacts; done;",
|
||||
"clean": "shx rm -rf _bundles lib test_temp scripts",
|
||||
"build:umd:prod": "NODE_ENV=production webpack",
|
||||
"build:commonjs": "tsc && copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"build:commonjs": "tsc && yarn update_artifacts && copyfiles -u 2 './src/compact_artifacts/**/*.json' ./lib/src/compact_artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"test:commonjs": "run-s build:commonjs run_mocha",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js --timeout 10000 --bail --exit",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
|
||||
@@ -33,7 +33,8 @@
|
||||
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
|
||||
},
|
||||
"config": {
|
||||
"artifacts": "TokenTransferProxy Exchange TokenRegistry Token EtherToken",
|
||||
"compact_artifacts": "Exchange DummyToken ZRXToken Token EtherToken TokenTransferProxy TokenRegistry",
|
||||
"contracts": "Exchange DummyToken ZRXToken Token WETH9 TokenTransferProxy MultiSigWallet MultiSigWalletWithTimeLock MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress MaliciousToken TokenRegistry Arbitrage EtherDelta AccountLevels",
|
||||
"postpublish": {
|
||||
"assets": [
|
||||
"packages/0x.js/_bundles/index.js",
|
||||
@@ -60,9 +61,11 @@
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/dev-utils": "^0.3.4",
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@0xproject/deployer": "^0.4.0",
|
||||
"@0xproject/dev-utils": "^0.3.5",
|
||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
||||
"@0xproject/subproviders": "^0.8.4",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@types/bintrees": "^1.0.2",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
@@ -86,20 +89,20 @@
|
||||
"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",
|
||||
"typescript": "2.7.1",
|
||||
"web3-provider-engine": "^13.0.1",
|
||||
"webpack": "^3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@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",
|
||||
"@0xproject/assert": "^0.2.6",
|
||||
"@0xproject/base-contract": "^0.2.0",
|
||||
"@0xproject/json-schemas": "^0.7.20",
|
||||
"@0xproject/types": "^0.6.0",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/utils": "^0.5.1",
|
||||
"@0xproject/web3-wrapper": "^0.6.0",
|
||||
"bintrees": "^1.0.2",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereumjs-abi": "^0.6.4",
|
||||
@@ -111,6 +114,9 @@
|
||||
"uuid": "^3.1.0",
|
||||
"web3": "^0.20.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@0xproject/migrations": "^0.0.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
|
@@ -0,0 +1,6 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
export abstract class BalanceAndProxyAllowanceFetcher {
|
||||
public abstract async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber>;
|
||||
public abstract async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber>;
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
export abstract class OrderFilledCancelledFetcher {
|
||||
public abstract async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber>;
|
||||
public abstract async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber>;
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
import * as DummyTokenArtifact from './artifacts/DummyToken.json';
|
||||
import * as EtherTokenArtifact from './artifacts/EtherToken.json';
|
||||
import * as ExchangeArtifact from './artifacts/Exchange.json';
|
||||
import * as TokenArtifact from './artifacts/Token.json';
|
||||
import * as TokenRegistryArtifact from './artifacts/TokenRegistry.json';
|
||||
import * as TokenTransferProxyArtifact from './artifacts/TokenTransferProxy.json';
|
||||
import * as ZRXArtifact from './artifacts/ZRX.json';
|
||||
import * as DummyTokenArtifact from './compact_artifacts/DummyToken.json';
|
||||
import * as EtherTokenArtifact from './compact_artifacts/EtherToken.json';
|
||||
import * as ExchangeArtifact from './compact_artifacts/Exchange.json';
|
||||
import * as TokenArtifact from './compact_artifacts/Token.json';
|
||||
import * as TokenRegistryArtifact from './compact_artifacts/TokenRegistry.json';
|
||||
import * as TokenTransferProxyArtifact from './compact_artifacts/TokenTransferProxy.json';
|
||||
import * as ZRXArtifact from './compact_artifacts/ZRX.json';
|
||||
import { Artifact } from './types';
|
||||
|
||||
export const artifacts = {
|
||||
|
@@ -13,6 +13,8 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import { SimpleBalanceAndProxyAllowanceFetcher } from '../fetchers/simple_balance_and_proxy_allowance_fetcher';
|
||||
import { SimpleOrderFilledCancelledFetcher } from '../fetchers/simple_order_filled_cancelled_fetcher';
|
||||
import {
|
||||
BlockRange,
|
||||
EventCallback,
|
||||
@@ -23,6 +25,7 @@ import {
|
||||
OrderAddresses,
|
||||
OrderCancellationRequest,
|
||||
OrderFillRequest,
|
||||
OrderState,
|
||||
OrderTransactionOpts,
|
||||
OrderValues,
|
||||
ValidateOrderFillableOpts,
|
||||
@@ -30,6 +33,7 @@ import {
|
||||
import { assert } from '../utils/assert';
|
||||
import { decorators } from '../utils/decorators';
|
||||
import { ExchangeTransferSimulator } from '../utils/exchange_transfer_simulator';
|
||||
import { OrderStateUtils } from '../utils/order_state_utils';
|
||||
import { OrderValidationUtils } from '../utils/order_validation_utils';
|
||||
import { utils } from '../utils/utils';
|
||||
|
||||
@@ -41,7 +45,6 @@ import {
|
||||
LogErrorContractEventArgs,
|
||||
} from './generated/exchange';
|
||||
import { TokenWrapper } from './token_wrapper';
|
||||
|
||||
const SHOULD_VALIDATE_BY_DEFAULT = true;
|
||||
|
||||
interface ExchangeContractErrCodesToMsgs {
|
||||
@@ -873,6 +876,28 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
throw new Error(errMessage);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the latest OrderState of a signedOrder
|
||||
* @param signedOrder The signedOrder
|
||||
* @param stateLayer Optional, desired blockchain state layer (defaults to latest).
|
||||
* @return OrderState of the signedOrder
|
||||
*/
|
||||
public async getOrderStateAsync(
|
||||
signedOrder: SignedOrder,
|
||||
stateLayer: BlockParamLiteral = BlockParamLiteral.Latest,
|
||||
): Promise<OrderState> {
|
||||
const simpleBalanceAndProxyAllowanceFetcher = new SimpleBalanceAndProxyAllowanceFetcher(
|
||||
this._tokenWrapper,
|
||||
stateLayer,
|
||||
);
|
||||
const simpleOrderFilledCancelledFetcher = new SimpleOrderFilledCancelledFetcher(this, stateLayer);
|
||||
const orderStateUtils = new OrderStateUtils(
|
||||
simpleBalanceAndProxyAllowanceFetcher,
|
||||
simpleOrderFilledCancelledFetcher,
|
||||
);
|
||||
const orderState = orderStateUtils.getOrderStateAsync(signedOrder);
|
||||
return orderState;
|
||||
}
|
||||
/**
|
||||
* Returns the ZRX token address used by the exchange contract.
|
||||
* @return Address of ZRX token
|
||||
|
@@ -0,0 +1,28 @@
|
||||
import { BlockParamLiteral } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
import { BalanceAndProxyAllowanceFetcher } from '../abstract/balance_and_proxy_allowance_fetcher';
|
||||
import { TokenWrapper } from '../contract_wrappers/token_wrapper';
|
||||
|
||||
export class SimpleBalanceAndProxyAllowanceFetcher implements BalanceAndProxyAllowanceFetcher {
|
||||
private _tokenWrapper: TokenWrapper;
|
||||
private _defaultBlock: BlockParamLiteral;
|
||||
constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) {
|
||||
this._tokenWrapper = token;
|
||||
this._defaultBlock = defaultBlock;
|
||||
}
|
||||
public async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const balance = this._tokenWrapper.getBalanceAsync(tokenAddress, userAddress, methodOpts);
|
||||
return balance;
|
||||
}
|
||||
public async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const proxyAllowance = this._tokenWrapper.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts);
|
||||
return proxyAllowance;
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
import { BlockParamLiteral } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
import { OrderFilledCancelledFetcher } from '../abstract/order_filled_cancelled_fetcher';
|
||||
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
|
||||
|
||||
export class SimpleOrderFilledCancelledFetcher implements OrderFilledCancelledFetcher {
|
||||
private _exchangeWrapper: ExchangeWrapper;
|
||||
private _defaultBlock: BlockParamLiteral;
|
||||
constructor(exchange: ExchangeWrapper, defaultBlock: BlockParamLiteral) {
|
||||
this._exchangeWrapper = exchange;
|
||||
this._defaultBlock = defaultBlock;
|
||||
}
|
||||
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const filledTakerAmount = this._exchangeWrapper.getFilledTakerAmountAsync(orderHash, methodOpts);
|
||||
return filledTakerAmount;
|
||||
}
|
||||
public async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const cancelledTakerAmount = this._exchangeWrapper.getCancelledTakerAmountAsync(orderHash, methodOpts);
|
||||
return cancelledTakerAmount;
|
||||
}
|
||||
}
|
@@ -13,7 +13,7 @@ enum LogEventState {
|
||||
Added,
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* The EventWatcher watches for blockchain events at the specified block confirmation
|
||||
* depth.
|
||||
*/
|
||||
|
@@ -48,6 +48,9 @@ export class ExpirationWatcher {
|
||||
this._orderHashByExpirationRBTree.insert(orderHash);
|
||||
}
|
||||
public removeOrder(orderHash: string): void {
|
||||
if (_.isUndefined(this._expiration[orderHash])) {
|
||||
return; // noop since order already removed
|
||||
}
|
||||
this._orderHashByExpirationRBTree.remove(orderHash);
|
||||
delete this._expiration[orderHash];
|
||||
}
|
||||
|
@@ -87,7 +87,7 @@ export class OrderStateWatcher {
|
||||
_.isUndefined(config) || _.isUndefined(config.stateLayer) ? BlockParamLiteral.Latest : config.stateLayer;
|
||||
this._eventWatcher = new EventWatcher(web3Wrapper, pollingIntervalIfExistsMs, stateLayer);
|
||||
this._balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore(token, stateLayer);
|
||||
this._orderFilledCancelledLazyStore = new OrderFilledCancelledLazyStore(exchange);
|
||||
this._orderFilledCancelledLazyStore = new OrderFilledCancelledLazyStore(exchange, stateLayer);
|
||||
this._orderStateUtils = new OrderStateUtils(
|
||||
this._balanceAndProxyAllowanceLazyStore,
|
||||
this._orderFilledCancelledLazyStore,
|
||||
@@ -131,7 +131,7 @@ export class OrderStateWatcher {
|
||||
}
|
||||
delete this._orderByOrderHash[orderHash];
|
||||
delete this._orderStateByOrderHashCache[orderHash];
|
||||
const exchange = (this._orderFilledCancelledLazyStore as any)._exchange as ExchangeWrapper;
|
||||
const exchange = (this._orderFilledCancelledLazyStore as any)._exchangeWrapper as ExchangeWrapper;
|
||||
const zrxTokenAddress = exchange.getZRXTokenAddress();
|
||||
|
||||
this._removeFromDependentOrderHashes(signedOrder.maker, zrxTokenAddress, orderHash);
|
||||
@@ -374,7 +374,7 @@ export class OrderStateWatcher {
|
||||
}
|
||||
}
|
||||
private _getZRXTokenAddress(): string {
|
||||
const exchange = (this._orderFilledCancelledLazyStore as any)._exchange as ExchangeWrapper;
|
||||
const exchange = (this._orderFilledCancelledLazyStore as any)._exchangeWrapper as ExchangeWrapper;
|
||||
const zrxTokenAddress = exchange.getZRXTokenAddress();
|
||||
return zrxTokenAddress;
|
||||
}
|
||||
|
@@ -2,13 +2,14 @@ import { BlockParamLiteral } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { BalanceAndProxyAllowanceFetcher } from '../abstract/balance_and_proxy_allowance_fetcher';
|
||||
import { TokenWrapper } from '../contract_wrappers/token_wrapper';
|
||||
|
||||
/**
|
||||
* Copy on read store for balances/proxyAllowances of tokens/accounts
|
||||
*/
|
||||
export class BalanceAndProxyAllowanceLazyStore {
|
||||
private _token: TokenWrapper;
|
||||
export class BalanceAndProxyAllowanceLazyStore implements BalanceAndProxyAllowanceFetcher {
|
||||
private _tokenWrapper: TokenWrapper;
|
||||
private _defaultBlock: BlockParamLiteral;
|
||||
private _balance: {
|
||||
[tokenAddress: string]: {
|
||||
@@ -21,7 +22,7 @@ export class BalanceAndProxyAllowanceLazyStore {
|
||||
};
|
||||
};
|
||||
constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) {
|
||||
this._token = token;
|
||||
this._tokenWrapper = token;
|
||||
this._defaultBlock = defaultBlock;
|
||||
this._balance = {};
|
||||
this._proxyAllowance = {};
|
||||
@@ -31,7 +32,7 @@ export class BalanceAndProxyAllowanceLazyStore {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const balance = await this._token.getBalanceAsync(tokenAddress, userAddress, methodOpts);
|
||||
const balance = await this._tokenWrapper.getBalanceAsync(tokenAddress, userAddress, methodOpts);
|
||||
this.setBalance(tokenAddress, userAddress, balance);
|
||||
}
|
||||
const cachedBalance = this._balance[tokenAddress][userAddress];
|
||||
@@ -59,7 +60,11 @@ export class BalanceAndProxyAllowanceLazyStore {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const proxyAllowance = await this._token.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts);
|
||||
const proxyAllowance = await this._tokenWrapper.getProxyAllowanceAsync(
|
||||
tokenAddress,
|
||||
userAddress,
|
||||
methodOpts,
|
||||
);
|
||||
this.setProxyAllowance(tokenAddress, userAddress, proxyAllowance);
|
||||
}
|
||||
const cachedProxyAllowance = this._proxyAllowance[tokenAddress][userAddress];
|
||||
|
@@ -2,30 +2,33 @@ import { BlockParamLiteral } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { OrderFilledCancelledFetcher } from '../abstract/order_filled_cancelled_fetcher';
|
||||
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
|
||||
|
||||
/**
|
||||
* Copy on read store for filled/cancelled taker amounts
|
||||
*/
|
||||
export class OrderFilledCancelledLazyStore {
|
||||
private _exchange: ExchangeWrapper;
|
||||
export class OrderFilledCancelledLazyStore implements OrderFilledCancelledFetcher {
|
||||
private _exchangeWrapper: ExchangeWrapper;
|
||||
private _defaultBlock: BlockParamLiteral;
|
||||
private _filledTakerAmount: {
|
||||
[orderHash: string]: BigNumber;
|
||||
};
|
||||
private _cancelledTakerAmount: {
|
||||
[orderHash: string]: BigNumber;
|
||||
};
|
||||
constructor(exchange: ExchangeWrapper) {
|
||||
this._exchange = exchange;
|
||||
constructor(exchange: ExchangeWrapper, defaultBlock: BlockParamLiteral) {
|
||||
this._exchangeWrapper = exchange;
|
||||
this._defaultBlock = defaultBlock;
|
||||
this._filledTakerAmount = {};
|
||||
this._cancelledTakerAmount = {};
|
||||
}
|
||||
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||
if (_.isUndefined(this._filledTakerAmount[orderHash])) {
|
||||
const methodOpts = {
|
||||
defaultBlock: BlockParamLiteral.Pending,
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const filledTakerAmount = await this._exchange.getFilledTakerAmountAsync(orderHash, methodOpts);
|
||||
const filledTakerAmount = await this._exchangeWrapper.getFilledTakerAmountAsync(orderHash, methodOpts);
|
||||
this.setFilledTakerAmount(orderHash, filledTakerAmount);
|
||||
}
|
||||
const cachedFilled = this._filledTakerAmount[orderHash];
|
||||
@@ -40,9 +43,12 @@ export class OrderFilledCancelledLazyStore {
|
||||
public async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||
if (_.isUndefined(this._cancelledTakerAmount[orderHash])) {
|
||||
const methodOpts = {
|
||||
defaultBlock: BlockParamLiteral.Pending,
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const cancelledTakerAmount = await this._exchange.getCancelledTakerAmountAsync(orderHash, methodOpts);
|
||||
const cancelledTakerAmount = await this._exchangeWrapper.getCancelledTakerAmountAsync(
|
||||
orderHash,
|
||||
methodOpts,
|
||||
);
|
||||
this.setCancelledTakerAmount(orderHash, cancelledTakerAmount);
|
||||
}
|
||||
const cachedCancelled = this._cancelledTakerAmount[orderHash];
|
||||
|
@@ -154,13 +154,13 @@ export interface OrderFillRequest {
|
||||
export type AsyncMethod = (...args: any[]) => Promise<any>;
|
||||
export type SyncMethod = (...args: any[]) => any;
|
||||
|
||||
/*
|
||||
* orderExpirationCheckingIntervalMs: How often to check for expired orders. Default: 50
|
||||
* eventPollingIntervalMs: How often to poll the Ethereum node for new events. Default: 200
|
||||
/**
|
||||
* orderExpirationCheckingIntervalMs: How often to check for expired orders. Default=50.
|
||||
* eventPollingIntervalMs: How often to poll the Ethereum node for new events. Default=200.
|
||||
* expirationMarginMs: Amount of time before order expiry that you'd like to be notified
|
||||
* of an orders expiration. Default: 0
|
||||
* cleanupJobIntervalMs: How often to run a cleanup job which revalidates all the orders. Defaults: 1h
|
||||
* stateLayer: Optional blockchain state layer OrderWatcher will monitor for new events. Default: latest
|
||||
* of an orders expiration. Default=0.
|
||||
* cleanupJobIntervalMs: How often to run a cleanup job which revalidates all the orders. Default=1hr.
|
||||
* stateLayer: Optional blockchain state layer OrderWatcher will monitor for new events. Default=latest.
|
||||
*/
|
||||
export interface OrderStateWatcherConfig {
|
||||
orderExpirationCheckingIntervalMs?: number;
|
||||
@@ -170,7 +170,7 @@ export interface OrderStateWatcherConfig {
|
||||
stateLayer: BlockParamLiteral;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* networkId: The id of the underlying ethereum network your provider is connected to. (1-mainnet, 3-ropsten, 4-rinkeby, 42-kovan, 50-testrpc)
|
||||
* gasPrice: Gas price to use with every transaction
|
||||
* exchangeContractAddress: The address of an exchange contract to use
|
||||
@@ -201,7 +201,7 @@ export interface Artifact {
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* expectedFillTakerTokenAmount: If specified, the validation method will ensure that the
|
||||
* supplied order maker has a sufficient allowance/balance to fill this amount of the order's
|
||||
* takerTokenAmount. If not specified, the validation method ensures that the maker has a sufficient
|
||||
@@ -211,7 +211,7 @@ export interface ValidateOrderFillableOpts {
|
||||
expectedFillTakerTokenAmount?: BigNumber;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* defaultBlock: The block up to which to query the blockchain state. Setting this to a historical block number
|
||||
* let's the user query the blockchain's state at an arbitrary point in time. In order for this to work, the
|
||||
* backing Ethereum node must keep the entire historical state of the chain (e.g setting `--pruning=archive`
|
||||
@@ -221,7 +221,7 @@ export interface MethodOpts {
|
||||
defaultBlock?: BlockParam;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* gasPrice: Gas price in Wei to use for a transaction
|
||||
* gasLimit: The amount of gas to send with a transaction
|
||||
*/
|
||||
@@ -230,9 +230,9 @@ export interface TransactionOpts {
|
||||
gasLimit?: number;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before
|
||||
* broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default: true
|
||||
* broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true.
|
||||
*/
|
||||
export interface OrderTransactionOpts extends TransactionOpts {
|
||||
shouldValidate?: boolean;
|
||||
|
@@ -3,17 +3,17 @@ import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { ZeroEx } from '../0x';
|
||||
import { BalanceAndProxyAllowanceFetcher } from '../abstract/balance_and_proxy_allowance_fetcher';
|
||||
import { OrderFilledCancelledFetcher } from '../abstract/order_filled_cancelled_fetcher';
|
||||
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
|
||||
import { RemainingFillableCalculator } from '../order_watcher/remaining_fillable_calculator';
|
||||
import { BalanceAndProxyAllowanceLazyStore } from '../stores/balance_proxy_allowance_lazy_store';
|
||||
import { OrderFilledCancelledLazyStore } from '../stores/order_filled_cancelled_lazy_store';
|
||||
import { ExchangeContractErrs, OrderRelevantState, OrderState, OrderStateInvalid, OrderStateValid } from '../types';
|
||||
|
||||
const ACCEPTABLE_RELATIVE_ROUNDING_ERROR = 0.0001;
|
||||
|
||||
export class OrderStateUtils {
|
||||
private _balanceAndProxyAllowanceLazyStore: BalanceAndProxyAllowanceLazyStore;
|
||||
private _orderFilledCancelledLazyStore: OrderFilledCancelledLazyStore;
|
||||
private _balanceAndProxyAllowanceFetcher: BalanceAndProxyAllowanceFetcher;
|
||||
private _orderFilledCancelledFetcher: OrderFilledCancelledFetcher;
|
||||
private static _validateIfOrderIsValid(signedOrder: SignedOrder, orderRelevantState: OrderRelevantState): void {
|
||||
const unavailableTakerTokenAmount = orderRelevantState.cancelledTakerTokenAmount.add(
|
||||
orderRelevantState.filledTakerTokenAmount,
|
||||
@@ -49,11 +49,11 @@ export class OrderStateUtils {
|
||||
}
|
||||
}
|
||||
constructor(
|
||||
balanceAndProxyAllowanceLazyStore: BalanceAndProxyAllowanceLazyStore,
|
||||
orderFilledCancelledLazyStore: OrderFilledCancelledLazyStore,
|
||||
balanceAndProxyAllowanceFetcher: BalanceAndProxyAllowanceFetcher,
|
||||
orderFilledCancelledFetcher: OrderFilledCancelledFetcher,
|
||||
) {
|
||||
this._balanceAndProxyAllowanceLazyStore = balanceAndProxyAllowanceLazyStore;
|
||||
this._orderFilledCancelledLazyStore = orderFilledCancelledLazyStore;
|
||||
this._balanceAndProxyAllowanceFetcher = balanceAndProxyAllowanceFetcher;
|
||||
this._orderFilledCancelledFetcher = orderFilledCancelledFetcher;
|
||||
}
|
||||
public async getOrderStateAsync(signedOrder: SignedOrder): Promise<OrderState> {
|
||||
const orderRelevantState = await this.getOrderRelevantStateAsync(signedOrder);
|
||||
@@ -80,27 +80,27 @@ export class OrderStateUtils {
|
||||
// If we pass it from the instantiator - there is no opportunity to get it there
|
||||
// because JS doesn't support async constructors.
|
||||
// Moreover - it's cached under the hood so it's equivalent to an async constructor.
|
||||
const exchange = (this._orderFilledCancelledLazyStore as any)._exchange as ExchangeWrapper;
|
||||
const exchange = (this._orderFilledCancelledFetcher as any)._exchangeWrapper as ExchangeWrapper;
|
||||
const zrxTokenAddress = exchange.getZRXTokenAddress();
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
const makerBalance = await this._balanceAndProxyAllowanceLazyStore.getBalanceAsync(
|
||||
const makerBalance = await this._balanceAndProxyAllowanceFetcher.getBalanceAsync(
|
||||
signedOrder.makerTokenAddress,
|
||||
signedOrder.maker,
|
||||
);
|
||||
const makerProxyAllowance = await this._balanceAndProxyAllowanceLazyStore.getProxyAllowanceAsync(
|
||||
const makerProxyAllowance = await this._balanceAndProxyAllowanceFetcher.getProxyAllowanceAsync(
|
||||
signedOrder.makerTokenAddress,
|
||||
signedOrder.maker,
|
||||
);
|
||||
const makerFeeBalance = await this._balanceAndProxyAllowanceLazyStore.getBalanceAsync(
|
||||
const makerFeeBalance = await this._balanceAndProxyAllowanceFetcher.getBalanceAsync(
|
||||
zrxTokenAddress,
|
||||
signedOrder.maker,
|
||||
);
|
||||
const makerFeeProxyAllowance = await this._balanceAndProxyAllowanceLazyStore.getProxyAllowanceAsync(
|
||||
const makerFeeProxyAllowance = await this._balanceAndProxyAllowanceFetcher.getProxyAllowanceAsync(
|
||||
zrxTokenAddress,
|
||||
signedOrder.maker,
|
||||
);
|
||||
const filledTakerTokenAmount = await this._orderFilledCancelledLazyStore.getFilledTakerAmountAsync(orderHash);
|
||||
const cancelledTakerTokenAmount = await this._orderFilledCancelledLazyStore.getCancelledTakerAmountAsync(
|
||||
const filledTakerTokenAmount = await this._orderFilledCancelledFetcher.getFilledTakerAmountAsync(orderHash);
|
||||
const cancelledTakerTokenAmount = await this._orderFilledCancelledFetcher.getCancelledTakerAmountAsync(
|
||||
orderHash,
|
||||
);
|
||||
const unavailableTakerTokenAmount = await exchange.getUnavailableTakerAmountAsync(orderHash);
|
||||
|
@@ -1,16 +1,23 @@
|
||||
import { Deployer } from '@0xproject/deployer';
|
||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||
// HACK: This dependency is optional since it is only available when run from within
|
||||
// the monorepo. tslint doesn't handle optional dependencies
|
||||
// tslint:disable-next-line:no-implicit-dependencies
|
||||
import { runMigrationsAsync } from '@0xproject/migrations';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
import * as path from 'path';
|
||||
import * as Sinon from 'sinon';
|
||||
|
||||
import { ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx } from '../src';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { deployer } from './utils/deployer';
|
||||
import { TokenUtils } from './utils/token_utils';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
chaiSetup.configure();
|
||||
@@ -19,10 +26,14 @@ const expect = chai.expect;
|
||||
const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false;
|
||||
|
||||
describe('ZeroEx library', () => {
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
const zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||
let zeroEx: ZeroEx;
|
||||
before(async () => {
|
||||
await runMigrationsAsync(deployer);
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
});
|
||||
describe('#setProvider', () => {
|
||||
it('overrides provider in nested web3s and invalidates contractInstances', async () => {
|
||||
// Instantiate the contract instances with the current provider
|
||||
@@ -31,10 +42,9 @@ describe('ZeroEx library', () => {
|
||||
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.not.be.undefined();
|
||||
expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.not.be.undefined();
|
||||
|
||||
const newProvider = web3Factory.getRpcProvider();
|
||||
// Add property to newProvider so that we can differentiate it from old provider
|
||||
(newProvider as any).zeroExTestId = 1;
|
||||
zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
|
||||
(provider as any).zeroExTestId = 1;
|
||||
zeroEx.setProvider(provider, constants.TESTRPC_NETWORK_ID);
|
||||
|
||||
// Check that contractInstances with old provider are removed after provider update
|
||||
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.be.undefined();
|
||||
@@ -278,7 +288,7 @@ describe('ZeroEx library', () => {
|
||||
exchangeContractAddress: ZeroEx.NULL_ADDRESS,
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
const zeroExWithWrongExchangeAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
|
||||
const zeroExWithWrongExchangeAddress = new ZeroEx(provider, zeroExConfig);
|
||||
expect(zeroExWithWrongExchangeAddress.exchange.getContractAddress()).to.be.equal(ZeroEx.NULL_ADDRESS);
|
||||
});
|
||||
it('allows to specify token registry token contract address', async () => {
|
||||
@@ -286,7 +296,7 @@ describe('ZeroEx library', () => {
|
||||
tokenRegistryContractAddress: ZeroEx.NULL_ADDRESS,
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
const zeroExWithWrongTokenRegistryAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
|
||||
const zeroExWithWrongTokenRegistryAddress = new ZeroEx(provider, zeroExConfig);
|
||||
expect(zeroExWithWrongTokenRegistryAddress.tokenRegistry.getContractAddress()).to.be.equal(
|
||||
ZeroEx.NULL_ADDRESS,
|
||||
);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { web3Factory } from '@0xproject/dev-utils';
|
||||
import * as fs from 'fs';
|
||||
import HDWalletProvider = require('truffle-hdwallet-provider');
|
||||
|
||||
import { ZeroEx } from '../src';
|
||||
|
||||
@@ -14,14 +14,11 @@ const TIMEOUT = 10000;
|
||||
describe('Artifacts', () => {
|
||||
describe('contracts are deployed on kovan', () => {
|
||||
const kovanRpcUrl = constants.KOVAN_RPC_URL;
|
||||
const packageJSONContent = fs.readFileSync('package.json', 'utf-8');
|
||||
const packageJSON = JSON.parse(packageJSONContent);
|
||||
const mnemonic = packageJSON.config.mnemonic;
|
||||
const web3Provider = new HDWalletProvider(mnemonic, kovanRpcUrl);
|
||||
const provider = web3Factory.create({ rpcUrl: kovanRpcUrl }).currentProvider;
|
||||
const config = {
|
||||
networkId: constants.KOVAN_NETWORK_ID,
|
||||
};
|
||||
const zeroEx = new ZeroEx(web3Provider, config);
|
||||
const zeroEx = new ZeroEx(provider, config);
|
||||
it('token registry contract is deployed', async () => {
|
||||
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
||||
}).timeout(TIMEOUT);
|
||||
@@ -34,14 +31,11 @@ describe('Artifacts', () => {
|
||||
});
|
||||
describe('contracts are deployed on ropsten', () => {
|
||||
const ropstenRpcUrl = constants.ROPSTEN_RPC_URL;
|
||||
const packageJSONContent = fs.readFileSync('package.json', 'utf-8');
|
||||
const packageJSON = JSON.parse(packageJSONContent);
|
||||
const mnemonic = packageJSON.config.mnemonic;
|
||||
const web3Provider = new HDWalletProvider(mnemonic, ropstenRpcUrl);
|
||||
const provider = web3Factory.create({ rpcUrl: ropstenRpcUrl }).currentProvider;
|
||||
const config = {
|
||||
networkId: constants.ROPSTEN_NETWORK_ID,
|
||||
};
|
||||
const zeroEx = new ZeroEx(web3Provider, config);
|
||||
const zeroEx = new ZeroEx(provider, config);
|
||||
it('token registry contract is deployed', async () => {
|
||||
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
||||
}).timeout(TIMEOUT);
|
||||
|
@@ -6,15 +6,15 @@ import { ZeroEx } from '../src';
|
||||
import { assert } from '../src/utils/assert';
|
||||
|
||||
import { constants } from './utils/constants';
|
||||
import { provider } from './utils/web3_wrapper';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('Assertion library', () => {
|
||||
const web3 = web3Factory.create();
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
const zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||
const zeroEx = new ZeroEx(provider, config);
|
||||
describe('#isSenderAddressHexAsync', () => {
|
||||
it('throws when address is invalid', async () => {
|
||||
const address = '0xdeadbeef';
|
||||
|
@@ -3,7 +3,6 @@ import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as chai from 'chai';
|
||||
import 'mocha';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import {
|
||||
ApprovalContractEventArgs,
|
||||
@@ -24,7 +23,7 @@ import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
||||
import { TokenUtils } from './utils/token_utils';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -55,7 +54,7 @@ describe('EtherTokenWrapper', () => {
|
||||
const depositAmount = new BigNumber(42);
|
||||
const withdrawalAmount = new BigNumber(42);
|
||||
before(async () => {
|
||||
zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig);
|
||||
zeroEx = new ZeroEx(provider, zeroExConfig);
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
addressWithETH = userAddresses[0];
|
||||
@@ -79,7 +78,7 @@ describe('EtherTokenWrapper', () => {
|
||||
const UNKNOWN_NETWORK_NETWORK_ID = 10;
|
||||
expect(
|
||||
() =>
|
||||
new ZeroEx(web3.currentProvider, {
|
||||
new ZeroEx(provider, {
|
||||
networkId: UNKNOWN_NETWORK_NETWORK_ID,
|
||||
} as any),
|
||||
).to.throw();
|
||||
@@ -261,8 +260,7 @@ describe('EtherTokenWrapper', () => {
|
||||
callbackNeverToBeCalled,
|
||||
);
|
||||
const callbackToBeCalled = reportNodeCallbackErrors(done)();
|
||||
const newProvider = web3Factory.getRpcProvider();
|
||||
zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
|
||||
zeroEx.setProvider(provider, constants.TESTRPC_NETWORK_ID);
|
||||
await zeroEx.etherToken.depositAsync(etherTokenAddress, transferAmount, addressWithETH);
|
||||
zeroEx.etherToken.subscribe(
|
||||
etherTokenAddress,
|
||||
|
@@ -5,7 +5,6 @@ import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
import * as Sinon from 'sinon';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import { LogEvent } from '../src';
|
||||
import { EventWatcher } from '../src/order_watcher/event_watcher';
|
||||
@@ -13,12 +12,12 @@ import { DoneCallback } from '../src/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
||||
import { provider } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('EventWatcher', () => {
|
||||
let web3: Web3;
|
||||
let stubs: Sinon.SinonStub[] = [];
|
||||
let eventWatcher: EventWatcher;
|
||||
let web3Wrapper: Web3Wrapper;
|
||||
@@ -53,9 +52,8 @@ describe('EventWatcher', () => {
|
||||
transactionIndex: 0,
|
||||
};
|
||||
before(async () => {
|
||||
web3 = web3Factory.create();
|
||||
const pollingIntervalMs = 10;
|
||||
web3Wrapper = new Web3Wrapper(web3.currentProvider);
|
||||
web3Wrapper = new Web3Wrapper(provider);
|
||||
eventWatcher = new EventWatcher(web3Wrapper, pollingIntervalMs);
|
||||
});
|
||||
afterEach(() => {
|
||||
|
@@ -9,7 +9,7 @@ import { ExchangeTransferSimulator } from '../src/utils/exchange_transfer_simula
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -19,7 +19,7 @@ describe('ExchangeTransferSimulator', () => {
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
const zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||
const zeroEx = new ZeroEx(provider, config);
|
||||
const transferAmount = new BigNumber(5);
|
||||
let userAddresses: string[];
|
||||
let tokens: Token[];
|
||||
|
@@ -4,7 +4,6 @@ import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import {
|
||||
BlockRange,
|
||||
@@ -15,6 +14,7 @@ import {
|
||||
LogFillContractEventArgs,
|
||||
OrderCancellationRequest,
|
||||
OrderFillRequest,
|
||||
OrderState,
|
||||
SignedOrder,
|
||||
Token,
|
||||
ZeroEx,
|
||||
@@ -26,7 +26,7 @@ import { constants } from './utils/constants';
|
||||
import { FillScenarios } from './utils/fill_scenarios';
|
||||
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
||||
import { TokenUtils } from './utils/token_utils';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -46,7 +46,7 @@ describe('ExchangeWrapper', () => {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
before(async () => {
|
||||
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
exchangeContractAddress = zeroEx.exchange.getContractAddress();
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
@@ -977,8 +977,7 @@ describe('ExchangeWrapper', () => {
|
||||
);
|
||||
zeroEx.exchange.subscribe(ExchangeEvents.LogFill, indexFilterValues, callbackNeverToBeCalled);
|
||||
|
||||
const newProvider = web3Factory.getRpcProvider();
|
||||
zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
|
||||
zeroEx.setProvider(provider, constants.TESTRPC_NETWORK_ID);
|
||||
|
||||
const callback = reportNodeCallbackErrors(done)(
|
||||
(logEvent: DecodedLogEvent<LogFillContractEventArgs>) => {
|
||||
@@ -1156,4 +1155,41 @@ describe('ExchangeWrapper', () => {
|
||||
expect(args.maker).to.be.equal(differentMakerAddress);
|
||||
});
|
||||
});
|
||||
describe('#getOrderStateAsync', () => {
|
||||
let maker: string;
|
||||
let taker: string;
|
||||
let makerToken: Token;
|
||||
let takerToken: Token;
|
||||
let signedOrder: SignedOrder;
|
||||
let orderState: OrderState;
|
||||
const fillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(5), constants.ZRX_DECIMALS);
|
||||
before(async () => {
|
||||
[, maker, taker] = userAddresses;
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
[makerToken, takerToken] = tokenUtils.getDummyTokens();
|
||||
});
|
||||
it('should report orderStateValid when order is fillable', async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
orderState = await zeroEx.exchange.getOrderStateAsync(signedOrder);
|
||||
expect(orderState.isValid).to.be.true();
|
||||
});
|
||||
it('should report orderStateInvalid when maker allowance set to 0', async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
await zeroEx.token.setProxyAllowanceAsync(makerToken.address, maker, new BigNumber(0));
|
||||
orderState = await zeroEx.exchange.getOrderStateAsync(signedOrder);
|
||||
expect(orderState.isValid).to.be.false();
|
||||
});
|
||||
});
|
||||
}); // tslint:disable:max-file-line-count
|
||||
|
@@ -4,7 +4,6 @@ import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
import * as Sinon from 'sinon';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import { ZeroEx } from '../src/0x';
|
||||
import { ExpirationWatcher } from '../src/order_watcher/expiration_watcher';
|
||||
@@ -16,7 +15,7 @@ import { constants } from './utils/constants';
|
||||
import { FillScenarios } from './utils/fill_scenarios';
|
||||
import { reportNoErrorCallbackErrors } from './utils/report_callback_errors';
|
||||
import { TokenUtils } from './utils/token_utils';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -44,7 +43,7 @@ describe('ExpirationWatcher', () => {
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
exchangeContractAddress = zeroEx.exchange.getContractAddress();
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
|
@@ -3,7 +3,6 @@ import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import {
|
||||
ExchangeContractErrs,
|
||||
@@ -23,7 +22,7 @@ import { constants } from './utils/constants';
|
||||
import { FillScenarios } from './utils/fill_scenarios';
|
||||
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
||||
import { TokenUtils } from './utils/token_utils';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
const TIMEOUT_MS = 150;
|
||||
|
||||
@@ -51,7 +50,7 @@ describe('OrderStateWatcher', () => {
|
||||
const decimals = constants.ZRX_DECIMALS;
|
||||
const fillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals);
|
||||
before(async () => {
|
||||
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
orderStateWatcher = zeroEx.createOrderStateWatcher();
|
||||
exchangeContractAddress = zeroEx.exchange.getContractAddress();
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
|
@@ -3,7 +3,6 @@ import { BlockParamLiteral } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import * as Sinon from 'sinon';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import { ExchangeContractErrs, SignedOrder, Token, ZeroEx, ZeroExError } from '../src';
|
||||
import { TradeSide, TransferType } from '../src/types';
|
||||
@@ -14,7 +13,7 @@ import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { FillScenarios } from './utils/fill_scenarios';
|
||||
import { TokenUtils } from './utils/token_utils';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -40,7 +39,7 @@ describe('OrderValidation', () => {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
before(async () => {
|
||||
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
exchangeContractAddress = zeroEx.exchange.getContractAddress();
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
|
||||
|
@@ -3,7 +3,6 @@ import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
import * as Sinon from 'sinon';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import { ApprovalContractEventArgs, DecodedLogEvent, Token, TokenEvents, ZeroEx } from '../src';
|
||||
import { DoneCallback } from '../src/types';
|
||||
@@ -11,7 +10,7 @@ import { DoneCallback } from '../src/types';
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { assertNodeCallbackError } from './utils/report_callback_errors';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
@@ -26,7 +25,7 @@ describe('SubscriptionTest', () => {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
before(async () => {
|
||||
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
coinbase = userAddresses[0];
|
||||
|
@@ -8,7 +8,7 @@ import { Token, ZeroEx } from '../src';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -31,7 +31,7 @@ describe('TokenRegistryWrapper', () => {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
before(async () => {
|
||||
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
_.map(tokens, token => {
|
||||
tokenAddressBySymbol[token.symbol] = token.address;
|
||||
|
@@ -1,14 +1,13 @@
|
||||
import { web3Factory } from '@0xproject/dev-utils';
|
||||
import * as chai from 'chai';
|
||||
|
||||
import { ZeroEx } from '../src';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { provider } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
const web3 = web3Factory.create();
|
||||
|
||||
describe('TokenTransferProxyWrapper', () => {
|
||||
let zeroEx: ZeroEx;
|
||||
@@ -16,7 +15,7 @@ describe('TokenTransferProxyWrapper', () => {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
before(async () => {
|
||||
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
});
|
||||
describe('#isAuthorizedAsync', () => {
|
||||
it('should return false if the address is not authorized', async () => {
|
||||
|
@@ -1,9 +1,10 @@
|
||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||
import { EmptyWalletSubprovider } from '@0xproject/subproviders';
|
||||
import { Provider } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as chai from 'chai';
|
||||
import 'mocha';
|
||||
import * as Web3 from 'web3';
|
||||
import Web3ProviderEngine = require('web3-provider-engine');
|
||||
|
||||
import {
|
||||
ApprovalContractEventArgs,
|
||||
@@ -22,7 +23,7 @@ import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
||||
import { TokenUtils } from './utils/token_utils';
|
||||
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -39,7 +40,7 @@ describe('TokenWrapper', () => {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
before(async () => {
|
||||
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
tokenUtils = new TokenUtils(tokens);
|
||||
@@ -164,7 +165,7 @@ describe('TokenWrapper', () => {
|
||||
});
|
||||
});
|
||||
describe('#getBalanceAsync', () => {
|
||||
describe('With web3 provider with accounts', () => {
|
||||
describe('With provider with accounts', () => {
|
||||
it('should return the balance for an existing ERC20 token', async () => {
|
||||
const token = tokens[0];
|
||||
const ownerAddress = coinbase;
|
||||
@@ -187,14 +188,14 @@ describe('TokenWrapper', () => {
|
||||
return expect(balance).to.be.bignumber.equal(expectedBalance);
|
||||
});
|
||||
});
|
||||
describe('With web3 provider without accounts', () => {
|
||||
describe('With provider without accounts', () => {
|
||||
let zeroExWithoutAccounts: ZeroEx;
|
||||
before(async () => {
|
||||
const hasAddresses = false;
|
||||
const web3WithoutAccounts = web3Factory.create({ hasAddresses });
|
||||
zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config);
|
||||
const emptyWalletProvider = addEmptyWalletSubprovider(provider);
|
||||
zeroExWithoutAccounts = new ZeroEx(emptyWalletProvider, config);
|
||||
});
|
||||
it('should return balance even when called with Web3 provider instance without addresses', async () => {
|
||||
it('should return balance even when called with provider instance without addresses', async () => {
|
||||
const token = tokens[0];
|
||||
const ownerAddress = coinbase;
|
||||
const balance = await zeroExWithoutAccounts.token.getBalanceAsync(token.address, ownerAddress);
|
||||
@@ -277,7 +278,7 @@ describe('TokenWrapper', () => {
|
||||
});
|
||||
});
|
||||
describe('#getAllowanceAsync', () => {
|
||||
describe('With web3 provider with accounts', () => {
|
||||
describe('With provider with accounts', () => {
|
||||
it('should get the proxy allowance', async () => {
|
||||
const token = tokens[0];
|
||||
const ownerAddress = coinbase;
|
||||
@@ -299,12 +300,12 @@ describe('TokenWrapper', () => {
|
||||
return expect(allowance).to.be.bignumber.equal(expectedAllowance);
|
||||
});
|
||||
});
|
||||
describe('With web3 provider without accounts', () => {
|
||||
describe('With provider without accounts', () => {
|
||||
let zeroExWithoutAccounts: ZeroEx;
|
||||
before(async () => {
|
||||
const hasAddresses = false;
|
||||
const web3WithoutAccounts = web3Factory.create({ hasAddresses });
|
||||
zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config);
|
||||
const emptyWalletProvider = addEmptyWalletSubprovider(provider);
|
||||
zeroExWithoutAccounts = new ZeroEx(emptyWalletProvider, config);
|
||||
});
|
||||
it('should get the proxy allowance', async () => {
|
||||
const token = tokens[0];
|
||||
@@ -424,8 +425,7 @@ describe('TokenWrapper', () => {
|
||||
);
|
||||
zeroEx.token.subscribe(tokenAddress, TokenEvents.Transfer, indexFilterValues, callbackNeverToBeCalled);
|
||||
const callbackToBeCalled = reportNodeCallbackErrors(done)();
|
||||
const newProvider = web3Factory.getRpcProvider();
|
||||
zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
|
||||
zeroEx.setProvider(provider, constants.TESTRPC_NETWORK_ID);
|
||||
zeroEx.token.subscribe(tokenAddress, TokenEvents.Transfer, indexFilterValues, callbackToBeCalled);
|
||||
await zeroEx.token.transferAsync(tokenAddress, coinbase, addressWithoutFunds, transferAmount);
|
||||
})().catch(done);
|
||||
@@ -515,3 +515,14 @@ describe('TokenWrapper', () => {
|
||||
});
|
||||
});
|
||||
// tslint:disable:max-file-line-count
|
||||
|
||||
function addEmptyWalletSubprovider(p: Provider): Provider {
|
||||
const providerEngine = new Web3ProviderEngine();
|
||||
providerEngine.addProvider(new EmptyWalletSubprovider());
|
||||
const currentSubproviders = (p as any)._providers;
|
||||
for (const subprovider of currentSubproviders) {
|
||||
providerEngine.addProvider(subprovider);
|
||||
}
|
||||
providerEngine.start();
|
||||
return providerEngine;
|
||||
}
|
||||
|
@@ -2,19 +2,17 @@ import { Deployer } from '@0xproject/deployer';
|
||||
import { devConstants } from '@0xproject/dev-utils';
|
||||
import * as path from 'path';
|
||||
|
||||
import { constants } from '../util/constants';
|
||||
import { constants } from './constants';
|
||||
|
||||
import { runMigrationsAsync } from './migrate';
|
||||
import { provider } from './web3_wrapper';
|
||||
|
||||
const artifactsDir = path.resolve('test', 'artifacts');
|
||||
const deployerOpts = {
|
||||
artifactsDir: path.resolve('src', 'artifacts'),
|
||||
jsonrpcUrl: devConstants.RPC_URL,
|
||||
artifactsDir,
|
||||
provider,
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
defaults: {
|
||||
gas: devConstants.GAS_ESTIMATE,
|
||||
},
|
||||
};
|
||||
|
||||
export const deployer = new Deployer(deployerOpts);
|
||||
|
||||
runMigrationsAsync(deployer).catch(console.log);
|
@@ -1,6 +1,12 @@
|
||||
import { web3Factory } from '@0xproject/dev-utils';
|
||||
import { devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||
import { Provider } from '@0xproject/types';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
export const web3 = web3Factory.create();
|
||||
export const web3Wrapper = new Web3Wrapper(web3.currentProvider);
|
||||
import { constants } from './constants';
|
||||
|
||||
const web3 = web3Factory.create({ shouldUseInProcessGanache: true });
|
||||
const provider: Provider = web3.currentProvider;
|
||||
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
|
||||
|
||||
export { provider, web3Wrapper };
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1524044013,
|
||||
"version": "0.2.11",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1523462196,
|
||||
"version": "0.2.10",
|
||||
|
@@ -5,7 +5,11 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.2.10 - _April 11, 2018_
|
||||
## v0.2.11 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.10 - _April 12, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
@@ -17,26 +21,26 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.5 - _March 17, 2018_
|
||||
## v0.2.5 - _March 18, 2018_
|
||||
|
||||
* Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package (#452)
|
||||
|
||||
## v0.2.4 - _March 3, 2018_
|
||||
## v0.2.4 - _March 4, 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 8, 2018_
|
||||
## v0.2.1 - _February 9, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.2.0 - _February 6, 2018_
|
||||
## v0.2.0 - _February 7, 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 10, 2018_
|
||||
## v0.1.0 - _January 11, 2018_
|
||||
|
||||
* Fixed array typings with union types (#295)
|
||||
* Add event ABIs to context data passed to templates (#302)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/abi-gen",
|
||||
"version": "0.2.9",
|
||||
"version": "0.2.10",
|
||||
"description": "Generate contract wrappers from ABI and handlebars templates",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
@@ -24,9 +24,9 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/types": "^0.5.0",
|
||||
"@0xproject/typescript-typings": "^0.0.3",
|
||||
"@0xproject/utils": "^0.5.0",
|
||||
"@0xproject/types": "^0.6.0",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/utils": "^0.5.1",
|
||||
"chalk": "^2.3.0",
|
||||
"glob": "^7.1.2",
|
||||
"handlebars": "^4.0.11",
|
||||
@@ -36,8 +36,8 @@
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@types/glob": "^5.0.33",
|
||||
"@types/handlebars": "^4.0.36",
|
||||
"@types/mkdirp": "^0.5.1",
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1524044013,
|
||||
"version": "0.2.7",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1523462196,
|
||||
"version": "0.2.6",
|
||||
|
@@ -5,7 +5,11 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.2.6 - _April 11, 2018_
|
||||
## v0.2.7 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.6 - _April 12, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
@@ -17,20 +21,20 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.0 - _March 7, 2018_
|
||||
## v0.2.0 - _March 8, 2018_
|
||||
|
||||
* Rename `isHttpUrl` to `isWebUri` (#412)
|
||||
|
||||
## v0.1.0 - _March 3, 2018_
|
||||
## v0.1.0 - _March 4, 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 8, 2017_
|
||||
## v0.0.18 - _February 9, 2017_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.0.4 - _November 13, 2017_
|
||||
## v0.0.4 - _November 14, 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.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/assert",
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"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",
|
||||
@@ -9,7 +9,7 @@
|
||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"clean": "shx rm -rf lib test_temp scripts",
|
||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js --exit",
|
||||
"prepublishOnly": "run-p build",
|
||||
"test": "run-s clean build run_mocha",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
@@ -27,8 +27,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/valid-url": "^1.0.2",
|
||||
@@ -43,9 +43,9 @@
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/json-schemas": "^0.7.19",
|
||||
"@0xproject/typescript-typings": "^0.0.3",
|
||||
"@0xproject/utils": "^0.5.0",
|
||||
"@0xproject/json-schemas": "^0.7.20",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/utils": "^0.5.1",
|
||||
"lodash": "^4.17.4",
|
||||
"valid-url": "^1.0.9"
|
||||
},
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1524044013,
|
||||
"version": "0.2.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"changes": [
|
||||
|
@@ -5,7 +5,11 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.2.0 - _April 11, 2018_
|
||||
## v0.2.1 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.0 - _April 12, 2018_
|
||||
|
||||
* Contract wrappers now accept Provider and defaults instead of Web3Wrapper (#501)
|
||||
|
||||
@@ -19,6 +23,6 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.2 - _March 3, 2018_
|
||||
## v0.0.2 - _March 4, 2018_
|
||||
|
||||
* Initial release
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/base-contract",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"description": "0x Base TS contract",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
@@ -26,8 +26,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@types/lodash": "4.14.104",
|
||||
"chai": "^4.0.1",
|
||||
"copyfiles": "^1.2.0",
|
||||
@@ -38,10 +38,10 @@
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/types": "^0.5.0",
|
||||
"@0xproject/typescript-typings": "^0.0.3",
|
||||
"@0xproject/utils": "^0.5.0",
|
||||
"@0xproject/web3-wrapper": "^0.5.0",
|
||||
"@0xproject/types": "^0.6.0",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/utils": "^0.5.1",
|
||||
"@0xproject/web3-wrapper": "^0.6.0",
|
||||
"ethers-contracts": "^2.2.1",
|
||||
"lodash": "^4.17.4"
|
||||
},
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1524044013,
|
||||
"version": "0.6.10",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1523462196,
|
||||
"version": "0.6.9",
|
||||
|
@@ -5,7 +5,11 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.6.9 - _April 11, 2018_
|
||||
## v0.6.10 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.9 - _April 12, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
@@ -17,44 +21,44 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.4 - _March 17, 2018_
|
||||
## v0.6.4 - _March 18, 2018_
|
||||
|
||||
* Consolidate `Order`, `SignedOrder`, and `ECSignature` into the `@0xproject/types` package (#456)
|
||||
|
||||
## v0.6.2 - _February 15, 2018_
|
||||
## v0.6.2 - _February 16, 2018_
|
||||
|
||||
* Fix JSON parse empty response (#407)
|
||||
|
||||
## v0.6.0 - _February 15, 2018_
|
||||
## v0.6.0 - _February 16, 2018_
|
||||
|
||||
* Add pagination options to HttpClient methods (#393)
|
||||
* Add heartbeat configuration to WebSocketOrderbookChannel constructor (#406)
|
||||
|
||||
## v0.5.7 - _February 8, 2018_
|
||||
## v0.5.7 - _February 9, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.5.0 - _January 16, 2018_
|
||||
## v0.5.0 - _January 17, 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 10, 2018_
|
||||
## v0.4.0 - _January 11, 2018_
|
||||
|
||||
* Prevent getFeesAsync method on HttpClient from mutating input (#296)
|
||||
|
||||
## v0.3.0 - _December 7, 2017_
|
||||
## v0.3.0 - _December 8, 2017_
|
||||
|
||||
* Expose WebSocketOrderbookChannel and associated types to public interface (#251)
|
||||
* Remove tokenA and tokenB fields from OrdersRequest (#256)
|
||||
|
||||
## v0.2.0 - _November 28, 2017_
|
||||
## v0.2.0 - _November 29, 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 21, 2017_
|
||||
## v0.1.0 - _November 22, 2017_
|
||||
|
||||
* Provide a HttpClient class for interacting with standard relayer api compliant HTTP urls
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/connect",
|
||||
"version": "0.6.8",
|
||||
"version": "0.6.9",
|
||||
"description": "A javascript library for interacting with the standard relayer api",
|
||||
"keywords": [
|
||||
"connect",
|
||||
@@ -17,7 +17,7 @@
|
||||
"clean": "shx rm -rf lib test_temp scripts",
|
||||
"copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
|
||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js --exit",
|
||||
"test": "run-s clean build copy_test_fixtures run_mocha",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
@@ -50,19 +50,19 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
|
||||
"dependencies": {
|
||||
"@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",
|
||||
"@0xproject/assert": "^0.2.6",
|
||||
"@0xproject/json-schemas": "^0.7.20",
|
||||
"@0xproject/types": "^0.6.0",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/utils": "^0.5.1",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"lodash": "^4.17.4",
|
||||
"query-string": "^5.0.1",
|
||||
"websocket": "^1.0.25"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@types/fetch-mock": "^5.12.1",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
|
@@ -15,14 +15,14 @@ export interface OrderbookChannel {
|
||||
close: () => void;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* heartbeatInterval: Interval in milliseconds that the orderbook channel should ping the underlying websocket. Default: 15000
|
||||
*/
|
||||
export interface WebSocketOrderbookChannelConfig {
|
||||
heartbeatIntervalMs?: number;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* baseTokenAddress: The address of token designated as the baseToken in the currency pair calculation of price
|
||||
* quoteTokenAddress: The address of token designated as the quoteToken in the currency pair calculation of price
|
||||
* snapshot: If true, a snapshot of the orderbook will be sent before the updates to the orderbook
|
||||
|
@@ -72,17 +72,6 @@ yarn lint
|
||||
|
||||
### Run Tests
|
||||
|
||||
Before running the tests, you will need to spin up a [TestRPC](https://www.npmjs.com/package/ethereumjs-testrpc) instance.
|
||||
|
||||
In a separate terminal, start TestRPC (a convenience command is provided as part of the [0x.js monorepo](https://github.com/0xProject/0x-monorepo))
|
||||
|
||||
```bash
|
||||
cd ../..
|
||||
yarn testrpc
|
||||
```
|
||||
|
||||
Then in your main terminal run
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
@@ -1,10 +0,0 @@
|
||||
import { MultiSigConfigByNetwork } from '../types';
|
||||
|
||||
// Make a copy of this file named `multisig.js` and input custom params as needed
|
||||
export const multiSig: MultiSigConfigByNetwork = {
|
||||
kovan: {
|
||||
owners: [],
|
||||
confirmationsRequired: 0,
|
||||
secondsRequired: 0,
|
||||
},
|
||||
};
|
@@ -1,23 +0,0 @@
|
||||
export interface MultiSigConfig {
|
||||
owners: string[];
|
||||
confirmationsRequired: number;
|
||||
secondsRequired: number;
|
||||
}
|
||||
|
||||
export interface MultiSigConfigByNetwork {
|
||||
[networkName: string]: MultiSigConfig;
|
||||
}
|
||||
|
||||
export interface Token {
|
||||
address?: string;
|
||||
name: string;
|
||||
symbol: string;
|
||||
decimals: number;
|
||||
ipfsHash: string;
|
||||
swarmHash: string;
|
||||
}
|
||||
|
||||
export interface TokenInfoByNetwork {
|
||||
development: Token[];
|
||||
live: Token[];
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "contracts",
|
||||
"version": "2.1.21",
|
||||
"version": "2.1.22",
|
||||
"description": "Smart contract components of 0x protocol",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
@@ -10,16 +10,15 @@
|
||||
"scripts": {
|
||||
"build:watch": "tsc -w",
|
||||
"prebuild": "run-s clean compile copy_artifacts generate_contract_wrappers",
|
||||
"copy_artifacts": "copyfiles './src/artifacts/**/*' ./lib",
|
||||
"copy_artifacts": "copyfiles -u 4 '../migrations/src/artifacts/**/*' ./lib/src/artifacts;",
|
||||
"build": "tsc",
|
||||
"test": "run-s build run_mocha",
|
||||
"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} --contract-dirs src/contracts --artifacts-dir src/artifacts",
|
||||
"compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir ../migrations/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",
|
||||
"lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
@@ -27,7 +26,7 @@
|
||||
"test:circleci": "yarn test:coverage"
|
||||
},
|
||||
"config": {
|
||||
"abis": "src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|Arbitrage|EtherDelta|AccountLevels).json",
|
||||
"abis": "../migrations/src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|Arbitrage|EtherDelta|AccountLevels).json",
|
||||
"contracts": "Exchange,DummyToken,ZRXToken,Token,WETH9,TokenTransferProxy,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,MaliciousToken,TokenRegistry,Arbitrage,EtherDelta,AccountLevels"
|
||||
},
|
||||
"repository": {
|
||||
@@ -41,8 +40,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/dev-utils": "^0.3.4",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@0xproject/dev-utils": "^0.3.5",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/node": "^8.0.53",
|
||||
"@types/yargs": "^10.0.0",
|
||||
@@ -55,18 +54,18 @@
|
||||
"npm-run-all": "^4.1.2",
|
||||
"prettier": "^1.11.1",
|
||||
"shx": "^0.2.2",
|
||||
"solc": "^0.4.18",
|
||||
"solc": "^0.4.22",
|
||||
"tslint": "5.8.0",
|
||||
"typescript": "2.7.1",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"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",
|
||||
"0x.js": "^0.36.0",
|
||||
"@0xproject/deployer": "^0.4.0",
|
||||
"@0xproject/types": "^0.6.0",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/utils": "^0.5.1",
|
||||
"@0xproject/web3-wrapper": "^0.6.0",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereumjs-abi": "^0.6.4",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
|
@@ -46,7 +46,7 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
|
||||
describe('changeTimeLock', () => {
|
||||
describe('initially non-time-locked', async () => {
|
||||
before('deploy a walet', async () => {
|
||||
before('deploy a wallet', async () => {
|
||||
const multiSigInstance = await deployer.deployAsync(ContractName.MultiSigWalletWithTimeLock, [
|
||||
owners,
|
||||
SIGNATURES_REQUIRED,
|
||||
@@ -143,7 +143,7 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
});
|
||||
});
|
||||
describe('initially time-locked', async () => {
|
||||
before('deploy a walet', async () => {
|
||||
before('deploy a wallet', async () => {
|
||||
const multiSigInstance = await deployer.deployAsync(ContractName.MultiSigWalletWithTimeLock, [
|
||||
owners,
|
||||
SIGNATURES_REQUIRED,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { ZeroEx } from '0x.js';
|
||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { BigNumber, NULL_BYTES } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as chai from 'chai';
|
||||
import ethUtil = require('ethereumjs-util');
|
||||
@@ -66,8 +66,8 @@ describe('TokenRegistry', () => {
|
||||
name: '',
|
||||
symbol: '',
|
||||
decimals: 0,
|
||||
ipfsHash: constants.NULL_BYTES,
|
||||
swarmHash: constants.NULL_BYTES,
|
||||
ipfsHash: NULL_BYTES,
|
||||
swarmHash: NULL_BYTES,
|
||||
};
|
||||
|
||||
describe('addToken', () => {
|
||||
|
@@ -8,7 +8,7 @@ import { web3 } from './web3_wrapper';
|
||||
|
||||
const deployerOpts = {
|
||||
provider: web3.currentProvider,
|
||||
artifactsDir: path.resolve('src', 'artifacts'),
|
||||
artifactsDir: path.resolve('lib', 'src', 'artifacts'),
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
defaults: {
|
||||
gas: devConstants.GAS_ESTIMATE,
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import { web3Factory } from '@0xproject/dev-utils';
|
||||
import { Provider } from '@0xproject/types';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
|
||||
const web3ProviderConfig = { shouldUseInProcessGanache: true };
|
||||
export const web3 = web3Factory.create(web3ProviderConfig);
|
||||
const providerConfigs = { shouldUseInProcessGanache: true };
|
||||
export const web3 = web3Factory.create(providerConfigs);
|
||||
export const provider = web3.currentProvider;
|
||||
export const web3Wrapper = new Web3Wrapper(provider);
|
||||
|
@@ -4,7 +4,6 @@ const DUMMY_TOKEN_DECIMALS = 18;
|
||||
const DUMMY_TOKEN_TOTAL_SUPPLY = 0;
|
||||
|
||||
export const constants = {
|
||||
NULL_BYTES: '0x',
|
||||
INVALID_OPCODE: 'invalid opcode',
|
||||
REVERT: 'revert',
|
||||
TESTRPC_NETWORK_ID: 50,
|
||||
|
@@ -4,14 +4,14 @@ import ethUtil = require('ethereumjs-util');
|
||||
import * as _ from 'lodash';
|
||||
|
||||
export const crypto = {
|
||||
/*
|
||||
* We convert types from JS to Solidity as follows:
|
||||
* BigNumber -> uint256
|
||||
* number -> uint8
|
||||
* string -> string
|
||||
* boolean -> bool
|
||||
* valid Ethereum address -> address
|
||||
*/
|
||||
/**
|
||||
* We convert types from JS to Solidity as follows:
|
||||
* BigNumber -> uint256
|
||||
* number -> uint8
|
||||
* string -> string
|
||||
* boolean -> bool
|
||||
* valid Ethereum address -> address
|
||||
*/
|
||||
solSHA3(args: any[]): Buffer {
|
||||
return crypto._solHash(args, ABI.soliditySHA3);
|
||||
},
|
||||
|
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"version": "0.4.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add support for solidity 0.4.22",
|
||||
"pr": 531
|
||||
}
|
||||
],
|
||||
"timestamp": 1524044013
|
||||
},
|
||||
{
|
||||
"version": "0.4.0",
|
||||
"changes": [
|
||||
|
@@ -5,7 +5,11 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.4.0 - _April 11, 2018_
|
||||
## v0.4.1 - _April 18, 2018_
|
||||
|
||||
* Add support for solidity 0.4.22 (#531)
|
||||
|
||||
## v0.4.0 - _April 12, 2018_
|
||||
|
||||
* Changed the config key `web3Provider` to `provider` to be consistent with other tools (#501)
|
||||
|
||||
@@ -17,11 +21,11 @@ CHANGELOG
|
||||
|
||||
* Create solc_bin directory if does not exist before attempting to compile (#491)
|
||||
|
||||
## v0.3.1 - _March 17, 2018_
|
||||
## v0.3.1 - _March 18, 2018_
|
||||
|
||||
* Add TS types for `yargs`
|
||||
|
||||
## v0.3.0 - _March 17, 2018_
|
||||
## v0.3.0 - _March 18, 2018_
|
||||
|
||||
* Add support for Solidity 0.4.20 and 0.4.21
|
||||
* Replace `jsonrpcPort` config with `jsonrpcUrl` (#426)
|
||||
@@ -34,15 +38,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 3, 2018_
|
||||
## v0.2.0 - _March 4, 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 15, 2018_
|
||||
## v0.1.0 - _February 16, 2018_
|
||||
|
||||
* Add the ability to pass in specific contracts to compile in CLI (#400)
|
||||
|
||||
## v0.0.8 - _February 8, 2018_
|
||||
## v0.0.8 - _February 9, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/deployer",
|
||||
"version": "0.3.5",
|
||||
"version": "0.4.0",
|
||||
"description": "Smart contract deployer of 0x protocol",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
@@ -8,7 +8,7 @@
|
||||
"build:watch": "tsc -w",
|
||||
"build": "yarn clean && copyfiles 'test/fixtures/contracts/**/*' ./lib && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"test": "run-s build run_mocha",
|
||||
"run_mocha": "mocha lib/test/*_test.js",
|
||||
"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",
|
||||
"compile": "npm run build; node lib/src/cli.js compile",
|
||||
@@ -47,12 +47,11 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/deployer/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/dev-utils": "^0.2.1",
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@0xproject/dev-utils": "^0.3.4",
|
||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@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",
|
||||
@@ -65,20 +64,24 @@
|
||||
"typedoc": "0xProject/typedoc",
|
||||
"types-bn": "^0.0.1",
|
||||
"typescript": "2.7.1",
|
||||
"web3-typescript-typings": "^0.10.2"
|
||||
"web3-typescript-typings": "^0.10.2",
|
||||
"zeppelin-solidity": "1.8.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@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",
|
||||
"@0xproject/sol-resolver": "^0.0.1",
|
||||
"@0xproject/json-schemas": "^0.7.20",
|
||||
"@0xproject/types": "^0.6.0",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/utils": "^0.5.1",
|
||||
"@0xproject/web3-wrapper": "^0.6.0",
|
||||
"@types/yargs": "^11.0.0",
|
||||
"chalk": "^2.3.0",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"lodash": "^4.17.4",
|
||||
"require-from-string": "^2.0.1",
|
||||
"semver": "^5.5.0",
|
||||
"solc": "^0.4.18",
|
||||
"solc": "^0.4.22",
|
||||
"web3": "^0.20.0",
|
||||
"web3-eth-abi": "^1.0.0-beta.24",
|
||||
"yargs": "^10.0.3"
|
||||
|
@@ -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, ContractDirectory, DeployerOptions } from './utils/types';
|
||||
import { CliOptions, CompilerOptions, 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 = {
|
||||
contractDirs: getContractDirectoriesFromList(argv.contractDirs),
|
||||
contractsDir: argv.contractsDir,
|
||||
networkId: argv.networkId,
|
||||
optimizerEnabled: argv.shouldOptimize,
|
||||
artifactsDir: argv.artifactsDir,
|
||||
@@ -41,11 +41,11 @@ async function onCompileCommandAsync(argv: CliOptions): Promise<void> {
|
||||
*/
|
||||
async function onDeployCommandAsync(argv: CliOptions): Promise<void> {
|
||||
const url = argv.jsonrpcUrl;
|
||||
const web3Provider = new Web3.providers.HttpProvider(url);
|
||||
const web3Wrapper = new Web3Wrapper(web3Provider);
|
||||
const provider = new Web3.providers.HttpProvider(url);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const networkId = await web3Wrapper.getNetworkIdAsync();
|
||||
const compilerOpts: CompilerOptions = {
|
||||
contractDirs: getContractDirectoriesFromList(argv.contractDirs),
|
||||
contractsDir: argv.contractsDir,
|
||||
networkId,
|
||||
optimizerEnabled: argv.shouldOptimize,
|
||||
artifactsDir: argv.artifactsDir,
|
||||
@@ -67,29 +67,6 @@ 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
|
||||
@@ -126,11 +103,10 @@ function deployCommandBuilder(yargsInstance: any) {
|
||||
(() => {
|
||||
const identityCommandBuilder = _.identity;
|
||||
return yargs
|
||||
.option('contract-dirs', {
|
||||
.option('contracts-dir', {
|
||||
type: 'string',
|
||||
default: DEFAULT_CONTRACTS_DIR,
|
||||
description:
|
||||
"comma separated list of contract directories.\nTo avoid filename clashes, directories should be prefixed with a namespace as follows: 'namespace:/path/to/dir'.",
|
||||
description: 'path of contracts directory to compile',
|
||||
})
|
||||
.option('network-id', {
|
||||
type: 'number',
|
||||
|
@@ -1,5 +1,17 @@
|
||||
import { AbiType, ContractAbi, MethodAbi } from '@0xproject/types';
|
||||
import {
|
||||
ContractSource,
|
||||
ContractSources,
|
||||
EnumerableResolver,
|
||||
FallthroughResolver,
|
||||
FSResolver,
|
||||
NameResolver,
|
||||
NPMResolver,
|
||||
Resolver,
|
||||
URLResolver,
|
||||
} from '@0xproject/sol-resolver';
|
||||
import { ContractAbi } from '@0xproject/types';
|
||||
import { logUtils, promisify } from '@0xproject/utils';
|
||||
import chalk from 'chalk';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
import * as fs from 'fs';
|
||||
import 'isomorphic-fetch';
|
||||
@@ -11,10 +23,7 @@ import solc = require('solc');
|
||||
|
||||
import { binPaths } from './solc/bin_paths';
|
||||
import {
|
||||
constructContractId,
|
||||
constructUniqueSourceFileId,
|
||||
createDirIfDoesNotExistAsync,
|
||||
findImportIfExist,
|
||||
getContractArtifactIfExistsAsync,
|
||||
getNormalizedErrMsg,
|
||||
parseDependencies,
|
||||
@@ -25,14 +34,10 @@ import { fsWrapper } from './utils/fs_wrapper';
|
||||
import {
|
||||
CompilerOptions,
|
||||
ContractArtifact,
|
||||
ContractDirectory,
|
||||
ContractIdToSourceFileId,
|
||||
ContractNetworkData,
|
||||
ContractNetworks,
|
||||
ContractSourceDataByFileId,
|
||||
ContractSources,
|
||||
ContractSourceData,
|
||||
ContractSpecificSourceData,
|
||||
FunctionNameToSeenCount,
|
||||
} from './utils/types';
|
||||
import { utils } from './utils/utils';
|
||||
|
||||
@@ -44,71 +49,32 @@ const SOLC_BIN_DIR = path.join(__dirname, '..', '..', 'solc_bin');
|
||||
* to artifact files.
|
||||
*/
|
||||
export class Compiler {
|
||||
private _contractDirs: Set<ContractDirectory>;
|
||||
private _resolver: Resolver;
|
||||
private _nameResolver: NameResolver;
|
||||
private _contractsDir: string;
|
||||
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 _specifiedContracts: Set<string> = new Set();
|
||||
private _contractSourceDataByFileId: ContractSourceDataByFileId = {};
|
||||
|
||||
/**
|
||||
* Recursively retrieves Solidity source code from directory.
|
||||
* @param dirPath Directory to search.
|
||||
* @param contractBaseDir Base contracts directory of search tree.
|
||||
* @return Mapping of sourceFilePath to the contract source.
|
||||
*/
|
||||
private static async _getContractSourcesAsync(dirPath: string, contractBaseDir: string): Promise<ContractSources> {
|
||||
let dirContents: string[] = [];
|
||||
try {
|
||||
dirContents = await fsWrapper.readdirAsync(dirPath);
|
||||
} catch (err) {
|
||||
throw new Error(`No directory found at ${dirPath}`);
|
||||
}
|
||||
let sources: ContractSources = {};
|
||||
for (const fileName of dirContents) {
|
||||
const contentPath = `${dirPath}/${fileName}`;
|
||||
if (path.extname(fileName) === constants.SOLIDITY_FILE_EXTENSION) {
|
||||
try {
|
||||
const opts = {
|
||||
encoding: 'utf8',
|
||||
};
|
||||
const source = await fsWrapper.readFileAsync(contentPath, opts);
|
||||
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, contractBaseDir);
|
||||
sources = {
|
||||
...sources,
|
||||
...nestedSources,
|
||||
};
|
||||
} catch (err) {
|
||||
logUtils.log(`${contentPath} is not a directory or ${constants.SOLIDITY_FILE_EXTENSION} file`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sources;
|
||||
}
|
||||
/**
|
||||
* Instantiates a new instance of the Compiler class.
|
||||
* @param opts Options specifying directories, network, and optimization settings.
|
||||
* @return An instance of the Compiler class.
|
||||
*/
|
||||
constructor(opts: CompilerOptions) {
|
||||
this._contractDirs = opts.contractDirs;
|
||||
this._contractsDir = opts.contractsDir;
|
||||
this._networkId = opts.networkId;
|
||||
this._optimizerEnabled = opts.optimizerEnabled;
|
||||
this._artifactsDir = opts.artifactsDir;
|
||||
this._specifiedContracts = opts.specifiedContracts;
|
||||
this._nameResolver = new NameResolver(path.resolve(this._contractsDir));
|
||||
const resolver = new FallthroughResolver();
|
||||
resolver.appendResolver(new URLResolver());
|
||||
const packagePath = path.resolve('');
|
||||
resolver.appendResolver(new NPMResolver(packagePath));
|
||||
resolver.appendResolver(new FSResolver());
|
||||
resolver.appendResolver(this._nameResolver);
|
||||
this._resolver = resolver;
|
||||
}
|
||||
/**
|
||||
* Compiles selected Solidity files found in `contractsDir` and writes JSON artifacts to `artifactsDir`.
|
||||
@@ -116,51 +82,27 @@ export class Compiler {
|
||||
public async compileAsync(): Promise<void> {
|
||||
await createDirIfDoesNotExistAsync(this._artifactsDir);
|
||||
await createDirIfDoesNotExistAsync(SOLC_BIN_DIR);
|
||||
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;
|
||||
});
|
||||
let contractNamesToCompile: string[] = [];
|
||||
if (this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER)) {
|
||||
const allContracts = this._nameResolver.getAll();
|
||||
contractNamesToCompile = _.map(allContracts, contractSource =>
|
||||
path.basename(contractSource.path, constants.SOLIDITY_FILE_EXTENSION),
|
||||
);
|
||||
} else {
|
||||
contractNamesToCompile = Array.from(this._specifiedContracts.values());
|
||||
}
|
||||
for (const contractNameToCompile of contractNamesToCompile) {
|
||||
await this._compileContractAsync(contractNameToCompile);
|
||||
}
|
||||
_.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 sourceFileId Unique ID of the source file.
|
||||
* @param fileName Name of contract with '.sol' extension.
|
||||
*/
|
||||
private async _compileContractAsync(sourceFileId: string): Promise<void> {
|
||||
if (_.isUndefined(this._contractSources)) {
|
||||
throw new Error('Contract sources not yet initialized');
|
||||
}
|
||||
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')}`;
|
||||
private async _compileContractAsync(contractName: string): Promise<void> {
|
||||
const contractSource = this._resolver.resolve(contractName);
|
||||
const currentArtifactIfExists = await getContractArtifactIfExistsAsync(this._artifactsDir, contractName);
|
||||
const sourceTreeHashHex = `0x${this._getSourceTreeHash(contractSource.path).toString('hex')}`;
|
||||
|
||||
let shouldCompile = false;
|
||||
if (_.isUndefined(currentArtifactIfExists)) {
|
||||
@@ -169,16 +111,14 @@ export class Compiler {
|
||||
const currentArtifact = currentArtifactIfExists as ContractArtifact;
|
||||
shouldCompile =
|
||||
currentArtifact.networks[this._networkId].optimizer_enabled !== this._optimizerEnabled ||
|
||||
currentArtifact.networks[this._networkId].source_tree_hash !== sourceTreeHash;
|
||||
currentArtifact.networks[this._networkId].source_tree_hash !== sourceTreeHashHex;
|
||||
}
|
||||
if (!shouldCompile) {
|
||||
return;
|
||||
}
|
||||
const solcVersionRange = parseSolidityVersionRange(contractSource.source);
|
||||
const availableCompilerVersions = _.keys(binPaths);
|
||||
const solcVersion = semver.maxSatisfying(
|
||||
availableCompilerVersions,
|
||||
contractSpecificSourceData.solcVersionRange,
|
||||
);
|
||||
const solcVersion = semver.maxSatisfying(availableCompilerVersions, solcVersionRange);
|
||||
const fullSolcVersion = binPaths[solcVersion];
|
||||
const compilerBinFilename = path.join(SOLC_BIN_DIR, fullSolcVersion);
|
||||
let solcjs: string;
|
||||
@@ -197,57 +137,77 @@ export class Compiler {
|
||||
}
|
||||
const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename));
|
||||
|
||||
logUtils.log(`Compiling ${sourceFileId} with Solidity v${solcVersion}...`);
|
||||
const source = this._contractSources[sourceFileId];
|
||||
const input = {
|
||||
[sourceFileId]: source,
|
||||
logUtils.log(`Compiling ${contractName} with Solidity v${solcVersion}...`);
|
||||
const source = contractSource.source;
|
||||
const absoluteFilePath = contractSource.path;
|
||||
const standardInput: solc.StandardInput = {
|
||||
language: 'Solidity',
|
||||
sources: {
|
||||
[absoluteFilePath]: {
|
||||
urls: [`file://${absoluteFilePath}`],
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: this._optimizerEnabled,
|
||||
},
|
||||
outputSelection: {
|
||||
'*': {
|
||||
'*': [
|
||||
'abi',
|
||||
'evm.bytecode.object',
|
||||
'evm.bytecode.sourceMap',
|
||||
'evm.deployedBytecode.object',
|
||||
'evm.deployedBytecode.sourceMap',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const sourcesToCompile = {
|
||||
sources: input,
|
||||
};
|
||||
|
||||
const compiled = solcInstance.compile(sourcesToCompile, Number(this._optimizerEnabled), importPath =>
|
||||
findImportIfExist(this._contractSources, sourceFileId, importPath),
|
||||
const compiled: solc.StandardOutput = JSON.parse(
|
||||
solcInstance.compileStandardWrapper(JSON.stringify(standardInput), importPath => {
|
||||
const sourceCodeIfExists = this._resolver.resolve(importPath);
|
||||
return { contents: sourceCodeIfExists.source };
|
||||
}),
|
||||
);
|
||||
|
||||
if (!_.isUndefined(compiled.errors)) {
|
||||
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);
|
||||
const SOLIDITY_WARNING = 'warning';
|
||||
const errors = _.filter(compiled.errors, entry => entry.severity !== SOLIDITY_WARNING);
|
||||
const warnings = _.filter(compiled.errors, entry => entry.severity === SOLIDITY_WARNING);
|
||||
if (!_.isEmpty(errors)) {
|
||||
errors.forEach(errMsg => {
|
||||
const normalizedErrMsg = getNormalizedErrMsg(errMsg);
|
||||
logUtils.log(normalizedErrMsg);
|
||||
errors.forEach(error => {
|
||||
const normalizedErrMsg = getNormalizedErrMsg(error.formattedMessage || error.message);
|
||||
logUtils.log(chalk.red(normalizedErrMsg));
|
||||
});
|
||||
process.exit(1);
|
||||
} else {
|
||||
warnings.forEach(errMsg => {
|
||||
const normalizedErrMsg = getNormalizedErrMsg(errMsg);
|
||||
logUtils.log(normalizedErrMsg);
|
||||
warnings.forEach(warning => {
|
||||
const normalizedWarningMsg = getNormalizedErrMsg(warning.formattedMessage || warning.message);
|
||||
logUtils.log(chalk.yellow(normalizedWarningMsg));
|
||||
});
|
||||
}
|
||||
}
|
||||
const contractName = path.basename(sourceFileId, constants.SOLIDITY_FILE_EXTENSION);
|
||||
const contractIdentifier = `${sourceFileId}:${contractName}`;
|
||||
if (_.isUndefined(compiled.contracts[contractIdentifier])) {
|
||||
const compiledData = compiled.contracts[absoluteFilePath][contractName];
|
||||
if (_.isUndefined(compiledData)) {
|
||||
throw new Error(
|
||||
`Contract ${contractName} not found in ${sourceFileId}. Please make sure your contract has the same name as it's file name`,
|
||||
`Contract ${contractName} not found in ${absoluteFilePath}. Please make sure your contract has the same name as it's file name`,
|
||||
);
|
||||
}
|
||||
const abi: ContractAbi = JSON.parse(compiled.contracts[contractIdentifier].interface);
|
||||
const bytecode = `0x${compiled.contracts[contractIdentifier].bytecode}`;
|
||||
const runtimeBytecode = `0x${compiled.contracts[contractIdentifier].runtimeBytecode}`;
|
||||
const sourceMap = compiled.contracts[contractIdentifier].srcmap;
|
||||
const sourceMapRuntime = compiled.contracts[contractIdentifier].srcmapRuntime;
|
||||
const sources = _.keys(compiled.sources);
|
||||
const abi: ContractAbi = compiledData.abi;
|
||||
const bytecode = `0x${compiledData.evm.bytecode.object}`;
|
||||
const runtimeBytecode = `0x${compiledData.evm.deployedBytecode.object}`;
|
||||
const sourceMap = compiledData.evm.bytecode.sourceMap;
|
||||
const sourceMapRuntime = compiledData.evm.deployedBytecode.sourceMap;
|
||||
const unresolvedSourcePaths = _.keys(compiled.sources);
|
||||
const sources = _.map(
|
||||
unresolvedSourcePaths,
|
||||
unresolvedSourcePath => this._resolver.resolve(unresolvedSourcePath).path,
|
||||
);
|
||||
const updated_at = Date.now();
|
||||
|
||||
const contractNetworkData: ContractNetworkData = {
|
||||
solc_version: solcVersion,
|
||||
keccak256: sourceHash,
|
||||
source_tree_hash: sourceTreeHash,
|
||||
source_tree_hash: sourceTreeHashHex,
|
||||
optimizer_enabled: this._optimizerEnabled,
|
||||
abi,
|
||||
bytecode,
|
||||
@@ -280,44 +240,22 @@ export class Compiler {
|
||||
const artifactString = utils.stringifyWithFormatting(newArtifact);
|
||||
const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`;
|
||||
await fsWrapper.writeFileAsync(currentArtifactPath, artifactString);
|
||||
logUtils.log(`${sourceFileId} artifact saved!`);
|
||||
logUtils.log(`${contractName} 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, fileId: string): void {
|
||||
if (!_.isUndefined(this._contractSourceDataByFileId[fileId])) {
|
||||
return;
|
||||
}
|
||||
const sourceHash = ethUtil.sha3(source);
|
||||
const solcVersionRange = parseSolidityVersionRange(source);
|
||||
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.
|
||||
*/
|
||||
private _getSourceTreeHash(fileName: string, sourceHash: Buffer, dependencies: string[]): Buffer {
|
||||
private _getSourceTreeHash(importPath: string): Buffer {
|
||||
const contractSource = this._resolver.resolve(importPath);
|
||||
const dependencies = parseDependencies(contractSource);
|
||||
const sourceHash = ethUtil.sha3(contractSource.source);
|
||||
if (dependencies.length === 0) {
|
||||
return sourceHash;
|
||||
} else {
|
||||
const dependencySourceTreeHashes = _.map(dependencies, dependency => {
|
||||
const source = this._contractSources[dependency];
|
||||
this._setContractSpecificSourceData(source, dependency);
|
||||
const sourceData = this._contractSourceDataByFileId[dependency];
|
||||
return this._getSourceTreeHash(dependency, sourceData.sourceHash, sourceData.dependencies);
|
||||
});
|
||||
const dependencySourceTreeHashes = _.map(dependencies, (dependency: string) =>
|
||||
this._getSourceTreeHash(dependency),
|
||||
);
|
||||
const sourceTreeHashesBuffer = Buffer.concat([sourceHash, ...dependencySourceTreeHashes]);
|
||||
const sourceTreeHash = ethUtil.sha3(sourceTreeHashesBuffer);
|
||||
return sourceTreeHash;
|
||||
|
@@ -38,17 +38,17 @@ export class Deployer {
|
||||
this._artifactsDir = opts.artifactsDir;
|
||||
this._networkId = opts.networkId;
|
||||
this._defaults = opts.defaults;
|
||||
let web3Provider: Provider;
|
||||
let provider: 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`);
|
||||
throw new Error(`Deployer options don't contain provider nor jsonrpcUrl. Please pass one of them`);
|
||||
}
|
||||
web3Provider = new Web3.providers.HttpProvider(jsonrpcUrl);
|
||||
provider = new Web3.providers.HttpProvider(jsonrpcUrl);
|
||||
} else {
|
||||
web3Provider = (opts as ProviderDeployerOptions).provider;
|
||||
provider = (opts as ProviderDeployerOptions).provider;
|
||||
}
|
||||
this.web3Wrapper = new Web3Wrapper(web3Provider, this._defaults);
|
||||
this.web3Wrapper = new Web3Wrapper(provider, this._defaults);
|
||||
}
|
||||
/**
|
||||
* Loads a contract's corresponding artifacts and deploys it with the supplied constructor arguments.
|
||||
@@ -170,7 +170,7 @@ export class Deployer {
|
||||
const contractArtifact: ContractArtifact = require(artifactPath);
|
||||
return contractArtifact;
|
||||
} catch (err) {
|
||||
throw new Error(`Artifact not found for contract: ${contractName}`);
|
||||
throw new Error(`Artifact not found for contract: ${contractName} at ${artifactPath}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@@ -15,4 +15,5 @@ export const binPaths: BinaryPaths = {
|
||||
'0.4.19': 'soljson-v0.4.19+commit.c4cbbb05.js',
|
||||
'0.4.20': 'soljson-v0.4.20+commit.3155dd80.js',
|
||||
'0.4.21': 'soljson-v0.4.21+commit.dfe3193c.js',
|
||||
'0.4.22': 'soljson-v0.4.22+commit.4cb486ee.js',
|
||||
};
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { AbiType, ContractAbi, MethodAbi } from '@0xproject/types';
|
||||
import { ContractSource, ContractSources } from '@0xproject/sol-resolver';
|
||||
import { logUtils } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
import * as path from 'path';
|
||||
@@ -6,60 +6,19 @@ import * as solc from 'solc';
|
||||
|
||||
import { constants } from './constants';
|
||||
import { fsWrapper } from './fs_wrapper';
|
||||
import { ContractArtifact, ContractSources, FunctionNameToSeenCount } from './types';
|
||||
import { ContractArtifact } 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.
|
||||
* @param fileName Name of contract file.
|
||||
* @param contractName Name of contract.
|
||||
* @return Contract data on network or undefined.
|
||||
*/
|
||||
export async function getContractArtifactIfExistsAsync(
|
||||
artifactsDir: string,
|
||||
fileName: string,
|
||||
contractName: string,
|
||||
): Promise<ContractArtifact | void> {
|
||||
let contractArtifact;
|
||||
const contractName = path.basename(fileName, constants.SOLIDITY_FILE_EXTENSION);
|
||||
const currentArtifactPath = `${artifactsDir}/${contractName}.json`;
|
||||
try {
|
||||
const opts = {
|
||||
@@ -69,7 +28,7 @@ export async function getContractArtifactIfExistsAsync(
|
||||
contractArtifact = JSON.parse(contractArtifactString);
|
||||
return contractArtifact;
|
||||
} catch (err) {
|
||||
logUtils.log(`Artifact for ${fileName} does not exist`);
|
||||
logUtils.log(`Artifact for ${contractName} does not exist`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -123,11 +82,11 @@ 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, sourceFileId: string): string[] {
|
||||
export function parseDependencies(contractSource: ContractSource): string[] {
|
||||
// TODO: Use a proper parser
|
||||
const source = contractSource.source;
|
||||
const IMPORT_REGEX = /(import\s)/;
|
||||
const DEPENDENCY_PATH_REGEX = /"([^"]+)"/; // Source: https://github.com/BlockChainCompany/soljitsu/blob/master/lib/shared.js
|
||||
const dependencies: string[] = [];
|
||||
@@ -136,35 +95,13 @@ export function parseDependencies(source: string, sourceFileId: string): string[
|
||||
if (!_.isNull(line.match(IMPORT_REGEX))) {
|
||||
const dependencyMatch = line.match(DEPENDENCY_PATH_REGEX);
|
||||
if (!_.isNull(dependencyMatch)) {
|
||||
const dependencyPath = dependencyMatch[1];
|
||||
const dependencyId = constructDependencyFileId(dependencyPath, sourceFileId);
|
||||
dependencies.push(dependencyId);
|
||||
let dependencyPath = dependencyMatch[1];
|
||||
if (dependencyPath.startsWith('.')) {
|
||||
dependencyPath = path.join(path.dirname(contractSource.path), dependencyPath);
|
||||
}
|
||||
dependencies.push(dependencyPath);
|
||||
}
|
||||
}
|
||||
});
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to resolve dependencies with `solc.compile`.
|
||||
* Throws error if contractSources not yet initialized.
|
||||
* @param contractSources Source codes of contracts.
|
||||
* @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,
|
||||
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 ${dependencyFileId}`);
|
||||
}
|
||||
const importContents: solc.ImportContents = {
|
||||
contents: source,
|
||||
};
|
||||
return importContents;
|
||||
}
|
||||
|
@@ -18,15 +18,9 @@ export interface ContractNetworks {
|
||||
[key: number]: ContractNetworkData;
|
||||
}
|
||||
|
||||
export interface ContractDirectory {
|
||||
path: string;
|
||||
namespace: string;
|
||||
}
|
||||
|
||||
export interface ContractNetworkData {
|
||||
solc_version: string;
|
||||
optimizer_enabled: boolean;
|
||||
keccak256: string;
|
||||
source_tree_hash: string;
|
||||
abi: ContractAbi;
|
||||
bytecode: string;
|
||||
@@ -45,7 +39,7 @@ export interface SolcErrors {
|
||||
|
||||
export interface CliOptions extends yargs.Arguments {
|
||||
artifactsDir: string;
|
||||
contractDirs: string;
|
||||
contractsDir: string;
|
||||
jsonrpcUrl: string;
|
||||
networkId: number;
|
||||
shouldOptimize: boolean;
|
||||
@@ -56,7 +50,7 @@ export interface CliOptions extends yargs.Arguments {
|
||||
}
|
||||
|
||||
export interface CompilerOptions {
|
||||
contractDirs: Set<ContractDirectory>;
|
||||
contractsDir: string;
|
||||
networkId: number;
|
||||
optimizerEnabled: boolean;
|
||||
artifactsDir: string;
|
||||
@@ -79,20 +73,11 @@ export interface UrlDeployerOptions extends BaseDeployerOptions {
|
||||
|
||||
export type DeployerOptions = UrlDeployerOptions | ProviderDeployerOptions;
|
||||
|
||||
export interface ContractSources {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
export interface ContractIdToSourceFileId {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
export interface ContractSourceDataByFileId {
|
||||
[key: string]: ContractSpecificSourceData;
|
||||
export interface ContractSourceData {
|
||||
[contractName: string]: ContractSpecificSourceData;
|
||||
}
|
||||
|
||||
export interface ContractSpecificSourceData {
|
||||
dependencies: string[];
|
||||
solcVersionRange: string;
|
||||
sourceHash: Buffer;
|
||||
sourceTreeHash: Buffer;
|
||||
@@ -107,8 +92,4 @@ export interface Token {
|
||||
swarmHash: string;
|
||||
}
|
||||
|
||||
export interface FunctionNameToSeenCount {
|
||||
[key: string]: number;
|
||||
}
|
||||
|
||||
export type DoneCallback = (err?: Error) => void;
|
||||
|
@@ -3,13 +3,7 @@ import 'mocha';
|
||||
|
||||
import { Compiler } from '../src/compiler';
|
||||
import { fsWrapper } from '../src/utils/fs_wrapper';
|
||||
import {
|
||||
CompilerOptions,
|
||||
ContractArtifact,
|
||||
ContractDirectory,
|
||||
ContractNetworkData,
|
||||
DoneCallback,
|
||||
} from '../src/utils/types';
|
||||
import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } from '../src/utils/types';
|
||||
|
||||
import { exchange_binary } from './fixtures/exchange_bin';
|
||||
import { constants } from './util/constants';
|
||||
@@ -19,15 +13,11 @@ const expect = chai.expect;
|
||||
describe('#Compiler', function() {
|
||||
this.timeout(constants.timeoutMs);
|
||||
const artifactsDir = `${__dirname}/fixtures/artifacts`;
|
||||
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 contractsDir = `${__dirname}/fixtures/contracts`;
|
||||
const exchangeArtifactPath = `${artifactsDir}/Exchange.json`;
|
||||
const compilerOpts: CompilerOptions = {
|
||||
artifactsDir,
|
||||
contractDirs,
|
||||
contractsDir,
|
||||
networkId: constants.networkId,
|
||||
optimizerEnabled: constants.optimizerEnabled,
|
||||
specifiedContracts: new Set(constants.specifiedContracts),
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import * as chai from 'chai';
|
||||
import * as dirtyChai from 'dirty-chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
|
||||
import {
|
||||
@@ -47,34 +48,36 @@ describe('Compiler utils', () => {
|
||||
});
|
||||
describe('#parseDependencies', () => {
|
||||
it('correctly parses Exchange dependencies', async () => {
|
||||
const exchangeSource = await fsWrapper.readFileAsync(`${__dirname}/fixtures/contracts/main/Exchange.sol`, {
|
||||
const path = `${__dirname}/fixtures/contracts/Exchange.sol`;
|
||||
const source = await fsWrapper.readFileAsync(path, {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
const sourceFileId = '/main/Exchange.sol';
|
||||
expect(parseDependencies(exchangeSource, sourceFileId)).to.be.deep.equal([
|
||||
'/main/TokenTransferProxy.sol',
|
||||
'/base/Token.sol',
|
||||
'/base/SafeMath.sol',
|
||||
]);
|
||||
const dependencies = parseDependencies({ source, path });
|
||||
const expectedDependencies = [
|
||||
'zeppelin-solidity/contracts/token/ERC20/ERC20.sol',
|
||||
'packages/deployer/lib/test/fixtures/contracts/TokenTransferProxy.sol',
|
||||
'packages/deployer/lib/test/fixtures/contracts/base/SafeMath.sol',
|
||||
];
|
||||
_.each(expectedDependencies, expectedDepdency => {
|
||||
const foundDependency = _.find(dependencies, dependency => _.endsWith(dependency, expectedDepdency));
|
||||
expect(foundDependency, `${expectedDepdency} not found`).to.not.be.undefined();
|
||||
});
|
||||
});
|
||||
it('correctly parses TokenTransferProxy dependencies', async () => {
|
||||
const exchangeSource = await fsWrapper.readFileAsync(
|
||||
`${__dirname}/fixtures/contracts/main/TokenTransferProxy.sol`,
|
||||
{
|
||||
encoding: 'utf8',
|
||||
},
|
||||
);
|
||||
const sourceFileId = '/main/TokenTransferProxy.sol';
|
||||
expect(parseDependencies(exchangeSource, sourceFileId)).to.be.deep.equal([
|
||||
'/base/Token.sol',
|
||||
'/base/Ownable.sol',
|
||||
const path = `${__dirname}/fixtures/contracts/TokenTransferProxy.sol`;
|
||||
const source = await fsWrapper.readFileAsync(path, {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
expect(parseDependencies({ source, path })).to.be.deep.equal([
|
||||
'zeppelin-solidity/contracts/ownership/Ownable.sol',
|
||||
'zeppelin-solidity/contracts/token/ERC20/ERC20.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";`;
|
||||
const sourceFileId = '/main/TokenTransferProxy.sol';
|
||||
expect(parseDependencies(contractWithCommentedOutDependencies, sourceFileId)).to.be.deep.equal([]);
|
||||
const path = '';
|
||||
const source = `// import "./TokenTransferProxy.sol";`;
|
||||
expect(parseDependencies({ path, source })).to.be.deep.equal([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -4,30 +4,21 @@ import 'mocha';
|
||||
import { Compiler } from '../src/compiler';
|
||||
import { Deployer } from '../src/deployer';
|
||||
import { fsWrapper } from '../src/utils/fs_wrapper';
|
||||
import {
|
||||
CompilerOptions,
|
||||
ContractArtifact,
|
||||
ContractDirectory,
|
||||
ContractNetworkData,
|
||||
DoneCallback,
|
||||
} from '../src/utils/types';
|
||||
import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } from '../src/utils/types';
|
||||
|
||||
import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
|
||||
import { constants } from './util/constants';
|
||||
import { provider } from './util/provider';
|
||||
|
||||
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,
|
||||
contractDirs,
|
||||
contractsDir,
|
||||
networkId: constants.networkId,
|
||||
optimizerEnabled: constants.optimizerEnabled,
|
||||
specifiedContracts: new Set(constants.specifiedContracts),
|
||||
@@ -36,7 +27,7 @@ describe('#Deployer', () => {
|
||||
const deployerOpts = {
|
||||
artifactsDir,
|
||||
networkId: constants.networkId,
|
||||
jsonrpcUrl: constants.jsonrpcUrl,
|
||||
provider,
|
||||
defaults: {
|
||||
gasPrice: constants.gasPrice,
|
||||
},
|
||||
|
@@ -16,11 +16,12 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.4.14;
|
||||
pragma solidity ^0.4.14;
|
||||
|
||||
import {ERC20 as Token} from "zeppelin-solidity/contracts/token/ERC20/ERC20.sol";
|
||||
|
||||
import "./TokenTransferProxy.sol";
|
||||
import "/base/Token.sol";
|
||||
import "/base/SafeMath.sol";
|
||||
import "./base/SafeMath.sol";
|
||||
|
||||
/// @title Exchange - Facilitates exchange of ERC20 tokens.
|
||||
/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
|
@@ -16,10 +16,10 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.4.14;
|
||||
pragma solidity ^0.4.14;
|
||||
|
||||
import "/base/Token.sol";
|
||||
import "/base/Ownable.sol";
|
||||
import { Ownable } from "zeppelin-solidity/contracts/ownership/Ownable.sol";
|
||||
import { ERC20 as Token } from "zeppelin-solidity/contracts/token/ERC20/ERC20.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>
|
@@ -1,27 +0,0 @@
|
||||
pragma solidity 0.4.14;
|
||||
|
||||
/*
|
||||
* Ownable
|
||||
*
|
||||
* Base contract with an owner.
|
||||
* Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
|
||||
*/
|
||||
|
||||
contract Ownable {
|
||||
address public owner;
|
||||
|
||||
function Ownable() {
|
||||
owner = msg.sender;
|
||||
}
|
||||
|
||||
modifier onlyOwner() {
|
||||
require(msg.sender == owner);
|
||||
_;
|
||||
}
|
||||
|
||||
function transferOwnership(address newOwner) onlyOwner {
|
||||
if (newOwner != address(0)) {
|
||||
owner = newOwner;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
pragma solidity 0.4.14;
|
||||
pragma solidity ^0.4.14;
|
||||
|
||||
contract SafeMath {
|
||||
function safeMul(uint a, uint b) internal constant returns (uint256) {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
pragma solidity 0.4.14;
|
||||
pragma solidity ^0.4.14;
|
||||
|
||||
contract Token {
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@@ -2,7 +2,6 @@ import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
export const constants = {
|
||||
networkId: 0,
|
||||
jsonrpcUrl: 'http://localhost:8545',
|
||||
optimizerEnabled: false,
|
||||
gasPrice: new BigNumber(20000000000),
|
||||
timeoutMs: 30000,
|
||||
|
9
packages/deployer/test/util/provider.ts
Normal file
9
packages/deployer/test/util/provider.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { web3Factory } from '@0xproject/dev-utils';
|
||||
import { Provider } from '@0xproject/types';
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
const providerConfigs = { shouldUseInProcessGanache: true };
|
||||
const web3Instance = web3Factory.create(providerConfigs);
|
||||
const provider: Provider = web3Instance.currentProvider;
|
||||
|
||||
export { provider };
|
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"version": "0.3.6",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Allow an rpcURL to be set in Web3Config (for testnet RPC endpoints)",
|
||||
"pr": 524
|
||||
}
|
||||
],
|
||||
"timestamp": 1524044013
|
||||
},
|
||||
{
|
||||
"timestamp": 1523462196,
|
||||
"version": "0.3.5",
|
||||
@@ -33,7 +43,7 @@
|
||||
"note": "Reduce npm package size by adding an `.npmignore` file."
|
||||
},
|
||||
{
|
||||
"note": "Move `@0xproject/web3_wrapper` to dependencies from devDependencies."
|
||||
"note": "Move `@0xproject/web3-wrapper` to dependencies from devDependencies."
|
||||
}
|
||||
],
|
||||
"timestamp": 1521298800
|
||||
|
@@ -5,7 +5,11 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.3.5 - _April 11, 2018_
|
||||
## v0.3.6 - _April 18, 2018_
|
||||
|
||||
* Allow an rpcURL to be set in Web3Config (for testnet RPC endpoints) (#524)
|
||||
|
||||
## v0.3.5 - _April 12, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
@@ -17,25 +21,25 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.1 - _March 17, 2018_
|
||||
## v0.3.1 - _March 18, 2018_
|
||||
|
||||
* Reduce npm package size by adding an `.npmignore` file.
|
||||
* Move `@0xproject/web3_wrapper` to dependencies from devDependencies.
|
||||
* Move `@0xproject/web3-wrapper` to dependencies from devDependencies.
|
||||
|
||||
## v0.3.0 - _March 17, 2018_
|
||||
## v0.3.0 - _March 18, 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 15, 2018_
|
||||
## v0.2.0 - _February 16, 2018_
|
||||
|
||||
* Remove subproviders (#392)
|
||||
|
||||
## v0.0.12 - _February 8, 2018_
|
||||
## v0.0.12 - _February 9, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.0.11 - _February 6, 2018_
|
||||
## v0.0.11 - _February 7, 2018_
|
||||
|
||||
* Updated `types-ethereumjs-util` dev dependency (#352)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/dev-utils",
|
||||
"version": "0.3.4",
|
||||
"version": "0.3.5",
|
||||
"description": "0x dev TS utils",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
@@ -26,8 +26,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/dev-utils/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"chai": "^4.0.1",
|
||||
@@ -40,11 +40,11 @@
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@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",
|
||||
"@0xproject/sol-cov": "^0.0.7",
|
||||
"@0xproject/subproviders": "^0.8.5",
|
||||
"@0xproject/types": "^0.6.0",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/web3-wrapper": "^0.6.0",
|
||||
"lodash": "^4.17.4",
|
||||
"web3": "^0.20.0",
|
||||
"web3-provider-engine": "^13.0.1"
|
||||
|
@@ -13,8 +13,8 @@ export const coverage = {
|
||||
return coverageSubprovider;
|
||||
},
|
||||
_getCoverageSubprovider(): CoverageSubprovider {
|
||||
const artifactsPath = './src/artifacts';
|
||||
const contractsPath = './src/contracts';
|
||||
const artifactsPath = '../migrations/src/artifacts';
|
||||
const contractsPath = 'src/contracts';
|
||||
const networkId = 50;
|
||||
const defaultFromAddress = constants.TESTRPC_FIRST_ADDRESS;
|
||||
return new CoverageSubprovider(artifactsPath, contractsPath, networkId, defaultFromAddress);
|
||||
|
@@ -26,6 +26,7 @@ import * as Web3 from 'web3';
|
||||
export interface Web3Config {
|
||||
hasAddresses?: boolean; // default: true
|
||||
shouldUseInProcessGanache?: boolean; // default: false
|
||||
rpcUrl?: string; // default: localhost:8545
|
||||
}
|
||||
|
||||
export const web3Factory = {
|
||||
@@ -53,6 +54,9 @@ export const web3Factory = {
|
||||
};
|
||||
const shouldUseInProcessGanache = !!config.shouldUseInProcessGanache;
|
||||
if (shouldUseInProcessGanache) {
|
||||
if (!_.isUndefined(config.rpcUrl)) {
|
||||
throw new Error('Cannot use both GanacheSubrovider and RPCSubprovider');
|
||||
}
|
||||
provider.addProvider(
|
||||
new GanacheSubprovider({
|
||||
logger,
|
||||
@@ -65,7 +69,7 @@ export const web3Factory = {
|
||||
} else {
|
||||
provider.addProvider(
|
||||
new RpcSubprovider({
|
||||
rpcUrl: constants.RPC_URL,
|
||||
rpcUrl: config.rpcUrl || constants.RPC_URL,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@@ -8,8 +8,8 @@ import { BlockchainLifecycle, web3Factory } from '../src';
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('BlockchainLifecycle tests', () => {
|
||||
const web3Provider = web3Factory.getRpcProvider();
|
||||
const web3Wrapper = new Web3Wrapper(web3Provider);
|
||||
const provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
describe('#startAsync/revertAsync', () => {
|
||||
it('reverts changes in between', async () => {
|
||||
|
@@ -8,8 +8,8 @@ import { web3Factory } from '../src';
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('RPC tests', () => {
|
||||
const web3Provider = web3Factory.getRpcProvider();
|
||||
const web3Wrapper = new Web3Wrapper(web3Provider);
|
||||
const provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
describe('#mineBlockAsync', () => {
|
||||
it('increases block number when called', async () => {
|
||||
const blockNumberBefore = await web3Wrapper.getBlockNumberAsync();
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1524044013,
|
||||
"version": "0.7.21",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1523462196,
|
||||
"version": "0.7.20",
|
||||
|
@@ -5,7 +5,11 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.7.20 - _April 11, 2018_
|
||||
## v0.7.21 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.7.20 - _April 12, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
@@ -17,14 +21,14 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.7.13 - _February 8, 2018_
|
||||
## v0.7.13 - _February 9, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.7.0 - _December 19, 2017_
|
||||
## v0.7.0 - _December 20, 2017_
|
||||
|
||||
* Rename `subscriptionOptsSchema` to `blockRangeSchema` (#272)
|
||||
|
||||
## v0.6.7 - _November 13, 2017_
|
||||
## v0.6.7 - _November 14, 2017_
|
||||
|
||||
* Re-publish JSON-schema previously published under NPM package 0x-json-schemas
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/json-schemas",
|
||||
"version": "0.7.19",
|
||||
"version": "0.7.20",
|
||||
"description": "0x-related json schemas",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
@@ -11,7 +11,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",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js --exit",
|
||||
"clean": "shx rm -rf lib test_temp scripts",
|
||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
|
||||
@@ -42,14 +42,15 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/typescript-typings": "^0.0.3",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@types/node": "^8.0.53",
|
||||
"jsonschema": "^1.2.0",
|
||||
"lodash.values": "^4.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.16",
|
||||
"@0xproject/tslint-config": "^0.4.14",
|
||||
"@0xproject/utils": "^0.5.0",
|
||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@0xproject/utils": "^0.5.1",
|
||||
"@types/lodash.foreach": "^4.5.3",
|
||||
"@types/lodash.values": "^4.3.3",
|
||||
"@types/mocha": "^2.2.42",
|
||||
|
@@ -1,169 +0,0 @@
|
||||
{
|
||||
"contract_name": "Metacoin",
|
||||
"networks": {
|
||||
"50": {
|
||||
"solc_version": "0.4.21",
|
||||
"keccak256": "0x85fb29ea6c21adcf07f754b2ad06482dd6fcd62d31935e36041b4d064c6a038e",
|
||||
"source_tree_hash": "0x85fb29ea6c21adcf07f754b2ad06482dd6fcd62d31935e36041b4d064c6a038e",
|
||||
"optimizer_enabled": false,
|
||||
"abi": [
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferData",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"name": "callback",
|
||||
"type": "uint32"
|
||||
}
|
||||
],
|
||||
"name": "nestedTransferData",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"name": "transfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "int256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balances",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferData",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"name": "transfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "success",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferData",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"name": "callback",
|
||||
"type": "uint32"
|
||||
}
|
||||
],
|
||||
"name": "transfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "int256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x6060604052341561000f57600080fd5b6127106000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610613806100636000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063135cfdb11461006757806327e235e31461009d5780632bd14bb9146100d35780632f8086ba14610109575b600080fd5b341561007257600080fd5b6100876004610082903690610446565b61013f565b604051610094919061051c565b60405180910390f35b34156100a857600080fd5b6100bd60046100b890369061041d565b61015a565b6040516100ca9190610537565b60405180910390f35b34156100de57600080fd5b6100f360046100ee90369061046f565b610172565b6040516101009190610501565b60405180910390f35b341561011457600080fd5b6101296004610124903690610498565b6102e2565b604051610136919061051c565b60405180910390f35b6000610153826000015183602001516102e2565b9050919050565b60006020528060005260406000206000915090505481565b600081602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156101c757600090506102dd565b81602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508160200151600080846000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84602001516040516102d09190610537565b60405180910390a3600190505b919050565b60006102ed83610172565b508163ffffffff16905092915050565b6000610309823561059f565b905092915050565b60006060828403121561032357600080fd5b61032d6040610552565b9050600061033d8482850161035d565b600083015250604061035184828501610409565b60208301525092915050565b60006040828403121561036f57600080fd5b6103796040610552565b90506000610389848285016102fd565b600083015250602061039d848285016103f5565b60208301525092915050565b6000604082840312156103bb57600080fd5b6103c56040610552565b905060006103d5848285016102fd565b60008301525060206103e9848285016103f5565b60208301525092915050565b600061040182356105bf565b905092915050565b600061041582356105c9565b905092915050565b60006020828403121561042f57600080fd5b600061043d848285016102fd565b91505092915050565b60006060828403121561045857600080fd5b600061046684828501610311565b91505092915050565b60006040828403121561048157600080fd5b600061048f848285016103a9565b91505092915050565b600080606083850312156104ab57600080fd5b60006104b9858286016103a9565b92505060406104ca85828601610409565b9150509250929050565b6104dd8161057f565b82525050565b6104ec8161058b565b82525050565b6104fb81610595565b82525050565b600060208201905061051660008301846104d4565b92915050565b600060208201905061053160008301846104e3565b92915050565b600060208201905061054c60008301846104f2565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561057557600080fd5b8060405250919050565b60008115159050919050565b6000819050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600063ffffffff821690509190505600a265627a7a72305820716a74dd7e2a73c237481496756750895b57977fc4876b1c48aef9b71759bf836c6578706572696d656e74616cf50037",
|
||||
"runtime_bytecode": "0x606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063135cfdb11461006757806327e235e31461009d5780632bd14bb9146100d35780632f8086ba14610109575b600080fd5b341561007257600080fd5b6100876004610082903690610446565b61013f565b604051610094919061051c565b60405180910390f35b34156100a857600080fd5b6100bd60046100b890369061041d565b61015a565b6040516100ca9190610537565b60405180910390f35b34156100de57600080fd5b6100f360046100ee90369061046f565b610172565b6040516101009190610501565b60405180910390f35b341561011457600080fd5b6101296004610124903690610498565b6102e2565b604051610136919061051c565b60405180910390f35b6000610153826000015183602001516102e2565b9050919050565b60006020528060005260406000206000915090505481565b600081602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156101c757600090506102dd565b81602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508160200151600080846000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84602001516040516102d09190610537565b60405180910390a3600190505b919050565b60006102ed83610172565b508163ffffffff16905092915050565b6000610309823561059f565b905092915050565b60006060828403121561032357600080fd5b61032d6040610552565b9050600061033d8482850161035d565b600083015250604061035184828501610409565b60208301525092915050565b60006040828403121561036f57600080fd5b6103796040610552565b90506000610389848285016102fd565b600083015250602061039d848285016103f5565b60208301525092915050565b6000604082840312156103bb57600080fd5b6103c56040610552565b905060006103d5848285016102fd565b60008301525060206103e9848285016103f5565b60208301525092915050565b600061040182356105bf565b905092915050565b600061041582356105c9565b905092915050565b60006020828403121561042f57600080fd5b600061043d848285016102fd565b91505092915050565b60006060828403121561045857600080fd5b600061046684828501610311565b91505092915050565b60006040828403121561048157600080fd5b600061048f848285016103a9565b91505092915050565b600080606083850312156104ab57600080fd5b60006104b9858286016103a9565b92505060406104ca85828601610409565b9150509250929050565b6104dd8161057f565b82525050565b6104ec8161058b565b82525050565b6104fb81610595565b82525050565b600060208201905061051660008301846104d4565b92915050565b600060208201905061053160008301846104e3565b92915050565b600060208201905061054c60008301846104f2565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561057557600080fd5b8060405250919050565b60008115159050919050565b6000819050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600063ffffffff821690509190505600a265627a7a72305820716a74dd7e2a73c237481496756750895b57977fc4876b1c48aef9b71759bf836c6578706572696d656e74616cf50037",
|
||||
"updated_at": 1522966321930,
|
||||
"source_map": "60:1093:0:-;;;389:72;;;;;;;;449:5;426:8;:20;435:10;426:20;;;;;;;;;;;;;;;:28;;;;60:1093;;;;;;",
|
||||
"source_map_runtime": "60:1093:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;978:172;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;84:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;467:352;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;825:147;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;978:172;1051:3;1073:70;1082:18;:31;;;1115:18;:27;;;1073:8;:70::i;:::-;1066:77;;978:172;;;:::o;84:41::-;;;;;;;;;;;;;;;;;:::o;467:352::-;528:12;579;:19;;;556:8;:20;565:10;556:20;;;;;;;;;;;;;;;;:42;552:60;;;607:5;600:12;;;;552:60;646:12;:19;;;622:8;:20;631:10;622:20;;;;;;;;;;;;;;;;:43;;;;;;;;;;;704:12;:19;;;675:8;:25;684:12;:15;;;675:25;;;;;;;;;;;;;;;;:48;;;;;;;;;;;754:12;:15;;;733:58;;742:10;733:58;;;771:12;:19;;;733:58;;;;;;;;;;;;;;;808:4;801:11;;467:352;;;;:::o;825:147::-;903:3;918:22;927:12;918:8;:22::i;:::-;;957:8;950:15;;;;825:147;;;;:::o;5:118:-1:-;;72:46;110:6;97:20;72:46;;;63:55;;57:66;;;;;171:510;;294:4;282:9;277:3;273:19;269:30;266:2;;;312:1;309;302:12;266:2;330:20;345:4;330:20;;;321:29;;408:1;439:73;508:3;499:6;488:9;484:22;439:73;;;433:3;426:5;422:15;415:98;360:164;578:2;611:48;655:3;646:6;635:9;631:22;611:48;;;604:4;597:5;593:16;586:74;534:137;260:421;;;;;723:465;;836:4;824:9;819:3;815:19;811:30;808:2;;;854:1;851;844:12;808:2;872:20;887:4;872:20;;;863:29;;940:1;971:49;1016:3;1007:6;996:9;992:22;971:49;;;965:3;958:5;954:15;947:74;902:130;1084:2;1117:49;1162:3;1153:6;1142:9;1138:22;1117:49;;;1110:4;1103:5;1099:16;1092:75;1042:136;802:386;;;;;1230:469;;1347:4;1335:9;1330:3;1326:19;1322:30;1319:2;;;1365:1;1362;1355:12;1319:2;1383:20;1398:4;1383:20;;;1374:29;;1451:1;1482:49;1527:3;1518:6;1507:9;1503:22;1482:49;;;1476:3;1469:5;1465:15;1458:74;1413:130;1595:2;1628:49;1673:3;1664:6;1653:9;1649:22;1628:49;;;1621:4;1614:5;1610:16;1603:75;1553:136;1313:386;;;;;1706:118;;1773:46;1811:6;1798:20;1773:46;;;1764:55;;1758:66;;;;;1831:116;;1897:45;1934:6;1921:20;1897:45;;;1888:54;;1882:65;;;;;1954:241;;2058:2;2046:9;2037:7;2033:23;2029:32;2026:2;;;2074:1;2071;2064:12;2026:2;2109:1;2126:53;2171:7;2162:6;2151:9;2147:22;2126:53;;;2116:63;;2088:97;2020:175;;;;;2202:309;;2340:2;2328:9;2319:7;2315:23;2311:32;2308:2;;;2356:1;2353;2346:12;2308:2;2391:1;2408:87;2487:7;2478:6;2467:9;2463:22;2408:87;;;2398:97;;2370:131;2302:209;;;;;2518:297;;2650:2;2638:9;2629:7;2625:23;2621:32;2618:2;;;2666:1;2663;2656:12;2618:2;2701:1;2718:81;2791:7;2782:6;2771:9;2767:22;2718:81;;;2708:91;;2680:125;2612:203;;;;;2822:420;;;2970:2;2958:9;2949:7;2945:23;2941:32;2938:2;;;2986:1;2983;2976:12;2938:2;3021:1;3038:81;3111:7;3102:6;3091:9;3087:22;3038:81;;;3028:91;;3000:125;3156:2;3174:52;3218:7;3209:6;3198:9;3194:22;3174:52;;;3164:62;;3135:97;2932:310;;;;;;3249:101;3316:28;3338:5;3316:28;;;3311:3;3304:41;3298:52;;;3357:107;3428:30;3452:5;3428:30;;;3423:3;3416:43;3410:54;;;3471:110;3544:31;3569:5;3544:31;;;3539:3;3532:44;3526:55;;;3588:181;;3690:2;3679:9;3675:18;3667:26;;3704:55;3756:1;3745:9;3741:17;3732:6;3704:55;;;3661:108;;;;;3776:189;;3882:2;3871:9;3867:18;3859:26;;3896:59;3952:1;3941:9;3937:17;3928:6;3896:59;;;3853:112;;;;;3972:193;;4080:2;4069:9;4065:18;4057:26;;4094:61;4152:1;4141:9;4137:17;4128:6;4094:61;;;4051:114;;;;;4172:256;;4234:2;4228:9;4218:19;;4272:4;4264:6;4260:17;4371:6;4359:10;4356:22;4335:18;4323:10;4320:34;4317:62;4314:2;;;4392:1;4389;4382:12;4314:2;4412:10;4408:2;4401:22;4212:216;;;;;4435:92;;4515:5;4508:13;4501:21;4490:32;;4484:43;;;;4534:78;;4602:5;4591:16;;4585:27;;;;4619:79;;4688:5;4677:16;;4671:27;;;;4705:128;;4785:42;4778:5;4774:54;4763:65;;4757:76;;;;4840:79;;4909:5;4898:16;;4892:27;;;;4926:95;;5005:10;4998:5;4994:22;4983:33;;4977:44;;;",
|
||||
"sources": [
|
||||
"/Metacoin.sol"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user