Compare commits

...

142 Commits

Author SHA1 Message Date
Fabio Berger
ac14dd2b29 Publish
- 0x.js@1.0.7
 - @0xproject/abi-gen@1.0.12
 - @0xproject/assert@1.0.12
 - @0xproject/asset-buyer@1.0.2
 - @0xproject/base-contract@3.0.0
 - @0xproject/connect@3.0.0
 - @0xproject/contract-wrappers@2.0.1
 - contracts@2.1.48
 - @0xproject/dev-utils@1.0.11
 - ethereum-types@1.0.9
 - @0xproject/fill-scenarios@1.0.6
 - @0xproject/json-schemas@1.0.5
 - @0xproject/metacoin@0.0.22
 - @0xproject/migrations@1.0.13
 - @0xproject/monorepo-scripts@1.0.10
 - @0xproject/order-utils@1.0.6
 - @0xproject/order-watcher@2.1.0
 - @0xproject/react-docs@1.0.12
 - @0xproject/react-shared@1.0.13
 - @0xproject/sol-compiler@1.1.6
 - @0xproject/sol-cov@2.1.6
 - @0xproject/sol-doc@1.0.1
 - @0xproject/sol-resolver@1.0.12
 - @0xproject/sra-report@1.0.12
 - @0xproject/sra-spec@1.0.5
 - @0xproject/subproviders@2.0.6
 - @0xproject/testnet-faucets@1.0.50
 - @0xproject/types@1.1.2
 - @0xproject/typescript-typings@3.0.0
 - @0xproject/utils@2.0.0
 - @0xproject/web3-wrapper@3.0.2
 - @0xproject/website@0.0.53
2018-09-28 19:16:07 +01:00
Fabio Berger
c354129b6f Updated CHANGELOGS 2018-09-28 19:15:38 +01:00
Fabio Berger
c7e26cd448 Un-nest the interface to fix the doc rendering 2018-09-28 18:59:28 +01:00
Jacob Evans
a737cfa004 Merge pull request #1090 from 0xProject/bug/contract-wrappers/handle-revert-with-reason
[contract-wrappers] Test revert with reason when decoding call result
2018-09-28 00:21:15 +00:00
Jacob Evans
21f6072186 Handle revert with reason when decoding call result
We use in-process ganache which throws on an RPC error. This means all of our tests get a nice revert error thrown when testing against ganache. This is not possible with RPC providers and a revert with reason result is returned. Our callAsync doesn't handle this and attempts to decode the revert with reason error log as a successful log, which results in an error while decoding.

This only works with our fork of ethers https://github.com/ethers-io/ethers.js/pull/188 and will need to be re-worked when updating to Ethers.js 4
2018-09-28 09:59:58 +10:00
Alex Browne
94badedad4 Remove yarn postinstall hack (#1098) 2018-09-27 15:34:01 -07:00
Leonid Logvinov
bf3795d2ac Merge pull request #1097 from 0xProject/feature/export-expiration-watcher
Export ExpirationWatcher from OrderWatcher
2018-09-27 12:53:36 +02:00
Leonid Logvinov
bc48bc99c3 Add PR number 2018-09-27 12:53:05 +02:00
Leonid Logvinov
51bfd1ca5e Export ExpirationWatcher from OrderWatcher 2018-09-27 12:48:48 +02:00
Leonid Logvinov
9160cd4983 Merge pull request #1069 from 0xProject/feature/ts-ethers
Upgrade to TS version of ethers
2018-09-27 12:47:00 +02:00
Leonid Logvinov
63d79faa85 Fix linter errors 2018-09-27 11:51:11 +02:00
Fabio Berger
70e412e375 Merge pull request #1096 from 0xProject/fixIsValidECSignature
Add address normalization to isValidECSignature method
2018-09-27 10:29:18 +01:00
Leonid Logvinov
a51919db0e Remove ethers.js carret as it's a beta version 2018-09-27 11:24:03 +02:00
Leonid Logvinov
60971be35a Throw revert reasons from contract wrappers 2018-09-27 11:21:47 +02:00
Leonid Logvinov
cb99ebf78a Throw revert reasons from contract wrappers 2018-09-27 11:21:39 +02:00
Fabio Berger
6f02a3f40d Fix PR nr 2018-09-27 10:05:04 +01:00
Fabio Berger
0591f1d32a Add address normalization to isValidECSignature method 2018-09-27 10:03:54 +01:00
Fabio Berger
1402119c84 Remove RC version warnings 2018-09-26 22:48:30 +01:00
Francesco Agosti
a162281529 Merge pull request #1094 from 0xProject/feature/website/coinbase-wallet-portal-fixes-and-clay-title
[website] Use coinbase wallet instead of Toshi, fix portal layout, update Clay's title
2018-09-26 18:20:06 +02:00
F. Eugene Aumson
8c18a8fefc Merge pull request #1093 from feuGeneA/sol-doc-fixes
[sol-doc] fixes
2018-09-26 12:16:33 -04:00
fragosti
48f6452c3b remove items-center classname 2018-09-26 17:58:48 +02:00
fragosti
bd002caadd Change clay to Ecosystem Development Lead 2018-09-26 17:56:09 +02:00
fragosti
d6090921a8 Update everything to Coinbase Wallet instead of Toshi 2018-09-26 17:55:40 +02:00
Francesco Agosti
78a693e092 Merge pull request #1088 from 0xProject/fix/website/relayers-column
[website] When number of relayers is less than number of columns, reduce column…
2018-09-26 17:40:12 +02:00
F. Eugene Aumson
3f61d27656 fix: add bin file for sol-doc cli 2018-09-26 11:28:53 -04:00
F. Eugene Aumson
30525d15f4 Merge pull request #1004 from feuGeneA/sol-doc
[ethereum-types, react-docs, sol-compiler, sol-doc, types, typescript-typings, website] Add new Solidity documentation generation utility
2018-09-26 10:15:53 -04:00
Francesco Agosti
c429409ed7 Merge pull request #1091 from 0xProject/feature/sra-spec/order-config-to-post-and-other-bugs
[connect][sra-spec] Update sra-spec and connect to have /order_config be a POST and other small improvements
2018-09-26 15:34:26 +02:00
F. Eugene Aumson
2bdaa58d71 fix: use latest versions of @0xproject packages 2018-09-26 09:22:06 -04:00
F. Eugene Aumson
75826fd559 Merge remote-tracking branch 'upstream/development' into sol-doc 2018-09-26 09:19:02 -04:00
F. Eugene Aumson
0ce6f03ed5 fix: disable tslint max-file-line-count...
before, tslint was saying "ERROR:
/home/gene/0x-monorepo/packages/types/src/index.ts[598, 2]: This file
has 599 lines, which exceeds the maximum of 500 lines allowed. Consider
breaking this file up into smaller parts."

https://github.com/0xProject/0x-monorepo/pull/1004#issuecomment-424704651
https://github.com/0xProject/0x-monorepo/pull/1004
2018-09-26 09:14:28 -04:00
Leonid Logvinov
5d73eebf6a Merge branch 'development' into feature/ts-ethers 2018-09-26 14:55:52 +02:00
Fabio Berger
13aa98f0f3 Merge pull request #1092 from 0xProject/addFlagToPublishReleases
Add Flag to publish releases command-line tool
2018-09-26 13:50:08 +01:00
Fabio Berger
4a94f8b1ca Merge branch 'development' into addFlagToPublishReleases
* development:
  Add weijie and rahul
  Change news link
2018-09-26 13:18:20 +01:00
Fabio Berger
f8532b3f51 Typo 2018-09-26 13:15:42 +01:00
Fabio Berger
b244f3e2c0 Merge branch 'development' of github.com:0xProject/0x-monorepo into development
* 'development' of github.com:0xProject/0x-monorepo:
  Add weijie and rahul
  Change news link
2018-09-26 13:14:23 +01:00
Fabio Berger
f33ecfd2fc Support passing in package names into publish_release_notes command-line for when publishing must be done manually 2018-09-26 13:11:12 +01:00
fragosti
f15751d800 Add to changelog 2018-09-26 14:06:53 +02:00
fragosti
e5e439adb9 Change /order_config endpoint to POST 2018-09-26 14:01:51 +02:00
fragosti
2d8f423cee Update examples 2018-09-26 13:57:41 +02:00
fragosti
5905fdb73b Fix erroneous ERC721 proxy id 2018-09-26 13:22:39 +02:00
fragosti
4ed9323804 Fix development flow 2018-09-26 13:19:01 +02:00
Francesco Agosti
d77c6e13b0 Merge pull request #1089 from 0xProject/feature/website/new-hires-sept-v2-announcement
[website] new hires and 0x v2 news link
2018-09-25 23:04:12 +02:00
fragosti
4e10f2c6f2 Merge branch 'development' of https://github.com/0xProject/0x-monorepo into feature/website/new-hires-sept-v2-announcement 2018-09-25 23:02:33 +02:00
F. Eugene Aumson
d3edb9721c Merge remote-tracking branch 'upstream/development' into sol-doc 2018-09-25 16:34:44 -04:00
Fabio Berger
1b35a6e3b5 Publish
- 0x.js@1.0.6
 - @0xproject/abi-gen@1.0.11
 - @0xproject/assert@1.0.11
 - @0xproject/asset-buyer@1.0.1
 - @0xproject/base-contract@2.0.5
 - @0xproject/connect@2.0.4
 - @0xproject/contract-wrappers@2.0.0
 - contracts@2.1.47
 - @0xproject/dev-utils@1.0.10
 - ethereum-types@1.0.8
 - @0xproject/fill-scenarios@1.0.5
 - @0xproject/json-schemas@1.0.4
 - @0xproject/metacoin@0.0.21
 - @0xproject/migrations@1.0.12
 - @0xproject/order-utils@1.0.5
 - @0xproject/order-watcher@2.0.0
 - @0xproject/react-docs@1.0.11
 - @0xproject/react-shared@1.0.12
 - @0xproject/sol-compiler@1.1.5
 - @0xproject/sol-cov@2.1.5
 - @0xproject/sol-resolver@1.0.11
 - @0xproject/sra-report@1.0.11
 - @0xproject/sra-spec@1.0.4
 - @0xproject/subproviders@2.0.5
 - @0xproject/testnet-faucets@1.0.49
 - @0xproject/types@1.1.1
 - @0xproject/typescript-typings@2.0.2
 - @0xproject/utils@1.0.11
 - @0xproject/web3-wrapper@3.0.1
 - @0xproject/website@0.0.52
2018-09-25 21:34:14 +01:00
Fabio Berger
900a8aee76 Updated CHANGELOGS 2018-09-25 21:33:55 +01:00
F. Eugene Aumson
de9f5d350f fix: call out a HACK in comments
https://github.com/0xProject/0x-monorepo/pull/1004#discussion_r220010054
https://github.com/0xProject/0x-monorepo/pull/1004
2018-09-25 16:31:40 -04:00
F. Eugene Aumson
e45f0b0eaf fix: update smart contract doc intros
https://github.com/0xProject/0x-monorepo/pull/1004#discussion_r220009790
https://github.com/0xProject/0x-monorepo/pull/1004#discussion_r220009909
https://github.com/0xProject/0x-monorepo/pull/1004
2018-09-25 16:31:40 -04:00
F. Eugene Aumson
2e7b218f40 fix: comments
https://github.com/0xProject/0x-monorepo/pull/1004#discussion_r219990314
https://github.com/0xProject/0x-monorepo/pull/1004#discussion_r220007992
https://github.com/0xProject/0x-monorepo/pull/1004
2018-09-25 16:31:40 -04:00
F. Eugene Aumson
7fbfd9ccd9 fix: print error and exit process; don't re-throw
https://github.com/0xProject/0x-monorepo/pull/1004#discussion_r219979003
https://github.com/0xProject/0x-monorepo/pull/1004
2018-09-25 16:31:40 -04:00
F. Eugene Aumson
1db5ff617f fix: split line for readability
https://github.com/0xProject/0x-monorepo/pull/1004#discussion_r219978696
https://github.com/0xProject/0x-monorepo/pull/1004
2018-09-25 16:31:40 -04:00
F. Eugene Aumson
ac5376a1ca fix: rename JSON_TABWIDTH to JSON_TAB_WIDTH
https://github.com/0xProject/0x-monorepo/pull/1004#discussion_r219977842
https://github.com/0xProject/0x-monorepo/pull/1004
2018-09-25 16:31:39 -04:00
F. Eugene Aumson
600ffd93a6 fix: use latest versions of @0xproject packages
https://github.com/0xProject/0x-monorepo/pull/1004#discussion_r219977747
https://github.com/0xProject/0x-monorepo/pull/1004
2018-09-25 16:31:26 -04:00
fragosti
22597674d2 Add weijie and rahul 2018-09-25 22:29:16 +02:00
Fabio Berger
adf5acd5c4 Update yarn.lock 2018-09-25 21:23:06 +01:00
fragosti
055bcb52f8 Change news link 2018-09-25 22:04:12 +02:00
F. Eugene Aumson
6174267f69 fix: explain why tslint rule is disabled
https://github.com/0xProject/0x-monorepo/pull/1004#discussion_r219976511
https://github.com/0xProject/0x-monorepo/pull/1004
2018-09-25 15:51:32 -04:00
F. Eugene Aumson
e8c8d3e722 fix: rename SupportedDocJson field to SolDoc
from Solidity

https://github.com/0xProject/0x-monorepo/pull/1004#discussion_r219976199
https://github.com/0xProject/0x-monorepo/pull/1004
2018-09-25 15:51:03 -04:00
Brandon Millman
d20f713fad When number of relayers is less than number of columns, reduce column number to number of relayers 2018-09-25 21:08:32 +02:00
Fabio Berger
b40861747b Properly render function generic types that don't extend another type 2018-09-25 17:34:22 +01:00
Fabio Berger
b73df28454 Merge pull request #1087 from 0xProject/addTxHashToOrderState
Add transactionHash to OrderState and emit it from OrderWatcher
2018-09-25 16:37:24 +01:00
Fabio Berger
5afc739397 Add changelog entry 2018-09-25 16:37:08 +01:00
Fabio Berger
9eecf3683b Add transactionHash to OrderState and emit it from OrderWatcher subscription 2018-09-25 16:10:13 +01:00
Fabio Berger
7570f3db51 Merge pull request #1080 from 0xProject/upgradeBlockstream
Fix dropped events issue in Order-watcher and Contract-wrappers subscriptions
2018-09-25 14:59:37 +01:00
Fabio Berger
977d55c61b merge development 2018-09-25 13:07:14 +01:00
Fabio Berger
fc3acec669 Fix lint issues 2018-09-25 12:32:20 +01:00
Fabio Berger
a05530f821 Fix prettier 2018-09-25 12:06:37 +01:00
Fabio Berger
173b36c54c Fix prettier 2018-09-25 12:06:28 +01:00
Fabio Berger
55ca971186 Decode logs received from blockstream 2018-09-25 12:05:44 +01:00
Fabio Berger
284930eb58 Add missing type 2018-09-25 11:30:27 +01:00
Fabio Berger
902691e289 Update changelogs 2018-09-25 11:29:36 +01:00
Fabio Berger
0afe55f2ff Refactor blockstream integration to use the proper callback method interface 2018-09-25 11:20:09 +01:00
Fabio Berger
21910a7129 Add entry about newly exposed method 2018-09-25 11:02:49 +01:00
Fabio Berger
9c89d1e99b Expose method to send raw JSON RPC payloads 2018-09-25 10:45:11 +01:00
F. Eugene Aumson
574270d061 fix: increase mocha timeout value
prior CI runs were failing because of this.
2018-09-24 17:17:28 -04:00
F. Eugene Aumson
9af5e3ba8e fix: add CHANGELOG.json 2018-09-24 17:17:19 -04:00
F. Eugene Aumson
2116548eed Merge remote-tracking branch 'upstream/development' into sol-doc 2018-09-24 13:30:37 -04:00
F. Eugene Aumson
57fca16d7b fix: use contract name for constructor method name
and for its return value
2018-09-24 13:24:03 -04:00
F. Eugene Aumson
a900255820 fix: document indexed event arguments 2018-09-24 13:05:35 -04:00
F. Eugene Aumson
bd7565ceda fix: save v1 contract doc/deploy commands
For posterity, save commands needed to use sol-doc to generate and
deploy documentation objects for v1 contracts.
2018-09-24 12:36:26 -04:00
F. Eugene Aumson
880cd6e440 fix: document return value's type, not its name 2018-09-24 12:29:02 -04:00
Fabio Berger
5e1a2bd972 Merge development 2018-09-24 15:53:34 +01:00
F. Eugene Aumson
98d06d6d25 BREAKING CHANGE: document contracts from sol-doc
Change website to accept smart contract documentation in the format
generated by sol-doc rather than that generated by Doxity.
2018-09-22 11:29:27 -04:00
F. Eugene Aumson
9f0dfb1e1a feat: make sol-doc only document what's requested
if a list of contracts-to-document is passed into sol-doc, then the
output should only contain documentation for the contracts requested.

if an empty/undefined list is passed, then it should document all
contracts that were found.
2018-09-22 10:55:46 -04:00
F. Eugene Aumson
37cb18e1da fix: rename variable 2018-09-22 10:21:27 -04:00
F. Eugene Aumson
3e5d427d4e feat: add sol-doc command-line interface
modified sol-compiler to output progress/warning/error/etc messages to
stderr rather than stdout, so that sol-doc can put its output (and
nothing else) to stdout.

for posterity, added sol-doc cli usage as npm scripts to package.json.
2018-09-22 10:14:49 -04:00
Fabio Berger
45dc2be083 Fix prettier 2018-09-21 14:53:25 +01:00
Fabio Berger
31f6fc065f Add changelog entries 2018-09-21 14:24:50 +01:00
Fabio Berger
b0484eafe3 Upgrade blockstream to version that supports fetching logs by blockHash, fixing reliability issues 2018-09-21 13:46:10 +01:00
Fabio Berger
1b799e98e8 Add blockHash to FilterObject now that EIP234 is supported 2018-09-21 13:45:06 +01:00
Fabio Berger
e6840c60c7 Add assertion that one cannot specify both blockHash & fromBlock/toBlock to getLogsAsync 2018-09-21 13:43:06 +01:00
Leonid Logvinov
f3deabccf4 Add CHANGELOG entries 2018-09-21 12:10:25 +02:00
Leonid Logvinov
393f9e5a29 Fix the way we detect BN's 2018-09-21 12:05:13 +02:00
Leonid Logvinov
79cf6969f9 Fix linter issue 2018-09-21 11:48:06 +02:00
Leonid Logvinov
3167bfde1a Remove unused import 2018-09-21 11:47:30 +02:00
F. Eugene Aumson
301e491952 Merge remote-tracking branch 'upstream/development' into sol-doc 2018-09-20 12:51:30 -04:00
Leonid Logvinov
5b6c91bb3f Fixes for the breaking changes in ethers 2018-09-19 17:56:23 +02:00
Leonid Logvinov
6701ec68bd Upgrade contract_templates to work with ethers 4.0 2018-09-19 17:56:23 +02:00
Leonid Logvinov
7b259c3f4c Remove types for ethers.js 2018-09-19 17:56:23 +02:00
Leonid Logvinov
ecbdf5f12b Upgrade to TS version of ethers 2018-09-19 17:56:23 +02:00
F. Eugene Aumson
30622631ff use Array.join rather than string concatenation 2018-09-17 19:31:47 -04:00
F. Eugene Aumson
4bab402e95 doc constructors as returning a Reference...
...not an Intrinsic
2018-09-17 19:31:45 -04:00
F. Eugene Aumson
91de15d50e remove stale comments 2018-09-17 19:31:42 -04:00
F. Eugene Aumson
d40a670d0b add newline to delimit interface declaration 2018-09-17 19:31:40 -04:00
F. Eugene Aumson
4ade674ada test multiple return values from a solidity method 2018-09-17 19:31:37 -04:00
F. Eugene Aumson
401ef2edef minorly tweak comments 2018-09-17 19:31:34 -04:00
F. Eugene Aumson
9201273939 add and test support for return comment 2018-09-17 19:31:32 -04:00
F. Eugene Aumson
5b07669bd0 add and test support for fallback functions 2018-09-17 19:31:30 -04:00
F. Eugene Aumson
3c7155afb0 test all the natspec stuff we use in our contracts 2018-09-17 19:31:23 -04:00
F. Eugene Aumson
a75981da14 test w/&w/out devdoc content in contract 2018-09-17 17:49:14 -04:00
F. Eugene Aumson
d5f964b58e test w/&w/out passing in contractsToCompile 2018-09-17 17:49:03 -04:00
F. Eugene Aumson
cbb5a425df Merge branch 'development' into sol-doc 2018-09-11 19:00:11 -04:00
F. Eugene Aumson
800dd5fb4f ammend generated docs with solc's devdoc output 2018-08-31 16:18:17 -04:00
F. Eugene Aumson
3dc4eb4421 rename 2 variables 2018-08-31 15:28:12 -04:00
F. Eugene Aumson
75664b6651 make postinstall symlink hack cross platform 2018-08-31 11:49:14 -04:00
F. Eugene Aumson
327b4ba554 satisfy linter 2018-08-31 11:18:43 -04:00
F. Eugene Aumson
50b725c687 introduce named vars to clarify return statements 2018-08-31 09:33:26 -04:00
F. Eugene Aumson
72419816a8 Merge remote-tracking branch 'upstream/development' into sol-doc 2018-08-31 09:22:05 -04:00
F. Eugene Aumson
9a4e6da02f enable sol-doc tests in circleci 2018-08-31 09:15:41 -04:00
F. Eugene Aumson
823b6c4d7d transform solc's ABI output into doc types 2018-08-31 09:12:27 -04:00
F. Eugene Aumson
8d122006ba move export to top of file 2018-08-30 12:34:27 -04:00
F. Eugene Aumson
0e45497acb rename variables 2018-08-30 12:28:09 -04:00
F. Eugene Aumson
fe7a62ba9a add named var to make if condition more readable 2018-08-30 12:02:46 -04:00
F. Eugene Aumson
b88a56e6b7 reduce proximity b/w instantiation and use of var 2018-08-30 12:02:46 -04:00
F. Eugene Aumson
297cbd996d remove unnecessary class SolidityDocFormat 2018-08-30 12:02:42 -04:00
F. Eugene Aumson
f55234b4a0 comment public interface 2018-08-30 11:30:43 -04:00
F. Eugene Aumson
f76c88c549 remove unused constructor parameter 2018-08-30 11:24:41 -04:00
F. Eugene Aumson
863966787f dev-depend on @0xproject/tslint-config 2018-08-30 10:43:43 -04:00
F. Eugene Aumson
7ed31d2fba correct package.json's privacy specification 2018-08-30 10:43:43 -04:00
F. Eugene Aumson
6273339f7c add named references for returned objects 2018-08-30 10:43:43 -04:00
F. Eugene Aumson
29f2ae605e re-word comment: 'construction' -> 'instantiation' 2018-08-30 10:43:43 -04:00
F. Eugene Aumson
6450844d7f rename method _addHexPrefixes 2018-08-30 10:43:43 -04:00
F. Eugene Aumson
9834395a48 remove mistaken TODO 2018-08-30 10:43:43 -04:00
F. Eugene Aumson
f429032eef move shared doc types from react-docs to @0x/types 2018-08-30 10:43:36 -04:00
F. Eugene Aumson
5088b7f23c hack postinstall to correct types package symlink
yarn is not doing this properly :( even on v1.9.4.
confirmed with @albrow .
2018-08-30 10:08:35 -04:00
F. Eugene Aumson
28246abec3 remove unneeded entries from doc gen config 2018-08-29 15:23:32 -04:00
F. Eugene Aumson
a1959df911 add devdoc support to solc typings, and use it 2018-08-29 08:51:01 -04:00
F. Eugene Aumson
775d1efd46 add package sol-doc 2018-08-29 08:50:55 -04:00
F. Eugene Aumson
849e203812 add interface to return compiler output...
...rather than persisting it to the filesystem.
2018-08-28 14:24:26 -04:00
F. Eugene Aumson
80ed724f3a rename var compiledData to compiledContract 2018-08-28 14:24:26 -04:00
F. Eugene Aumson
5c056b57b7 extract method _getContractNamesToCompile() 2018-08-28 14:24:26 -04:00
F. Eugene Aumson
4779ebfd20 split method 2018-08-28 14:24:26 -04:00
178 changed files with 2971 additions and 1123 deletions

View File

@@ -100,6 +100,7 @@ jobs:
- run: yarn wsrun test:circleci @0xproject/order-watcher - run: yarn wsrun test:circleci @0xproject/order-watcher
- run: yarn wsrun test:circleci @0xproject/sol-compiler - run: yarn wsrun test:circleci @0xproject/sol-compiler
- run: yarn wsrun test:circleci @0xproject/sol-cov - run: yarn wsrun test:circleci @0xproject/sol-cov
- run: yarn wsrun test:circleci @0xproject/sol-doc
- run: yarn wsrun test:circleci @0xproject/sra-report - run: yarn wsrun test:circleci @0xproject/sra-report
- run: yarn wsrun test:circleci @0xproject/subproviders - run: yarn wsrun test:circleci @0xproject/subproviders
- run: yarn wsrun test:circleci @0xproject/web3-wrapper - run: yarn wsrun test:circleci @0xproject/web3-wrapper
@@ -152,6 +153,10 @@ jobs:
key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }} key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
paths: paths:
- ~/repo/packages/sol-cov/coverage/lcov.info - ~/repo/packages/sol-cov/coverage/lcov.info
- save_cache:
key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/sol-doc/coverage/lcov.info
- save_cache: - save_cache:
key: coverage-sra-report-{{ .Environment.CIRCLE_SHA1 }} key: coverage-sra-report-{{ .Environment.CIRCLE_SHA1 }}
paths: paths:
@@ -218,6 +223,9 @@ jobs:
- restore_cache: - restore_cache:
keys: keys:
- coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }} - coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache: - restore_cache:
keys: keys:
- coverage-sra-report-{{ .Environment.CIRCLE_SHA1 }} - coverage-sra-report-{{ .Environment.CIRCLE_SHA1 }}

View File

@@ -35,8 +35,7 @@
"test": "wsrun test $PKG --fast-exit --serial --exclude-missing", "test": "wsrun test $PKG --fast-exit --serial --exclude-missing",
"generate_doc": "node ./packages/monorepo-scripts/lib/doc_generate_and_upload.js", "generate_doc": "node ./packages/monorepo-scripts/lib/doc_generate_and_upload.js",
"test:generate_docs:circleci": "for i in ${npm_package_config_packagesWithDocPages}; do yarn generate_doc --package $i --shouldUpload false --isStaging true || break -1; done;", "test:generate_docs:circleci": "for i in ${npm_package_config_packagesWithDocPages}; do yarn generate_doc --package $i --shouldUpload false --isStaging true || break -1; done;",
"lint": "wsrun lint $PKG --fast-exit --parallel --exclude-missing", "lint": "wsrun lint $PKG --fast-exit --parallel --exclude-missing"
"comment:postinstall": "HACK: For some reason `yarn` is not setting up symlinks properly for order-utils. We temporarily set them manually. Remove this after V2 refactor is complete."
}, },
"config": { "config": {
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic", "mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic",
@@ -54,8 +53,5 @@
"source-map-support": "^0.5.6", "source-map-support": "^0.5.6",
"typescript": "3.0.1", "typescript": "3.0.1",
"wsrun": "^2.2.0" "wsrun": "^2.2.0"
},
"resolutions": {
"ethers": "0xproject/ethers.js#eip-838-reasons"
} }
} }

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "1.0.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.0.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "1.0.5", "version": "1.0.5",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.0.7 - _September 28, 2018_
* Dependencies updated
## v1.0.6 - _September 25, 2018_
* Dependencies updated
## v1.0.5 - _September 25, 2018_ ## v1.0.5 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "0x.js", "name": "0x.js",
"version": "1.0.5", "version": "1.0.7",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -41,10 +41,10 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"devDependencies": { "devDependencies": {
"@0xproject/abi-gen": "^1.0.10", "@0xproject/abi-gen": "^1.0.12",
"@0xproject/dev-utils": "^1.0.9", "@0xproject/dev-utils": "^1.0.11",
"@0xproject/migrations": "^1.0.11", "@0xproject/migrations": "^1.0.13",
"@0xproject/monorepo-scripts": "^1.0.9", "@0xproject/monorepo-scripts": "^1.0.10",
"@0xproject/tslint-config": "^1.0.7", "@0xproject/tslint-config": "^1.0.7",
"@types/lodash": "4.14.104", "@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",
@@ -73,18 +73,18 @@
"webpack": "^3.1.0" "webpack": "^3.1.0"
}, },
"dependencies": { "dependencies": {
"@0xproject/assert": "^1.0.10", "@0xproject/assert": "^1.0.12",
"@0xproject/base-contract": "^2.0.4", "@0xproject/base-contract": "^3.0.0",
"@0xproject/contract-wrappers": "^1.0.5", "@0xproject/contract-wrappers": "^2.0.1",
"@0xproject/order-utils": "^1.0.4", "@0xproject/order-utils": "^1.0.6",
"@0xproject/order-watcher": "^1.0.5", "@0xproject/order-watcher": "^2.1.0",
"@0xproject/subproviders": "^2.0.4", "@0xproject/subproviders": "^2.0.6",
"@0xproject/types": "^1.1.0", "@0xproject/types": "^1.1.2",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"ethers": "3.0.22", "ethers": "4.0.0-beta.14",
"lodash": "^4.17.5", "lodash": "^4.17.5",
"web3-provider-engine": "14.0.6" "web3-provider-engine": "14.0.6"
}, },

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "1.0.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.0.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "1.0.10", "version": "1.0.10",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.0.12 - _September 28, 2018_
* Dependencies updated
## v1.0.11 - _September 25, 2018_
* Dependencies updated
## v1.0.10 - _September 25, 2018_ ## v1.0.10 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/abi-gen", "name": "@0xproject/abi-gen",
"version": "1.0.10", "version": "1.0.12",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -30,10 +30,10 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
"dependencies": { "dependencies": {
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"chalk": "^2.3.0", "chalk": "^2.3.0",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"glob": "^7.1.2", "glob": "^7.1.2",
"handlebars": "^4.0.11", "handlebars": "^4.0.11",
"lodash": "^4.17.5", "lodash": "^4.17.5",

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "1.0.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.0.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "1.0.10", "version": "1.0.10",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.0.12 - _September 28, 2018_
* Dependencies updated
## v1.0.11 - _September 25, 2018_
* Dependencies updated
## v1.0.10 - _September 25, 2018_ ## v1.0.10 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/assert", "name": "@0xproject/assert",
"version": "1.0.10", "version": "1.0.12",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -44,9 +44,9 @@
"typescript": "3.0.1" "typescript": "3.0.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/json-schemas": "^1.0.3", "@0xproject/json-schemas": "^1.0.5",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"lodash": "^4.17.5", "lodash": "^4.17.5",
"valid-url": "^1.0.9" "valid-url": "^1.0.9"
}, },

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "1.0.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.0.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "1.0.0", "version": "1.0.0",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.0.2 - _September 28, 2018_
* Dependencies updated
## v1.0.1 - _September 25, 2018_
* Dependencies updated
## v1.0.0 - _September 25, 2018_ ## v1.0.0 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/asset-buyer", "name": "@0xproject/asset-buyer",
"version": "1.0.0", "version": "1.0.2",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -36,17 +36,17 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md",
"dependencies": { "dependencies": {
"@0xproject/assert": "^1.0.10", "@0xproject/assert": "^1.0.12",
"@0xproject/connect": "^2.0.3", "@0xproject/connect": "^3.0.0",
"@0xproject/contract-wrappers": "^1.0.5", "@0xproject/contract-wrappers": "^2.0.1",
"@0xproject/json-schemas": "^1.0.3", "@0xproject/json-schemas": "^1.0.5",
"@0xproject/order-utils": "^1.0.4", "@0xproject/order-utils": "^1.0.6",
"@0xproject/subproviders": "^2.0.4", "@0xproject/subproviders": "^2.0.6",
"@0xproject/types": "^1.1.0", "@0xproject/types": "^1.1.2",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"ethereum-types": "^1.0.6", "ethereum-types": "^1.0.9",
"lodash": "^4.17.10" "lodash": "^4.17.10"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -1,4 +1,27 @@
[ [
{
"version": "3.0.0",
"changes": [
{
"note": "Change the way we detect BN to work with the newest ethers.js",
"pr": 1069
},
{
"note": "Add baseContract._throwIfRevertWithReasonCallResult",
"pr": 1069
}
],
"timestamp": 1538157789
},
{
"timestamp": 1537907159,
"version": "2.0.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "2.0.4", "version": "2.0.4",

View File

@@ -5,6 +5,15 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v3.0.0 - _September 28, 2018_
* Change the way we detect BN to work with the newest ethers.js (#1069)
* Add baseContract._throwIfRevertWithReasonCallResult (#1069)
## v2.0.5 - _September 25, 2018_
* Dependencies updated
## v2.0.4 - _September 25, 2018_ ## v2.0.4 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/base-contract", "name": "@0xproject/base-contract",
"version": "2.0.4", "version": "3.0.0",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -40,11 +40,11 @@
"typescript": "3.0.1" "typescript": "3.0.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"ethers": "3.0.22", "ethers": "4.0.0-beta.14",
"lodash": "^4.17.5" "lodash": "^4.17.5"
}, },
"publishConfig": { "publishConfig": {

View File

@@ -20,6 +20,11 @@ export interface EthersInterfaceByFunctionSignature {
[key: string]: ethers.Interface; [key: string]: ethers.Interface;
} }
const REVERT_ERROR_SELECTOR = '08c379a0';
const REVERT_ERROR_SELECTOR_OFFSET = 2;
const REVERT_ERROR_SELECTOR_BYTES_LENGTH = 4;
const REVERT_ERROR_SELECTOR_END = REVERT_ERROR_SELECTOR_OFFSET + REVERT_ERROR_SELECTOR_BYTES_LENGTH * 2;
export class BaseContract { export class BaseContract {
protected _ethersInterfacesByFunctionSignature: EthersInterfaceByFunctionSignature; protected _ethersInterfacesByFunctionSignature: EthersInterfaceByFunctionSignature;
protected _web3Wrapper: Web3Wrapper; protected _web3Wrapper: Web3Wrapper;
@@ -61,7 +66,7 @@ export class BaseContract {
} }
} }
protected static _bnToBigNumber(_type: string, value: any): any { protected static _bnToBigNumber(_type: string, value: any): any {
return _.isObject(value) && value._bn ? new BigNumber(value.toString()) : value; return _.isObject(value) && value._hex ? new BigNumber(value.toString()) : value;
} }
protected static async _applyDefaultsToTxDataAsync<T extends Partial<TxData | TxDataPayable>>( protected static async _applyDefaultsToTxDataAsync<T extends Partial<TxData | TxDataPayable>>(
txData: T, txData: T,
@@ -82,15 +87,24 @@ export class BaseContract {
} }
return txDataWithDefaults; return txDataWithDefaults;
} }
protected static _throwIfRevertWithReasonCallResult(rawCallResult: string): void {
if (rawCallResult.slice(REVERT_ERROR_SELECTOR_OFFSET, REVERT_ERROR_SELECTOR_END) === REVERT_ERROR_SELECTOR) {
const revertReason = ethers.utils.defaultAbiCoder.decode(
['string'],
ethers.utils.hexDataSlice(rawCallResult, REVERT_ERROR_SELECTOR_BYTES_LENGTH),
);
throw new Error(revertReason);
}
}
// Throws if the given arguments cannot be safely/correctly encoded based on // Throws if the given arguments cannot be safely/correctly encoded based on
// the given inputAbi. An argument may not be considered safely encodeable // the given inputAbi. An argument may not be considered safely encodeable
// if it overflows the corresponding Solidity type, there is a bug in the // if it overflows the corresponding Solidity type, there is a bug in the
// encoder, or the encoder performs unsafe type coercion. // encoder, or the encoder performs unsafe type coercion.
public static strictArgumentEncodingCheck(inputAbi: DataItem[], args: any[]): void { public static strictArgumentEncodingCheck(inputAbi: DataItem[], args: any[]): void {
const coder = ethers.utils.AbiCoder.defaultCoder; const coder = new ethers.AbiCoder();
const params = abiUtils.parseEthersParams(inputAbi); const params = abiUtils.parseEthersParams(inputAbi);
const rawEncoded = coder.encode(params.names, params.types, args); const rawEncoded = coder.encode(inputAbi, args);
const rawDecoded = coder.decode(params.names, params.types, rawEncoded); const rawDecoded = coder.decode(inputAbi, rawEncoded);
for (let i = 0; i < rawDecoded.length; i++) { for (let i = 0; i < rawDecoded.length; i++) {
const original = args[i]; const original = args[i];
const decoded = rawDecoded[i]; const decoded = rawDecoded[i];

View File

@@ -1,4 +1,23 @@
[ [
{
"version": "3.0.0",
"changes": [
{
"note": "Change /order_config request to a POST instead of GET",
"pr": 1091
}
],
"timestamp": 1538157789
},
{
"timestamp": 1537907159,
"version": "2.0.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"version": "2.0.3", "version": "2.0.3",
"changes": [ "changes": [

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v3.0.0 - _September 28, 2018_
* Change /order_config request to a POST instead of GET (#1091)
## v2.0.4 - _September 25, 2018_
* Dependencies updated
## v2.0.3 - _September 25, 2018_ ## v2.0.3 - _September 25, 2018_
* Import SRA-related types from @0xproject/types (#1085) * Import SRA-related types from @0xproject/types (#1085)

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/connect", "name": "@0xproject/connect",
"version": "2.0.3", "version": "3.0.0",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -43,12 +43,12 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
"dependencies": { "dependencies": {
"@0xproject/assert": "^1.0.10", "@0xproject/assert": "^1.0.12",
"@0xproject/json-schemas": "^1.0.3", "@0xproject/json-schemas": "^1.0.5",
"@0xproject/order-utils": "^1.0.4", "@0xproject/order-utils": "^1.0.6",
"@0xproject/types": "^1.1.0", "@0xproject/types": "^1.1.2",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"lodash": "^4.17.5", "lodash": "^4.17.5",
"query-string": "^5.0.1", "query-string": "^5.0.1",
"sinon": "^4.0.0", "sinon": "^4.0.0",

View File

@@ -149,7 +149,7 @@ export class HttpClient implements Client {
params: requestOpts, params: requestOpts,
payload: request, payload: request,
}; };
const responseJson = await this._requestAsync('/order_config', HttpRequestType.Get, httpRequestOpts); const responseJson = await this._requestAsync('/order_config', HttpRequestType.Post, httpRequestOpts);
const fees = relayerResponseJsonParsers.parseOrderConfigResponseJson(responseJson); const fees = relayerResponseJsonParsers.parseOrderConfigResponseJson(responseJson);
return fees; return fees;
} }

View File

@@ -148,12 +148,12 @@ describe('HttpClient', () => {
}; };
const url = `${relayUrl}/order_config`; const url = `${relayUrl}/order_config`;
it('gets order config', async () => { it('gets order config', async () => {
fetchMock.get(url, orderConfigResponseJSON); fetchMock.post(url, orderConfigResponseJSON);
const fees = await relayerClient.getOrderConfigAsync(request); const fees = await relayerClient.getOrderConfigAsync(request);
expect(fees).to.be.deep.equal(orderConfigResponse); expect(fees).to.be.deep.equal(orderConfigResponse);
}); });
it('does not mutate input', async () => { it('does not mutate input', async () => {
fetchMock.get(url, orderConfigResponseJSON); fetchMock.post(url, orderConfigResponseJSON);
const makerAssetAmountBefore = request.makerAssetAmount; const makerAssetAmountBefore = request.makerAssetAmount;
const takerAssetAmountBefore = request.takerAssetAmount; const takerAssetAmountBefore = request.takerAssetAmount;
const expirationTimeSecondsBefore = request.expirationTimeSeconds; const expirationTimeSecondsBefore = request.expirationTimeSeconds;
@@ -163,7 +163,7 @@ describe('HttpClient', () => {
expect(expirationTimeSecondsBefore).to.be.deep.equal(request.expirationTimeSeconds); expect(expirationTimeSecondsBefore).to.be.deep.equal(request.expirationTimeSeconds);
}); });
it('throws an error for invalid JSON response', async () => { it('throws an error for invalid JSON response', async () => {
fetchMock.get(url, { test: 'dummy' }); fetchMock.post(url, { test: 'dummy' });
expect(relayerClient.getOrderConfigAsync(request)).to.be.rejected(); expect(relayerClient.getOrderConfigAsync(request)).to.be.rejected();
}); });
}); });

View File

@@ -1,7 +1,7 @@
[ [
{ {
"timestamp": 1537875740, "timestamp": 1538157789,
"version": "1.0.5", "version": "2.0.1",
"changes": [ "changes": [
{ {
"note": "Dependencies updated" "note": "Dependencies updated"
@@ -9,13 +9,38 @@
] ]
}, },
{ {
"timestamp": 1537541580, "version": "2.0.0",
"changes": [
{
"note":
"Fixes dropped events in subscriptions by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too.",
"pr": 1080
},
{
"note":
"Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it",
"pr": 1080
}
],
"timestamp": 1537907159
},
{
"version": "1.0.5",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1537875740
},
{
"version": "1.0.4", "version": "1.0.4",
"changes": [ "changes": [
{ {
"note": "Dependencies updated" "note": "Dependencies updated"
} }
] ],
"timestamp": 1537541580
}, },
{ {
"version": "1.0.3", "version": "1.0.3",

View File

@@ -5,6 +5,15 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v2.0.1 - _September 28, 2018_
* Dependencies updated
## v2.0.0 - _September 25, 2018_
* Fixes dropped events in subscriptions by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too. (#1080)
* Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it (#1080)
## v1.0.5 - _September 25, 2018_ ## v1.0.5 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/contract-wrappers", "name": "@0xproject/contract-wrappers",
"version": "1.0.5", "version": "2.0.1",
"description": "Smart TS wrappers for 0x smart contracts", "description": "Smart TS wrappers for 0x smart contracts",
"keywords": [ "keywords": [
"0xproject", "0xproject",
@@ -41,10 +41,10 @@
"node": ">=6.0.0" "node": ">=6.0.0"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/abi-gen": "^1.0.10", "@0xproject/abi-gen": "^1.0.12",
"@0xproject/dev-utils": "^1.0.9", "@0xproject/dev-utils": "^1.0.11",
"@0xproject/migrations": "^1.0.11", "@0xproject/migrations": "^1.0.13",
"@0xproject/subproviders": "^2.0.4", "@0xproject/subproviders": "^2.0.6",
"@0xproject/tslint-config": "^1.0.7", "@0xproject/tslint-config": "^1.0.7",
"@types/lodash": "4.14.104", "@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",
@@ -72,19 +72,19 @@
"web3-provider-engine": "14.0.6" "web3-provider-engine": "14.0.6"
}, },
"dependencies": { "dependencies": {
"@0xproject/assert": "^1.0.10", "@0xproject/assert": "^1.0.12",
"@0xproject/base-contract": "^2.0.4", "@0xproject/base-contract": "^3.0.0",
"@0xproject/fill-scenarios": "^1.0.4", "@0xproject/fill-scenarios": "^1.0.6",
"@0xproject/json-schemas": "^1.0.3", "@0xproject/json-schemas": "^1.0.5",
"@0xproject/order-utils": "^1.0.4", "@0xproject/order-utils": "^1.0.6",
"@0xproject/types": "^1.1.0", "@0xproject/types": "^1.1.2",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"ethereumjs-blockstream": "5.0.0", "ethereumjs-blockstream": "6.0.0",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "^5.1.1",
"ethers": "3.0.22", "ethers": "4.0.0-beta.14",
"js-sha3": "^0.7.0", "js-sha3": "^0.7.0",
"lodash": "^4.17.5", "lodash": "^4.17.5",
"uuid": "^3.1.0" "uuid": "^3.1.0"

View File

@@ -1,14 +1,14 @@
import { AbiDecoder, intervalUtils, logUtils } from '@0xproject/utils'; import { AbiDecoder, intervalUtils, logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { marshaller, Web3Wrapper } from '@0xproject/web3-wrapper';
import { import {
BlockParamLiteral, BlockParamLiteral,
BlockWithoutTransactionData,
ContractAbi, ContractAbi,
ContractArtifact, ContractArtifact,
FilterObject, FilterObject,
LogEntry, LogEntry,
LogWithDecodedArgs, LogWithDecodedArgs,
RawLog, RawLog,
RawLogEntry,
} from 'ethereum-types'; } from 'ethereum-types';
import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream'; import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream';
import * as _ from 'lodash'; import * as _ from 'lodash';
@@ -158,7 +158,8 @@ export abstract class ContractWrapper {
return addressIfExists; return addressIfExists;
} }
} }
private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, log: LogEntry): void { private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, rawLog: RawLogEntry): void {
const log: LogEntry = marshaller.unmarshalLog(rawLog);
_.forEach(this._filters, (filter: FilterObject, filterToken: string) => { _.forEach(this._filters, (filter: FilterObject, filterToken: string) => {
if (filterUtils.matchesFilter(log, filter)) { if (filterUtils.matchesFilter(log, filter)) {
const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs<ArgsType>; const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs<ArgsType>;
@@ -175,8 +176,8 @@ export abstract class ContractWrapper {
throw new Error(ContractWrappersError.SubscriptionAlreadyPresent); throw new Error(ContractWrappersError.SubscriptionAlreadyPresent);
} }
this._blockAndLogStreamerIfExists = new BlockAndLogStreamer( this._blockAndLogStreamerIfExists = new BlockAndLogStreamer(
this._getBlockOrNullAsync.bind(this), this._blockstreamGetBlockOrNullAsync.bind(this),
this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper), this._blockstreamGetLogsAsync.bind(this),
ContractWrapper._onBlockAndLogStreamerError.bind(this, isVerbose), ContractWrapper._onBlockAndLogStreamerError.bind(this, isVerbose),
); );
const catchAllLogFilter = {}; const catchAllLogFilter = {};
@@ -196,12 +197,30 @@ export abstract class ContractWrapper {
); );
} }
// This method only exists in order to comply with the expected interface of Blockstream's constructor // This method only exists in order to comply with the expected interface of Blockstream's constructor
private async _getBlockOrNullAsync(): Promise<BlockWithoutTransactionData | null> { private async _blockstreamGetBlockOrNullAsync(hash: string): Promise<Block | null> {
const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper); const shouldIncludeTransactionData = false;
if (_.isUndefined(blockIfExists)) { const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync<Block | null>({
return null; method: 'eth_getBlockByHash',
params: [hash, shouldIncludeTransactionData],
});
return blockOrNull;
} }
return blockIfExists; // This method only exists in order to comply with the expected interface of Blockstream's constructor
private async _blockstreamGetLatestBlockOrNullAsync(): Promise<Block | null> {
const shouldIncludeTransactionData = false;
const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync<Block | null>({
method: 'eth_getBlockByNumber',
params: [BlockParamLiteral.Latest, shouldIncludeTransactionData],
});
return blockOrNull;
}
// This method only exists in order to comply with the expected interface of Blockstream's constructor
private async _blockstreamGetLogsAsync(filterOptions: FilterObject): Promise<RawLogEntry[]> {
const logs = await this._web3Wrapper.sendRawPayloadAsync<RawLogEntry[]>({
method: 'eth_getLogs',
params: [filterOptions],
});
return logs as RawLogEntry[];
} }
// HACK: This should be a package-scoped method (which doesn't exist in TS) // HACK: This should be a package-scoped method (which doesn't exist in TS)
// We don't want this method available in the public interface for all classes // We don't want this method available in the public interface for all classes
@@ -221,14 +240,14 @@ export abstract class ContractWrapper {
delete this._blockAndLogStreamerIfExists; delete this._blockAndLogStreamerIfExists;
} }
private async _reconcileBlockAsync(): Promise<void> { private async _reconcileBlockAsync(): Promise<void> {
const latestBlockIfExists = await this._web3Wrapper.getBlockIfExistsAsync(BlockParamLiteral.Latest); const latestBlockOrNull = await this._blockstreamGetLatestBlockOrNullAsync();
if (_.isUndefined(latestBlockIfExists)) { if (_.isNull(latestBlockOrNull)) {
return; // noop return; // noop
} }
// We need to coerce to Block type cause Web3.Block includes types for mempool blocks // We need to coerce to Block type cause Web3.Block includes types for mempool blocks
if (!_.isUndefined(this._blockAndLogStreamerIfExists)) { if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
// If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined
await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockIfExists as any) as Block); await this._blockAndLogStreamerIfExists.reconcileNewBlock(latestBlockOrNull);
} }
} }
} }

View File

@@ -0,0 +1,122 @@
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { FillScenarios } from '@0xproject/fill-scenarios';
import { runV2MigrationsAsync } from '@0xproject/migrations';
import { assetDataUtils } from '@0xproject/order-utils';
import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import 'mocha';
import { ContractWrappers } from '../src';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { tokenUtils } from './utils/token_utils';
chaiSetup.configure();
const expect = chai.expect;
describe('Revert Validation ExchangeWrapper', () => {
let contractWrappers: ContractWrappers;
let userAddresses: string[];
let zrxTokenAddress: string;
let fillScenarios: FillScenarios;
let exchangeContractAddress: string;
let makerTokenAddress: string;
let takerTokenAddress: string;
let coinbase: string;
let makerAddress: string;
let anotherMakerAddress: string;
let takerAddress: string;
let makerAssetData: string;
let takerAssetData: string;
let feeRecipient: string;
let txHash: string;
let blockchainLifecycle: BlockchainLifecycle;
let web3Wrapper: Web3Wrapper;
const fillableAmount = new BigNumber(5);
const takerTokenFillAmount = new BigNumber(5);
let signedOrder: SignedOrder;
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
blockPollingIntervalMs: 0,
};
before(async () => {
// vmErrorsOnRPCResponse is useful for quick feedback and testing during development
// but is not the default behaviour in production. Here we ensure our failure cases
// are handled in an environment which behaves similar to production
const provider = web3Factory.getRpcProvider({
shouldUseInProcessGanache: true,
shouldThrowErrorsOnGanacheRPCResponse: false,
});
web3Wrapper = new Web3Wrapper(provider);
blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const txDefaults = {
gas: devConstants.GAS_LIMIT,
from: devConstants.TESTRPC_FIRST_ADDRESS,
};
const artifactsDir = `src/artifacts`;
// Re-deploy the artifacts in this provider, rather than in the default provider exposed in
// the beforeAll hook. This is due to the fact that the default provider enabled vmErrorsOnRPCResponse
// and we are explicity testing with vmErrorsOnRPCResponse disabled.
await runV2MigrationsAsync(provider, artifactsDir, txDefaults);
await blockchainLifecycle.startAsync();
contractWrappers = new ContractWrappers(provider, config);
exchangeContractAddress = contractWrappers.exchange.getContractAddress();
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
fillScenarios = new FillScenarios(
provider,
userAddresses,
zrxTokenAddress,
exchangeContractAddress,
contractWrappers.erc20Proxy.getContractAddress(),
contractWrappers.erc721Proxy.getContractAddress(),
);
[coinbase, makerAddress, takerAddress, feeRecipient, anotherMakerAddress] = userAddresses;
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
[makerAssetData, takerAssetData] = [
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
assetDataUtils.encodeERC20AssetData(takerTokenAddress),
];
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerAssetData,
takerAssetData,
makerAddress,
takerAddress,
fillableAmount,
);
});
after(async () => {
await blockchainLifecycle.revertAsync();
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
});
afterEach(async () => {
await blockchainLifecycle.revertAsync();
});
describe('#fillOrderAsync', () => {
it('should throw the revert reason when shouldValidate is true and a fill would revert', async () => {
// Create a scenario where the fill will revert
const makerTokenBalance = await contractWrappers.erc20Token.getBalanceAsync(
makerTokenAddress,
makerAddress,
);
// Transfer all of the tokens from maker to create a failure scenario
txHash = await contractWrappers.erc20Token.transferAsync(
makerTokenAddress,
makerAddress,
takerAddress,
makerTokenBalance,
);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
expect(
contractWrappers.exchange.fillOrderAsync(signedOrder, takerTokenFillAmount, takerAddress, {
shouldValidate: true,
}),
).to.be.rejectedWith('TRANSFER_FAILED');
});
});
});

View File

@@ -1,6 +1,6 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils'; import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { FillScenarios } from '@0xproject/fill-scenarios'; import { FillScenarios } from '@0xproject/fill-scenarios';
import { assetDataUtils, signatureUtils, generatePseudoRandomSalt, orderHashUtils } from '@0xproject/order-utils'; import { assetDataUtils, generatePseudoRandomSalt, orderHashUtils, signatureUtils } from '@0xproject/order-utils';
import { SignedOrder, SignerType } from '@0xproject/types'; import { SignedOrder, SignerType } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import 'mocha'; import 'mocha';

View File

@@ -65,10 +65,12 @@ export class {{contractName}}Contract extends BaseContract {
[{{> params inputs=ctor.inputs}}], [{{> params inputs=ctor.inputs}}],
BaseContract._bigNumberToString, BaseContract._bigNumberToString,
); );
const txData = ethers.Contract.getDeployTransaction(bytecode, abi, {{> params inputs=ctor.inputs}}); const iface = new ethers.Interface(abi);
const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, [{{> params inputs=ctor.inputs}}]);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
txData, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );

View File

@@ -8,10 +8,8 @@ async callAsync(
const inputAbi = self._lookupAbi(functionSignature).inputs; const inputAbi = self._lookupAbi(functionSignature).inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self)); [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
BaseContract.strictArgumentEncodingCheck(inputAbi, [{{> params inputs=inputs}}]); BaseContract.strictArgumentEncodingCheck(inputAbi, [{{> params inputs=inputs}}]);
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.{{this.name}}( const ethersFunction = self._lookupEthersInterface(functionSignature).functions.{{this.name}};
{{> params inputs=inputs}} const encodedData = ethersFunction.encode([{{> params inputs=inputs}}]);
) as ethers.CallDescription;
const encodedData = ethersFunction.data;
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@@ -21,7 +19,8 @@ async callAsync(
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
let resultArray = ethersFunction.parse(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
let resultArray = ethersFunction.decode(rawCallResult);
const outputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).outputs; const outputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).outputs;
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));

View File

@@ -12,9 +12,7 @@ public {{this.tsName}} = {
const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs; const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self)); [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
BaseContract.strictArgumentEncodingCheck(inputAbi, [{{> params inputs=inputs}}]); BaseContract.strictArgumentEncodingCheck(inputAbi, [{{> params inputs=inputs}}]);
const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}( const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]);
{{> params inputs=inputs}}
).data;
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@@ -37,9 +35,7 @@ public {{this.tsName}} = {
const self = this as any as {{contractName}}Contract; const self = this as any as {{contractName}}Contract;
const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs; const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString); [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString);
const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}( const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]);
{{> params inputs=inputs}}
).data;
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@@ -57,9 +53,7 @@ public {{this.tsName}} = {
const self = this as any as {{contractName}}Contract; const self = this as any as {{contractName}}Contract;
const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs; const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString); [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString);
const abiEncodedTransactionData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}( const abiEncodedTransactionData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]);
{{> params inputs=inputs}}
).data;
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
{{> callAsync}} {{> callAsync}}

View File

@@ -1,7 +1,7 @@
{ {
"private": true, "private": true,
"name": "contracts", "name": "contracts",
"version": "2.1.46", "version": "2.1.48",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -45,11 +45,11 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/abi-gen": "^1.0.10", "@0xproject/abi-gen": "^1.0.12",
"@0xproject/dev-utils": "^1.0.9", "@0xproject/dev-utils": "^1.0.11",
"@0xproject/sol-compiler": "^1.1.4", "@0xproject/sol-compiler": "^1.1.6",
"@0xproject/sol-cov": "^2.1.4", "@0xproject/sol-cov": "^2.1.6",
"@0xproject/subproviders": "^2.0.4", "@0xproject/subproviders": "^2.0.6",
"@0xproject/tslint-config": "^1.0.7", "@0xproject/tslint-config": "^1.0.7",
"@types/bn.js": "^4.11.0", "@types/bn.js": "^4.11.0",
"@types/ethereumjs-abi": "^0.6.0", "@types/ethereumjs-abi": "^0.6.0",
@@ -72,18 +72,18 @@
"yargs": "^10.0.3" "yargs": "^10.0.3"
}, },
"dependencies": { "dependencies": {
"@0xproject/base-contract": "^2.0.4", "@0xproject/base-contract": "^3.0.0",
"@0xproject/order-utils": "^1.0.4", "@0xproject/order-utils": "^1.0.6",
"@0xproject/types": "^1.1.0", "@0xproject/types": "^1.1.2",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"@types/js-combinatorics": "^0.5.29", "@types/js-combinatorics": "^0.5.29",
"bn.js": "^4.11.8", "bn.js": "^4.11.8",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"ethereumjs-abi": "0.6.5", "ethereumjs-abi": "0.6.5",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "^5.1.1",
"ethers": "3.0.22", "ethers": "4.0.0-beta.14",
"js-combinatorics": "^0.5.3", "js-combinatorics": "^0.5.3",
"lodash": "^4.17.5" "lodash": "^4.17.5"
} }

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "1.0.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.0.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "1.0.9", "version": "1.0.9",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.0.11 - _September 28, 2018_
* Dependencies updated
## v1.0.10 - _September 25, 2018_
* Dependencies updated
## v1.0.9 - _September 25, 2018_ ## v1.0.9 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/dev-utils", "name": "@0xproject/dev-utils",
"version": "1.0.9", "version": "1.0.11",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -42,12 +42,12 @@
"typescript": "3.0.1" "typescript": "3.0.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/subproviders": "^2.0.4", "@0xproject/subproviders": "^2.0.6",
"@0xproject/types": "^1.1.0", "@0xproject/types": "^1.1.2",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"lodash": "^4.17.5" "lodash": "^4.17.5"
}, },
"publishConfig": { "publishConfig": {

View File

@@ -14,6 +14,7 @@ import { env, EnvVars } from './env';
export interface Web3Config { export interface Web3Config {
hasAddresses?: boolean; // default: true hasAddresses?: boolean; // default: true
shouldUseInProcessGanache?: boolean; // default: false shouldUseInProcessGanache?: boolean; // default: false
shouldThrowErrorsOnGanacheRPCResponse?: boolean; // default: true
rpcUrl?: string; // default: localhost:8545 rpcUrl?: string; // default: localhost:8545
shouldUseFakeGasEstimate?: boolean; // default: true shouldUseFakeGasEstimate?: boolean; // default: true
} }
@@ -41,15 +42,19 @@ export const web3Factory = {
if (!_.isUndefined(config.rpcUrl)) { if (!_.isUndefined(config.rpcUrl)) {
throw new Error('Cannot use both GanacheSubrovider and RPCSubprovider'); throw new Error('Cannot use both GanacheSubrovider and RPCSubprovider');
} }
const shouldThrowErrorsOnGanacheRPCResponse =
_.isUndefined(config.shouldThrowErrorsOnGanacheRPCResponse) ||
config.shouldThrowErrorsOnGanacheRPCResponse;
provider.addProvider( provider.addProvider(
new GanacheSubprovider({ new GanacheSubprovider({
vmErrorsOnRPCResponse: shouldThrowErrorsOnGanacheRPCResponse,
gasLimit: constants.GAS_LIMIT, gasLimit: constants.GAS_LIMIT,
logger, logger,
verbose: env.parseBoolean(EnvVars.VerboseGanache), verbose: env.parseBoolean(EnvVars.VerboseGanache),
port: 8545, port: 8545,
network_id: 50, network_id: 50,
mnemonic: 'concert load couple harbor equip island argue ramp clarify fence smart topic', mnemonic: 'concert load couple harbor equip island argue ramp clarify fence smart topic',
}), } as any), // TODO remove any once types are merged in DefinitelyTyped
); );
} else { } else {
provider.addProvider(new RPCSubprovider(config.rpcUrl || constants.RPC_URL)); provider.addProvider(new RPCSubprovider(config.rpcUrl || constants.RPC_URL));

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "1.0.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.0.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537541580, "timestamp": 1537541580,
"version": "1.0.7", "version": "1.0.7",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.0.9 - _September 28, 2018_
* Dependencies updated
## v1.0.8 - _September 25, 2018_
* Dependencies updated
## v1.0.7 - _September 21, 2018_ ## v1.0.7 - _September 21, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "ethereum-types", "name": "ethereum-types",
"version": "1.0.7", "version": "1.0.9",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },

View File

@@ -181,6 +181,7 @@ export interface CallData extends CallTxDataBase {
export interface FilterObject { export interface FilterObject {
fromBlock?: number | string; fromBlock?: number | string;
toBlock?: number | string; toBlock?: number | string;
blockHash?: string;
address?: string; address?: string;
topics?: LogTopic[]; topics?: LogTopic[];
} }
@@ -324,9 +325,59 @@ export interface ContractNetworkData {
constructorArgs: string; constructorArgs: string;
} }
export type ParamDescription = string;
export interface StandardContractOutput { export interface StandardContractOutput {
abi: ContractAbi; abi: ContractAbi;
evm: EvmOutput; evm: EvmOutput;
devdoc?: DevdocOutput;
}
export interface StandardOutput {
errors: SolcError[];
sources: {
[fileName: string]: {
id: number;
ast?: object;
legacyAST?: object;
};
};
contracts: {
[fileName: string]: {
[contractName: string]: StandardContractOutput;
};
};
}
export type ErrorType =
| 'JSONError'
| 'IOError'
| 'ParserError'
| 'DocstringParsingError'
| 'SyntaxError'
| 'DeclarationError'
| 'TypeError'
| 'UnimplementedFeatureError'
| 'InternalCompilerError'
| 'Exception'
| 'CompilerError'
| 'FatalError'
| 'Warning';
export type ErrorSeverity = 'error' | 'warning';
export interface SolcError {
sourceLocation?: SourceLocation;
type: ErrorType;
component: 'general' | 'ewasm';
severity: ErrorSeverity;
message: string;
formattedMessage?: string;
}
export interface SourceLocation {
file: string;
start: number;
end: number;
} }
export interface EvmOutput { export interface EvmOutput {
@@ -339,6 +390,20 @@ export interface EvmBytecodeOutput {
sourceMap: string; sourceMap: string;
} }
export interface DevdocOutput {
title: string;
author: string;
methods: {
[signature: string]: {
details: string;
params: {
[name: string]: ParamDescription;
};
return?: string;
};
};
}
export interface ContractVersionData { export interface ContractVersionData {
compiler: CompilerOpts; compiler: CompilerOpts;
sources: { sources: {

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "1.0.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.0.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "1.0.4", "version": "1.0.4",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.0.6 - _September 28, 2018_
* Dependencies updated
## v1.0.5 - _September 25, 2018_
* Dependencies updated
## v1.0.4 - _September 25, 2018_ ## v1.0.4 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/fill-scenarios", "name": "@0xproject/fill-scenarios",
"version": "1.0.4", "version": "1.0.6",
"description": "0x order fill scenario generator", "description": "0x order fill scenario generator",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
@@ -26,7 +26,7 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/fill-scenarios/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/fill-scenarios/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/abi-gen": "^1.0.10", "@0xproject/abi-gen": "^1.0.12",
"@0xproject/tslint-config": "^1.0.7", "@0xproject/tslint-config": "^1.0.7",
"@types/lodash": "4.14.104", "@types/lodash": "4.14.104",
"copyfiles": "^2.0.0", "copyfiles": "^2.0.0",
@@ -37,14 +37,14 @@
"typescript": "3.0.1" "typescript": "3.0.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/base-contract": "^2.0.4", "@0xproject/base-contract": "^3.0.0",
"@0xproject/order-utils": "^1.0.4", "@0xproject/order-utils": "^1.0.6",
"@0xproject/types": "^1.1.0", "@0xproject/types": "^1.1.2",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"ethers": "3.0.22", "ethers": "4.0.0-beta.14",
"lodash": "^4.17.5" "lodash": "^4.17.5"
}, },
"publishConfig": { "publishConfig": {

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "1.0.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.0.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "1.0.3", "version": "1.0.3",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.0.5 - _September 28, 2018_
* Dependencies updated
## v1.0.4 - _September 25, 2018_
* Dependencies updated
## v1.0.3 - _September 25, 2018_ ## v1.0.3 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/json-schemas", "name": "@0xproject/json-schemas",
"version": "1.0.3", "version": "1.0.5",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -38,14 +38,14 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md",
"dependencies": { "dependencies": {
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@types/node": "*", "@types/node": "*",
"jsonschema": "^1.2.0", "jsonschema": "^1.2.0",
"lodash.values": "^4.3.0" "lodash.values": "^4.3.0"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^1.0.7", "@0xproject/tslint-config": "^1.0.7",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@types/lodash.foreach": "^4.5.3", "@types/lodash.foreach": "^4.5.3",
"@types/lodash.values": "^4.3.3", "@types/lodash.values": "^4.3.3",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/metacoin", "name": "@0xproject/metacoin",
"version": "0.0.20", "version": "0.0.22",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -28,25 +28,25 @@
"author": "", "author": "",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@0xproject/abi-gen": "^1.0.10", "@0xproject/abi-gen": "^1.0.12",
"@0xproject/base-contract": "^2.0.4", "@0xproject/base-contract": "^3.0.0",
"@0xproject/sol-cov": "^2.1.4", "@0xproject/sol-cov": "^2.1.6",
"@0xproject/subproviders": "^2.0.4", "@0xproject/subproviders": "^2.0.6",
"@0xproject/tslint-config": "^1.0.7", "@0xproject/tslint-config": "^1.0.7",
"@0xproject/types": "^1.1.0", "@0xproject/types": "^1.1.2",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"@types/mocha": "^5.2.2", "@types/mocha": "^5.2.2",
"copyfiles": "^2.0.0", "copyfiles": "^2.0.0",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"ethers": "3.0.22", "ethers": "4.0.0-beta.14",
"lodash": "^4.17.5", "lodash": "^4.17.5",
"run-s": "^0.0.0" "run-s": "^0.0.0"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/dev-utils": "^1.0.9", "@0xproject/dev-utils": "^1.0.11",
"@0xproject/sol-compiler": "^1.1.4", "@0xproject/sol-compiler": "^1.1.6",
"chai": "^4.0.1", "chai": "^4.0.1",
"chai-as-promised": "^7.1.0", "chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1", "chai-bignumber": "^2.0.1",

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "1.0.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.0.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "1.0.11", "version": "1.0.11",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.0.13 - _September 28, 2018_
* Dependencies updated
## v1.0.12 - _September 25, 2018_
* Dependencies updated
## v1.0.11 - _September 25, 2018_ ## v1.0.11 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/migrations", "name": "@0xproject/migrations",
"version": "1.0.11", "version": "1.0.13",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -30,10 +30,10 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"devDependencies": { "devDependencies": {
"@0xproject/abi-gen": "^1.0.10", "@0xproject/abi-gen": "^1.0.12",
"@0xproject/dev-utils": "^1.0.9", "@0xproject/dev-utils": "^1.0.11",
"@0xproject/tslint-config": "^1.0.7", "@0xproject/tslint-config": "^1.0.7",
"@0xproject/types": "^1.1.0", "@0xproject/types": "^1.1.2",
"@types/yargs": "^10.0.0", "@types/yargs": "^10.0.0",
"copyfiles": "^2.0.0", "copyfiles": "^2.0.0",
"make-promises-safe": "^1.1.0", "make-promises-safe": "^1.1.0",
@@ -44,16 +44,16 @@
"yargs": "^10.0.3" "yargs": "^10.0.3"
}, },
"dependencies": { "dependencies": {
"@0xproject/base-contract": "^2.0.4", "@0xproject/base-contract": "^3.0.0",
"@0xproject/order-utils": "^1.0.4", "@0xproject/order-utils": "^1.0.6",
"@0xproject/sol-compiler": "^1.1.4", "@0xproject/sol-compiler": "^1.1.6",
"@0xproject/subproviders": "^2.0.4", "@0xproject/subproviders": "^2.0.6",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"@ledgerhq/hw-app-eth": "^4.3.0", "@ledgerhq/hw-app-eth": "^4.3.0",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"ethers": "3.0.22", "ethers": "4.0.0-beta.14",
"lodash": "^4.17.5" "lodash": "^4.17.5"
}, },
"optionalDependencies": { "optionalDependencies": {

View File

@@ -1,7 +1,7 @@
{ {
"private": true, "private": true,
"name": "@0xproject/monorepo-scripts", "name": "@0xproject/monorepo-scripts",
"version": "1.0.9", "version": "1.0.10",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },

View File

@@ -1,3 +1,4 @@
import * as _ from 'lodash';
import * as yargs from 'yargs'; import * as yargs from 'yargs';
import { publishReleaseNotesAsync } from './utils/github_release_utils'; import { publishReleaseNotesAsync } from './utils/github_release_utils';
@@ -9,14 +10,25 @@ const args = yargs
type: 'boolean', type: 'boolean',
demandOption: true, demandOption: true,
}) })
.example('$0 --isDryRun true', 'Full usage example').argv; .option('packages', {
describe:
'Space-separated list of packages to generated release notes for. If not supplied, it does all `Lerna updated` packages.',
type: 'string',
})
.example('$0 --isDryRun true --packages "0x.js @0xproject/web3-wrapper"', 'Full usage example').argv;
(async () => { (async () => {
const isDryRun = args.isDryRun; const isDryRun = args.isDryRun;
let packages;
if (_.isUndefined(args.packages)) {
const shouldIncludePrivate = false; const shouldIncludePrivate = false;
const allUpdatedPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate); packages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate);
} else {
const packageNames = args.packages.split(' ');
packages = await utils.getPackagesByNameAsync(packageNames);
}
await publishReleaseNotesAsync(allUpdatedPackages, isDryRun); await publishReleaseNotesAsync(packages, isDryRun);
process.exit(0); process.exit(0);
})().catch(err => { })().catch(err => {
utils.log(err); utils.log(err);

View File

@@ -54,6 +54,13 @@ export const utils = {
} }
return packages; return packages;
}, },
async getPackagesByNameAsync(packageNames: string[]): Promise<Package[]> {
const allPackages = utils.getPackages(constants.monorepoRootPath);
const updatedPackages = _.filter(allPackages, pkg => {
return _.includes(packageNames, pkg.packageJson.name);
});
return updatedPackages;
},
async getUpdatedPackagesAsync(shouldIncludePrivate: boolean): Promise<Package[]> { async getUpdatedPackagesAsync(shouldIncludePrivate: boolean): Promise<Package[]> {
const updatedPublicPackages = await utils.getLernaUpdatedPackagesAsync(shouldIncludePrivate); const updatedPublicPackages = await utils.getLernaUpdatedPackagesAsync(shouldIncludePrivate);
const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name); const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name);

View File

@@ -1,4 +1,24 @@
[ [
{
"version": "1.0.6",
"changes": [
{
"note":
"Add signerAddress normalization to `isValidECSignature` to avoid `invalid address recovery` error if caller supplies a checksummed address",
"pr": 1096
}
],
"timestamp": 1538157789
},
{
"timestamp": 1537907159,
"version": "1.0.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "1.0.4", "version": "1.0.4",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.0.6 - _September 28, 2018_
* Add signerAddress normalization to `isValidECSignature` to avoid `invalid address recovery` error if caller supplies a checksummed address (#1096)
## v1.0.5 - _September 25, 2018_
* Dependencies updated
## v1.0.4 - _September 25, 2018_ ## v1.0.4 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/order-utils", "name": "@0xproject/order-utils",
"version": "1.0.4", "version": "1.0.6",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -38,7 +38,7 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/dev-utils": "^1.0.9", "@0xproject/dev-utils": "^1.0.11",
"@0xproject/tslint-config": "^1.0.7", "@0xproject/tslint-config": "^1.0.7",
"@types/bn.js": "^4.11.0", "@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104", "@types/lodash": "4.14.104",
@@ -57,19 +57,19 @@
"typescript": "3.0.1" "typescript": "3.0.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/assert": "^1.0.10", "@0xproject/assert": "^1.0.12",
"@0xproject/base-contract": "^2.0.4", "@0xproject/base-contract": "^3.0.0",
"@0xproject/json-schemas": "^1.0.3", "@0xproject/json-schemas": "^1.0.5",
"@0xproject/types": "^1.1.0", "@0xproject/types": "^1.1.2",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"@types/node": "*", "@types/node": "*",
"bn.js": "^4.11.8", "bn.js": "^4.11.8",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"ethereumjs-abi": "0.6.5", "ethereumjs-abi": "0.6.5",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "^5.1.1",
"ethers": "3.0.22", "ethers": "4.0.0-beta.14",
"lodash": "^4.17.5" "lodash": "^4.17.5"
}, },
"publishConfig": { "publishConfig": {

View File

@@ -114,7 +114,7 @@ export class OrderStateUtils {
* @return State relevant to the signedOrder, as well as whether the signedOrder is "valid". * @return State relevant to the signedOrder, as well as whether the signedOrder is "valid".
* Validity is defined as a non-zero amount of the order can still be filled. * Validity is defined as a non-zero amount of the order can still be filled.
*/ */
public async getOpenOrderStateAsync(signedOrder: SignedOrder): Promise<OrderState> { public async getOpenOrderStateAsync(signedOrder: SignedOrder, transactionHash?: string): Promise<OrderState> {
const orderRelevantState = await this.getOpenOrderRelevantStateAsync(signedOrder); const orderRelevantState = await this.getOpenOrderRelevantStateAsync(signedOrder);
const orderHash = orderHashUtils.getOrderHashHex(signedOrder); const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const isOrderCancelled = await this._orderFilledCancelledFetcher.isOrderCancelledAsync(orderHash); const isOrderCancelled = await this._orderFilledCancelledFetcher.isOrderCancelledAsync(orderHash);
@@ -134,6 +134,7 @@ export class OrderStateUtils {
isValid: true, isValid: true,
orderHash, orderHash,
orderRelevantState, orderRelevantState,
transactionHash,
}; };
return orderState; return orderState;
} else { } else {
@@ -141,6 +142,7 @@ export class OrderStateUtils {
isValid: false, isValid: false,
orderHash, orderHash,
error: orderValidationResult.error, error: orderValidationResult.error,
transactionHash,
}; };
return orderState; return orderState;
} }

View File

@@ -174,6 +174,7 @@ export const signatureUtils = {
assert.isHexString('data', data); assert.isHexString('data', data);
assert.doesConformToSchema('signature', signature, schemas.ecSignatureSchema); assert.doesConformToSchema('signature', signature, schemas.ecSignatureSchema);
assert.isETHAddressHex('signerAddress', signerAddress); assert.isETHAddressHex('signerAddress', signerAddress);
const normalizedSignerAddress = signerAddress.toLowerCase();
const msgHashBuff = ethUtil.toBuffer(data); const msgHashBuff = ethUtil.toBuffer(data);
try { try {
@@ -184,7 +185,8 @@ export const signatureUtils = {
ethUtil.toBuffer(signature.s), ethUtil.toBuffer(signature.s),
); );
const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey)); const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey));
return retrievedAddress === signerAddress; const normalizedRetrievedAddress = retrievedAddress.toLowerCase();
return normalizedRetrievedAddress === normalizedSignerAddress;
} catch (err) { } catch (err) {
return false; return false;
} }

View File

@@ -120,5 +120,25 @@ describe('OrderStateUtils', () => {
const orderState = await orderStateUtils.getOpenOrderStateAsync(signedOrder); const orderState = await orderStateUtils.getOpenOrderStateAsync(signedOrder);
expect(orderState.isValid).to.eq(false); expect(orderState.isValid).to.eq(false);
}); });
it('should include the transactionHash in orderState if supplied in method invocation', async () => {
const makerAssetAmount = new BigNumber(10);
const takerAssetAmount = new BigNumber(10000000000000000);
const takerBalance = takerAssetAmount;
const orderFilledAmount = new BigNumber(0);
const mockBalanceFetcher = buildMockBalanceFetcher(takerBalance);
const mockOrderFilledFetcher = buildMockOrderFilledFetcher(orderFilledAmount);
const [signedOrder] = testOrderFactory.generateTestSignedOrders(
{
makerAssetAmount,
takerAssetAmount,
},
1,
);
const orderStateUtils = new OrderStateUtils(mockBalanceFetcher, mockOrderFilledFetcher);
const transactionHash = '0xdeadbeef';
const orderState = await orderStateUtils.getOpenOrderStateAsync(signedOrder, transactionHash);
expect(orderState.transactionHash).to.eq(transactionHash);
});
}); });
}); });

View File

@@ -1,21 +1,52 @@
[ [
{ {
"timestamp": 1537875740, "version": "2.1.0",
"changes": [
{
"note": "Export ExpirationWatcher",
"pr": 1097
}
],
"timestamp": 1538157789
},
{
"version": "2.0.0",
"changes": [
{
"note":
"Fixes dropped events issue by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too.",
"pr": 1080
},
{
"note":
"Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it",
"pr": 1080
},
{
"note":
"Add `transactionHash` to `OrderState` emitted by `OrderWatcher` subscriptions if the order's state change originated from a transaction.",
"pr": 1087
}
],
"timestamp": 1537907159
},
{
"version": "1.0.5", "version": "1.0.5",
"changes": [ "changes": [
{ {
"note": "Dependencies updated" "note": "Dependencies updated"
} }
] ],
"timestamp": 1537875740
}, },
{ {
"timestamp": 1537541580,
"version": "1.0.4", "version": "1.0.4",
"changes": [ "changes": [
{ {
"note": "Dependencies updated" "note": "Dependencies updated"
} }
] ],
"timestamp": 1537541580
}, },
{ {
"version": "1.0.3", "version": "1.0.3",

View File

@@ -5,6 +5,16 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v2.1.0 - _September 28, 2018_
* Export ExpirationWatcher (#1097)
## v2.0.0 - _September 25, 2018_
* Fixes dropped events issue by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too. (#1080)
* Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it (#1080)
* Add `transactionHash` to `OrderState` emitted by `OrderWatcher` subscriptions if the order's state change originated from a transaction. (#1087)
## v1.0.5 - _September 25, 2018_ ## v1.0.5 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/order-watcher", "name": "@0xproject/order-watcher",
"version": "1.0.5", "version": "2.1.0",
"description": "An order watcher daemon that watches for order validity", "description": "An order watcher daemon that watches for order validity",
"keywords": [ "keywords": [
"0x", "0x",
@@ -42,9 +42,9 @@
"node": ">=6.0.0" "node": ">=6.0.0"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/abi-gen": "^1.0.10", "@0xproject/abi-gen": "^1.0.12",
"@0xproject/dev-utils": "^1.0.9", "@0xproject/dev-utils": "^1.0.11",
"@0xproject/migrations": "^1.0.11", "@0xproject/migrations": "^1.0.13",
"@0xproject/tslint-config": "^1.0.7", "@0xproject/tslint-config": "^1.0.7",
"@types/bintrees": "^1.0.2", "@types/bintrees": "^1.0.2",
"@types/lodash": "4.14.104", "@types/lodash": "4.14.104",
@@ -70,20 +70,20 @@
"typescript": "3.0.1" "typescript": "3.0.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/assert": "^1.0.10", "@0xproject/assert": "^1.0.12",
"@0xproject/base-contract": "^2.0.4", "@0xproject/base-contract": "^3.0.0",
"@0xproject/contract-wrappers": "^1.0.5", "@0xproject/contract-wrappers": "^2.0.1",
"@0xproject/fill-scenarios": "^1.0.4", "@0xproject/fill-scenarios": "^1.0.6",
"@0xproject/json-schemas": "^1.0.3", "@0xproject/json-schemas": "^1.0.5",
"@0xproject/order-utils": "^1.0.4", "@0xproject/order-utils": "^1.0.6",
"@0xproject/types": "^1.1.0", "@0xproject/types": "^1.1.2",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"bintrees": "^1.0.2", "bintrees": "^1.0.2",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"ethereumjs-blockstream": "5.0.0", "ethereumjs-blockstream": "6.0.0",
"ethers": "3.0.22", "ethers": "4.0.0-beta.14",
"lodash": "^4.17.5" "lodash": "^4.17.5"
}, },
"publishConfig": { "publishConfig": {

View File

@@ -1,4 +1,5 @@
export { OrderWatcher } from './order_watcher/order_watcher'; export { OrderWatcher } from './order_watcher/order_watcher';
export { ExpirationWatcher } from './order_watcher/expiration_watcher';
export { export {
OrderStateValid, OrderStateValid,

View File

@@ -1,6 +1,6 @@
import { intervalUtils, logUtils } from '@0xproject/utils'; import { intervalUtils, logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { marshaller, Web3Wrapper } from '@0xproject/web3-wrapper';
import { BlockParamLiteral, BlockWithoutTransactionData, LogEntry, Provider } from 'ethereum-types'; import { BlockParamLiteral, FilterObject, LogEntry, Provider, RawLogEntry } from 'ethereum-types';
import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream'; import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream';
import * as _ from 'lodash'; import * as _ from 'lodash';
@@ -20,7 +20,6 @@ enum LogEventState {
*/ */
export class EventWatcher { export class EventWatcher {
private readonly _web3Wrapper: Web3Wrapper; private readonly _web3Wrapper: Web3Wrapper;
private readonly _stateLayer: BlockParamLiteral;
private readonly _isVerbose: boolean; private readonly _isVerbose: boolean;
private _blockAndLogStreamerIfExists: BlockAndLogStreamer<Block, Log> | undefined; private _blockAndLogStreamerIfExists: BlockAndLogStreamer<Block, Log> | undefined;
private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer; private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer;
@@ -35,7 +34,6 @@ export class EventWatcher {
) { ) {
this._isVerbose = isVerbose; this._isVerbose = isVerbose;
this._web3Wrapper = new Web3Wrapper(provider); this._web3Wrapper = new Web3Wrapper(provider);
this._stateLayer = stateLayer;
this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs) this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs)
? DEFAULT_EVENT_POLLING_INTERVAL_MS ? DEFAULT_EVENT_POLLING_INTERVAL_MS
: pollingIntervalIfExistsMs; : pollingIntervalIfExistsMs;
@@ -62,8 +60,8 @@ export class EventWatcher {
throw new Error(OrderWatcherError.SubscriptionAlreadyPresent); throw new Error(OrderWatcherError.SubscriptionAlreadyPresent);
} }
this._blockAndLogStreamerIfExists = new BlockAndLogStreamer( this._blockAndLogStreamerIfExists = new BlockAndLogStreamer(
this._getBlockOrNullAsync.bind(this), this._blockstreamGetBlockOrNullAsync.bind(this),
this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper), this._blockstreamGetLogsAsync.bind(this),
this._onBlockAndLogStreamerError.bind(this), this._onBlockAndLogStreamerError.bind(this),
); );
const catchAllLogFilter = {}; const catchAllLogFilter = {};
@@ -83,12 +81,30 @@ export class EventWatcher {
); );
} }
// This method only exists in order to comply with the expected interface of Blockstream's constructor // This method only exists in order to comply with the expected interface of Blockstream's constructor
private async _getBlockOrNullAsync(): Promise<BlockWithoutTransactionData | null> { private async _blockstreamGetBlockOrNullAsync(hash: string): Promise<Block | null> {
const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper); const shouldIncludeTransactionData = false;
if (_.isUndefined(blockIfExists)) { const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync<Block | null>({
return null; method: 'eth_getBlockByHash',
params: [hash, shouldIncludeTransactionData],
});
return blockOrNull;
} }
return blockIfExists; // This method only exists in order to comply with the expected interface of Blockstream's constructor
private async _blockstreamGetLatestBlockOrNullAsync(): Promise<Block | null> {
const shouldIncludeTransactionData = false;
const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync<Block | null>({
method: 'eth_getBlockByNumber',
params: [BlockParamLiteral.Latest, shouldIncludeTransactionData],
});
return blockOrNull;
}
// This method only exists in order to comply with the expected interface of Blockstream's constructor
private async _blockstreamGetLogsAsync(filterOptions: FilterObject): Promise<RawLogEntry[]> {
const logs = await this._web3Wrapper.sendRawPayloadAsync<RawLogEntry[]>({
method: 'eth_getLogs',
params: [filterOptions],
});
return logs as RawLogEntry[];
} }
private _stopBlockAndLogStream(): void { private _stopBlockAndLogStream(): void {
if (_.isUndefined(this._blockAndLogStreamerIfExists)) { if (_.isUndefined(this._blockAndLogStreamerIfExists)) {
@@ -103,19 +119,20 @@ export class EventWatcher {
private async _onLogStateChangedAsync( private async _onLogStateChangedAsync(
callback: EventWatcherCallback, callback: EventWatcherCallback,
isRemoved: boolean, isRemoved: boolean,
log: LogEntry, rawLog: RawLogEntry,
): Promise<void> { ): Promise<void> {
const log: LogEntry = marshaller.unmarshalLog(rawLog);
await this._emitDifferencesAsync(log, isRemoved ? LogEventState.Removed : LogEventState.Added, callback); await this._emitDifferencesAsync(log, isRemoved ? LogEventState.Removed : LogEventState.Added, callback);
} }
private async _reconcileBlockAsync(): Promise<void> { private async _reconcileBlockAsync(): Promise<void> {
const latestBlockIfExists = await this._web3Wrapper.getBlockIfExistsAsync(this._stateLayer); const latestBlockOrNull = await this._blockstreamGetLatestBlockOrNullAsync();
if (_.isUndefined(latestBlockIfExists)) { if (_.isNull(latestBlockOrNull)) {
return; // noop return; // noop
} }
// We need to coerce to Block type cause Web3.Block includes types for mempool blocks // We need to coerce to Block type cause Web3.Block includes types for mempool blocks
if (!_.isUndefined(this._blockAndLogStreamerIfExists)) { if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
// If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined
await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockIfExists as any) as Block); await this._blockAndLogStreamerIfExists.reconcileNewBlock(latestBlockOrNull);
} }
} }
private async _emitDifferencesAsync( private async _emitDifferencesAsync(

View File

@@ -275,6 +275,7 @@ export class OrderWatcher {
return; // noop return; // noop
} }
const decodedLog = (maybeDecodedLog as any) as LogWithDecodedArgs<ContractEventArgs>; const decodedLog = (maybeDecodedLog as any) as LogWithDecodedArgs<ContractEventArgs>;
const transactionHash = decodedLog.transactionHash;
switch (decodedLog.event) { switch (decodedLog.event) {
case ERC20TokenEvents.Approval: case ERC20TokenEvents.Approval:
case ERC721TokenEvents.Approval: { case ERC721TokenEvents.Approval: {
@@ -290,7 +291,7 @@ export class OrderWatcher {
args._owner, args._owner,
tokenAssetData, tokenAssetData,
); );
await this._emitRevalidateOrdersAsync(orderHashes); await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break; break;
} else { } else {
// ERC721 // ERC721
@@ -303,7 +304,7 @@ export class OrderWatcher {
args._owner, args._owner,
tokenAssetData, tokenAssetData,
); );
await this._emitRevalidateOrdersAsync(orderHashes); await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break; break;
} }
} }
@@ -322,7 +323,7 @@ export class OrderWatcher {
args._from, args._from,
tokenAssetData, tokenAssetData,
); );
await this._emitRevalidateOrdersAsync(orderHashes); await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break; break;
} else { } else {
// ERC721 // ERC721
@@ -336,7 +337,7 @@ export class OrderWatcher {
args._from, args._from,
tokenAssetData, tokenAssetData,
); );
await this._emitRevalidateOrdersAsync(orderHashes); await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break; break;
} }
} }
@@ -350,7 +351,7 @@ export class OrderWatcher {
args._owner, args._owner,
tokenAddress, tokenAddress,
); );
await this._emitRevalidateOrdersAsync(orderHashes); await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break; break;
} }
case WETH9Events.Deposit: { case WETH9Events.Deposit: {
@@ -363,7 +364,7 @@ export class OrderWatcher {
args._owner, args._owner,
tokenAssetData, tokenAssetData,
); );
await this._emitRevalidateOrdersAsync(orderHashes); await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break; break;
} }
case WETH9Events.Withdrawal: { case WETH9Events.Withdrawal: {
@@ -376,7 +377,7 @@ export class OrderWatcher {
args._owner, args._owner,
tokenAssetData, tokenAssetData,
); );
await this._emitRevalidateOrdersAsync(orderHashes); await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break; break;
} }
case ExchangeEvents.Fill: { case ExchangeEvents.Fill: {
@@ -387,7 +388,7 @@ export class OrderWatcher {
const orderHash = args.orderHash; const orderHash = args.orderHash;
const isOrderWatched = !_.isUndefined(this._orderByOrderHash[orderHash]); const isOrderWatched = !_.isUndefined(this._orderByOrderHash[orderHash]);
if (isOrderWatched) { if (isOrderWatched) {
await this._emitRevalidateOrdersAsync([orderHash]); await this._emitRevalidateOrdersAsync([orderHash], transactionHash);
} }
break; break;
} }
@@ -399,7 +400,7 @@ export class OrderWatcher {
const orderHash = args.orderHash; const orderHash = args.orderHash;
const isOrderWatched = !_.isUndefined(this._orderByOrderHash[orderHash]); const isOrderWatched = !_.isUndefined(this._orderByOrderHash[orderHash]);
if (isOrderWatched) { if (isOrderWatched) {
await this._emitRevalidateOrdersAsync([orderHash]); await this._emitRevalidateOrdersAsync([orderHash], transactionHash);
} }
break; break;
} }
@@ -410,7 +411,7 @@ export class OrderWatcher {
this._orderFilledCancelledLazyStore.deleteAllIsCancelled(); this._orderFilledCancelledLazyStore.deleteAllIsCancelled();
// Revalidate orders // Revalidate orders
const orderHashes = this._dependentOrderHashesTracker.getDependentOrderHashesByMaker(args.makerAddress); const orderHashes = this._dependentOrderHashesTracker.getDependentOrderHashesByMaker(args.makerAddress);
await this._emitRevalidateOrdersAsync(orderHashes); await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break; break;
} }
@@ -418,12 +419,12 @@ export class OrderWatcher {
throw errorUtils.spawnSwitchErr('decodedLog.event', decodedLog.event); throw errorUtils.spawnSwitchErr('decodedLog.event', decodedLog.event);
} }
} }
private async _emitRevalidateOrdersAsync(orderHashes: string[]): Promise<void> { private async _emitRevalidateOrdersAsync(orderHashes: string[], transactionHash?: string): Promise<void> {
for (const orderHash of orderHashes) { for (const orderHash of orderHashes) {
const signedOrder = this._orderByOrderHash[orderHash]; const signedOrder = this._orderByOrderHash[orderHash];
// Most of these calls will never reach the network because the data is fetched from stores // Most of these calls will never reach the network because the data is fetched from stores
// and only updated when cache is invalidated // and only updated when cache is invalidated
const orderState = await this._orderStateUtils.getOpenOrderStateAsync(signedOrder); const orderState = await this._orderStateUtils.getOpenOrderStateAsync(signedOrder, transactionHash);
if (_.isUndefined(this._callbackIfExists)) { if (_.isUndefined(this._callbackIfExists)) {
break; // Unsubscribe was called break; // Unsubscribe was called
} }

View File

@@ -250,6 +250,32 @@ describe('OrderWatcher', () => {
await contractWrappers.exchange.fillOrderAsync(signedOrder, fillableAmount, takerAddress); await contractWrappers.exchange.fillOrderAsync(signedOrder, fillableAmount, takerAddress);
})().catch(done); })().catch(done);
}); });
it('should include transactionHash in emitted orderStateInvalid when watched order fully filled', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerAssetData,
takerAssetData,
makerAddress,
takerAddress,
fillableAmount,
);
await orderWatcher.addOrderAsync(signedOrder);
let transactionHash: string;
const callback = callbackErrorReporter.reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.false();
const invalidOrderState = orderState as OrderStateInvalid;
expect(invalidOrderState.transactionHash).to.be.equal(transactionHash);
});
orderWatcher.subscribe(callback);
transactionHash = await contractWrappers.exchange.fillOrderAsync(
signedOrder,
fillableAmount,
takerAddress,
);
})().catch(done);
});
it('should emit orderStateValid when watched order partially filled', (done: DoneCallback) => { it('should emit orderStateValid when watched order partially filled', (done: DoneCallback) => {
(async () => { (async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync( signedOrder = await fillScenarios.createFillableSignedOrderAsync(

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "1.0.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.0.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "1.0.10", "version": "1.0.10",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.0.12 - _September 28, 2018_
* Dependencies updated
## v1.0.11 - _September 25, 2018_
* Dependencies updated
## v1.0.10 - _September 25, 2018_ ## v1.0.10 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -2,7 +2,7 @@
#### WARNING: Alpha software. Expect things to break when trying to use. #### WARNING: Alpha software. Expect things to break when trying to use.
A full-page React component for rendering beautiful documentation for Solidity and Typescript code generated with [TypeDoc](http://typedoc.org/) or [Doxity](https://github.com/0xproject/doxity). A full-page React component for rendering beautiful documentation for Solidity and Typescript code generated with [TypeDoc](http://typedoc.org/) or [sol-doc](https://github.com/0xProject/0x-monorepo/tree/development/packages/sol-doc).
<div style="text-align: center;"> <div style="text-align: center;">
<img src="https://s3.eu-west-2.amazonaws.com/0x-wiki-images/screenshot.png" style="padding-bottom: 20px; padding-top: 20px;" width="80%" /> <img src="https://s3.eu-west-2.amazonaws.com/0x-wiki-images/screenshot.png" style="padding-bottom: 20px; padding-top: 20px;" width="80%" />
@@ -47,7 +47,7 @@ Feel free to contribute to these improvements!
* Allow user to pass in styling for all major elements similar to [Material-UI](http://www.material-ui.com/). * Allow user to pass in styling for all major elements similar to [Material-UI](http://www.material-ui.com/).
* Allow user to define an alternative font and have it change everywhere. * Allow user to define an alternative font and have it change everywhere.
* Add source links to Solidity docs (currently unsupported by Doxity). * Add source links to Solidity docs (currently unsupported by solc, which underlies sol-doc).
## Contributing ## Contributing

View File

@@ -1,10 +1,10 @@
{ {
"name": "@0xproject/react-docs", "name": "@0xproject/react-docs",
"version": "1.0.10", "version": "1.0.12",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
"description": "React documentation component for rendering TypeDoc & Doxity generated JSON", "description": "React documentation component for rendering TypeDoc & sol-doc generated JSON",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
"scripts": { "scripts": {
@@ -23,7 +23,7 @@
"url": "https://github.com/0xProject/0x-monorepo.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/dev-utils": "^1.0.9", "@0xproject/dev-utils": "^1.0.11",
"@0xproject/tslint-config": "^1.0.7", "@0xproject/tslint-config": "^1.0.7",
"@types/compare-versions": "^3.0.0", "@types/compare-versions": "^3.0.0",
"copyfiles": "^2.0.0", "copyfiles": "^2.0.0",
@@ -33,8 +33,9 @@
"typescript": "3.0.1" "typescript": "3.0.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/react-shared": "^1.0.11", "@0xproject/react-shared": "^1.0.13",
"@0xproject/utils": "^1.0.10", "@0xproject/types": "^1.1.2",
"@0xproject/utils": "^2.0.0",
"@types/lodash": "4.14.104", "@types/lodash": "4.14.104",
"@types/material-ui": "^0.20.0", "@types/material-ui": "^0.20.0",
"@types/node": "*", "@types/node": "*",

View File

@@ -2,7 +2,7 @@ import { logUtils } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { CustomType } from '../types'; import { CustomType } from '@0xproject/types';
const STRING_ENUM_CODE_PREFIX = ' strEnum('; const STRING_ENUM_CODE_PREFIX = ' strEnum(';

View File

@@ -9,24 +9,23 @@ import {
Styles, Styles,
utils as sharedUtils, utils as sharedUtils,
} from '@0xproject/react-shared'; } from '@0xproject/react-shared';
import {
DocAgnosticFormat,
Event,
ExternalExportToLink,
Property,
SolidityMethod,
TypeDefinitionByName,
TypescriptFunction,
TypescriptMethod,
} from '@0xproject/types';
import * as _ from 'lodash'; import * as _ from 'lodash';
import CircularProgress from 'material-ui/CircularProgress'; import CircularProgress from 'material-ui/CircularProgress';
import * as React from 'react'; import * as React from 'react';
import * as semver from 'semver'; import * as semver from 'semver';
import { DocsInfo } from '../docs_info'; import { DocsInfo } from '../docs_info';
import { import { AddressByContractName, SupportedDocJson } from '../types';
AddressByContractName,
DocAgnosticFormat,
Event,
ExternalExportToLink,
Property,
SolidityMethod,
SupportedDocJson,
TypeDefinitionByName,
TypescriptFunction,
TypescriptMethod,
} from '../types';
import { constants } from '../utils/constants'; import { constants } from '../utils/constants';
import { Badge } from './badge'; import { Badge } from './badge';
@@ -330,7 +329,7 @@ export class Documentation extends React.Component<DocumentationProps, Documenta
return <div>{externalExports}</div>; return <div>{externalExports}</div>;
} }
private _renderNetworkBadgesIfExists(sectionName: string): React.ReactNode { private _renderNetworkBadgesIfExists(sectionName: string): React.ReactNode {
if (this.props.docsInfo.type !== SupportedDocJson.Doxity) { if (this.props.docsInfo.type !== SupportedDocJson.SolDoc) {
return null; return null;
} }

View File

@@ -1,9 +1,9 @@
import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared'; import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared';
import { Event, EventArg } from '@0xproject/types';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { DocsInfo } from '../docs_info'; import { DocsInfo } from '../docs_info';
import { Event, EventArg } from '../types';
import { Type } from './type'; import { Type } from './type';

View File

@@ -1,8 +1,9 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { CustomType, TypeDefinitionByName } from '@0xproject/types';
import { DocsInfo } from '../docs_info'; import { DocsInfo } from '../docs_info';
import { CustomType, TypeDefinitionByName } from '../types';
import { Signature } from './signature'; import { Signature } from './signature';
import { Type } from './type'; import { Type } from './type';

View File

@@ -1,8 +1,8 @@
import { AnchorTitle, HeaderSizes } from '@0xproject/react-shared'; import { AnchorTitle, HeaderSizes } from '@0xproject/react-shared';
import { Property, TypeDefinitionByName } from '@0xproject/types';
import * as React from 'react'; import * as React from 'react';
import { DocsInfo } from '../docs_info'; import { DocsInfo } from '../docs_info';
import { Property, TypeDefinitionByName } from '../types';
import { constants } from '../utils/constants'; import { constants } from '../utils/constants';
import { Comment } from './comment'; import { Comment } from './comment';

View File

@@ -1,8 +1,9 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { Parameter, Type as TypeDef, TypeDefinitionByName, TypeParameter } from '@0xproject/types';
import { DocsInfo } from '../docs_info'; import { DocsInfo } from '../docs_info';
import { Parameter, Type as TypeDef, TypeDefinitionByName, TypeParameter } from '../types';
import { Type } from './type'; import { Type } from './type';
@@ -134,7 +135,10 @@ function renderTypeParameter(
): React.ReactNode { ): React.ReactNode {
const typeParam = ( const typeParam = (
<span> <span>
{`<${typeParameter.name} extends `} {`<${typeParameter.name}`}
{!_.isUndefined(typeParameter.type) && (
<span>
{' extends '}
<Type <Type
type={typeParameter.type} type={typeParameter.type}
sectionName={sectionName} sectionName={sectionName}
@@ -142,6 +146,8 @@ function renderTypeParameter(
docsInfo={docsInfo} docsInfo={docsInfo}
isInPopover={isInPopover} isInPopover={isInPopover}
/> />
</span>
)}
{`>`} {`>`}
</span> </span>
); );

View File

@@ -1,9 +1,15 @@
import { AnchorTitle, colors, HeaderSizes, Styles } from '@0xproject/react-shared'; import { AnchorTitle, colors, HeaderSizes, Styles } from '@0xproject/react-shared';
import {
Parameter,
SolidityMethod,
TypeDefinitionByName,
TypescriptFunction,
TypescriptMethod,
} from '@0xproject/types';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { DocsInfo } from '../docs_info'; import { DocsInfo } from '../docs_info';
import { Parameter, SolidityMethod, TypeDefinitionByName, TypescriptFunction, TypescriptMethod } from '../types';
import { constants } from '../utils/constants'; import { constants } from '../utils/constants';
import { Comment } from './comment'; import { Comment } from './comment';

View File

@@ -1,8 +1,7 @@
import { colors } from '@0xproject/react-shared'; import { colors } from '@0xproject/react-shared';
import { Source } from '@0xproject/types';
import * as React from 'react'; import * as React from 'react';
import { Source } from '../types';
export interface SourceLinkProps { export interface SourceLinkProps {
source: Source; source: Source;
sourceUrl: string; sourceUrl: string;

View File

@@ -1,4 +1,5 @@
import { colors, constants as sharedConstants, utils as sharedUtils } from '@0xproject/react-shared'; import { colors, constants as sharedConstants, utils as sharedUtils } from '@0xproject/react-shared';
import { Type as TypeDef, TypeDefinitionByName, TypeDocTypes } from '@0xproject/types';
import { errorUtils } from '@0xproject/utils'; import { errorUtils } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
@@ -6,7 +7,6 @@ import { Link as ScrollLink } from 'react-scroll';
import * as ReactTooltip from 'react-tooltip'; import * as ReactTooltip from 'react-tooltip';
import { DocsInfo } from '../docs_info'; import { DocsInfo } from '../docs_info';
import { Type as TypeDef, TypeDefinitionByName, TypeDocTypes } from '../types';
import { constants } from '../utils/constants'; import { constants } from '../utils/constants';
import { Signature } from './signature'; import { Signature } from './signature';

View File

@@ -1,10 +1,11 @@
import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared'; import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared';
import { CustomType, CustomTypeChild, TypeDefinitionByName, TypeDocTypes } from '@0xproject/types';
import { errorUtils } from '@0xproject/utils'; import { errorUtils } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as React from 'react'; import * as React from 'react';
import { DocsInfo } from '../docs_info'; import { DocsInfo } from '../docs_info';
import { CustomType, CustomTypeChild, KindString, TypeDefinitionByName, TypeDocTypes } from '../types'; import { KindString } from '../types';
import { constants } from '../utils/constants'; import { constants } from '../utils/constants';
import { Comment } from './comment'; import { Comment } from './comment';

View File

@@ -1,20 +1,15 @@
import { MenuSubsectionsBySection } from '@0xproject/react-shared'; import { MenuSubsectionsBySection } from '@0xproject/react-shared';
import { DocAgnosticFormat, TypeDefinitionByName } from '@0xproject/types';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { import {
ContractsByVersionByNetworkId, ContractsByVersionByNetworkId,
DocAgnosticFormat,
DocsInfoConfig, DocsInfoConfig,
DocsMenu, DocsMenu,
DoxityDocObj,
GeneratedDocJson,
SectionNameToMarkdownByVersion, SectionNameToMarkdownByVersion,
SectionsMap, SectionsMap,
SupportedDocJson, SupportedDocJson,
TypeDefinitionByName,
} from './types'; } from './types';
import { doxityUtils } from './utils/doxity_utils';
import { TypeDocUtils } from './utils/typedoc_utils';
export class DocsInfo { export class DocsInfo {
public id: string; public id: string;
@@ -95,12 +90,4 @@ export class DocsInfo {
const typeDefinitionByName = _.keyBy(typeDocSection.types, 'name') as any; const typeDefinitionByName = _.keyBy(typeDocSection.types, 'name') as any;
return typeDefinitionByName; return typeDefinitionByName;
} }
public convertToDocAgnosticFormat(docObj: DoxityDocObj | GeneratedDocJson): DocAgnosticFormat {
if (this.type === SupportedDocJson.Doxity) {
return doxityUtils.convertToDocAgnosticFormat(docObj as DoxityDocObj);
} else {
const typeDocUtils = new TypeDocUtils(docObj as GeneratedDocJson, this);
return typeDocUtils.convertToDocAgnosticFormat();
}
}
} }

View File

@@ -1,3 +1,5 @@
export { DocAgnosticFormat, GeneratedDocJson } from '@0xproject/types';
// Exported to give users of this library added flexibility if they want to build // Exported to give users of this library added flexibility if they want to build
// a docs page from scratch using the individual components. // a docs page from scratch using the individual components.
export { Badge } from './components/badge'; export { Badge } from './components/badge';
@@ -12,17 +14,10 @@ export { Signature } from './components/signature';
export { SourceLink } from './components/source_link'; export { SourceLink } from './components/source_link';
export { TypeDefinition } from './components/type_definition'; export { TypeDefinition } from './components/type_definition';
export { Type } from './components/type'; export { Type } from './components/type';
export { TypeDocUtils } from './utils/typedoc_utils';
export { DocsInfo } from './docs_info'; export { DocsInfo } from './docs_info';
export { export { DocsInfoConfig, DocsMenu, SupportedDocJson } from './types';
DocsInfoConfig,
DocAgnosticFormat,
DoxityDocObj,
DocsMenu,
SupportedDocJson,
TypeDocNode,
GeneratedDocJson,
} from './types';
export { constants } from './utils/constants'; export { constants } from './utils/constants';

View File

@@ -22,72 +22,6 @@ export interface SectionsMap {
[sectionName: string]: string; [sectionName: string]: string;
} }
export interface TypeDocType {
type: TypeDocTypes;
value: string;
name: string;
types: TypeDocType[];
typeArguments?: TypeDocType[];
declaration: TypeDocNode;
elementType?: TypeDocType;
indexSignature?: TypeDocNode;
elements?: TupleElement[];
}
export interface TupleElement {
type: string;
name: string;
}
export interface TypeDocFlags {
isStatic?: boolean;
isOptional?: boolean;
isPublic?: boolean;
isExported?: boolean;
}
export interface TypeDocGroup {
title: string;
children: number[];
}
export interface TypeDocNode {
id?: number;
name?: string;
kind?: string;
defaultValue?: string;
kindString?: string;
type?: TypeDocType;
fileName?: string;
line?: number;
comment?: TypeDocNode;
text?: string;
shortText?: string;
returns?: string;
declaration: TypeDocNode;
flags?: TypeDocFlags;
indexSignature?: TypeDocNode;
signatures?: TypeDocNode[];
parameters?: TypeDocNode[];
typeParameter?: TypeDocNode[];
sources?: TypeDocNode[];
children?: TypeDocNode[];
groups?: TypeDocGroup[];
}
export enum TypeDocTypes {
Intrinsic = 'intrinsic',
Reference = 'reference',
Array = 'array',
StringLiteral = 'stringLiteral',
Reflection = 'reflection',
Union = 'union',
TypeParameter = 'typeParameter',
Intersection = 'intersection',
Tuple = 'tuple',
Unknown = 'unknown',
}
// Exception: We don't make the values uppercase because these KindString's need to // Exception: We don't make the values uppercase because these KindString's need to
// match up those returned by TypeDoc // match up those returned by TypeDoc
export enum KindString { export enum KindString {
@@ -103,141 +37,8 @@ export enum KindString {
Class = 'Class', Class = 'Class',
} }
export interface DocAgnosticFormat {
[sectionName: string]: DocSection;
}
export interface DocSection {
comment: string;
constructors: Array<TypescriptMethod | SolidityMethod>;
methods: Array<TypescriptMethod | SolidityMethod>;
properties: Property[];
types: CustomType[];
functions: TypescriptFunction[];
events?: Event[];
externalExportToLink?: ExternalExportToLink;
}
export interface TypescriptMethod extends BaseMethod {
source?: Source;
isStatic?: boolean;
typeParameter?: TypeParameter;
}
export interface TypescriptFunction extends BaseFunction {
source?: Source;
typeParameter?: TypeParameter;
callPath: string;
}
export interface SolidityMethod extends BaseMethod {
isConstant?: boolean;
isPayable?: boolean;
}
export interface Source {
fileName: string;
line: number;
}
export interface Parameter {
name: string;
comment: string;
isOptional: boolean;
type: Type;
defaultValue?: string;
}
export interface TypeParameter {
name: string;
type: Type;
}
export interface Type {
name: string;
typeDocType: TypeDocTypes;
value?: string;
isExportedClassReference?: boolean;
typeArguments?: Type[];
elementType?: ElementType;
types?: Type[];
method?: TypescriptMethod;
indexSignature?: IndexSignature;
externalLink?: string;
tupleElements?: Type[];
}
export interface ElementType {
name: string;
typeDocType: TypeDocTypes;
}
export interface IndexSignature {
keyName: string;
keyType: Type;
valueName: string;
}
export interface CustomType {
name: string;
kindString: string;
type?: Type;
method?: TypescriptMethod;
indexSignature?: IndexSignature;
defaultValue?: string;
comment?: string;
children?: CustomTypeChild[];
}
export interface CustomTypeChild {
name: string;
type?: Type;
defaultValue?: string;
}
export interface Event {
name: string;
eventArgs: EventArg[];
}
export interface EventArg {
isIndexed: boolean;
name: string;
type: Type;
}
export interface Property {
name: string;
type: Type;
source?: Source;
comment?: string;
callPath?: string;
}
export interface BaseMethod {
isConstructor: boolean;
name: string;
returnComment?: string | undefined;
callPath: string;
parameters: Parameter[];
returnType: Type;
comment?: string;
}
export interface BaseFunction {
name: string;
returnComment?: string | undefined;
parameters: Parameter[];
returnType: Type;
comment?: string;
}
export interface TypeDefinitionByName {
[typeName: string]: CustomType;
}
export enum SupportedDocJson { export enum SupportedDocJson {
Doxity = 'DOXITY', SolDoc = 'SOL_DOC',
TypeDoc = 'TYPEDOC', TypeDoc = 'TYPEDOC',
} }
@@ -249,40 +50,6 @@ export interface ContractsByVersionByNetworkId {
}; };
} }
export interface DoxityDocObj {
[contractName: string]: DoxityContractObj;
}
export interface DoxityContractObj {
title: string;
fileName: string;
name: string;
abiDocs: DoxityAbiDoc[];
}
export interface DoxityAbiDoc {
constant: boolean;
inputs: DoxityInput[];
name: string;
outputs: DoxityOutput[];
payable: boolean;
type: string;
details?: string;
return?: string;
}
export interface DoxityOutput {
name: string;
type: string;
}
export interface DoxityInput {
name: string;
type: string;
description: string;
indexed?: boolean;
}
export interface AddressByContractName { export interface AddressByContractName {
[contractName: string]: string; [contractName: string]: string;
} }
@@ -297,28 +64,3 @@ export enum AbiTypes {
Function = 'function', Function = 'function',
Event = 'event', Event = 'event',
} }
export interface ExportNameToTypedocNames {
[exportName: string]: string[];
}
export interface ExternalTypeToLink {
[externalTypeName: string]: string;
}
export interface ExternalExportToLink {
[externalExport: string]: string;
}
export interface Metadata {
exportPathToTypedocNames: ExportNameToTypedocNames;
exportPathOrder: string[];
externalTypeToLink: ExternalTypeToLink;
externalExportToLink: ExternalExportToLink;
}
export interface GeneratedDocJson {
version: string;
metadata: Metadata;
typedocJson: TypeDocNode;
}

View File

@@ -4,7 +4,7 @@ export const constants = {
TYPES_SECTION_NAME: 'types', TYPES_SECTION_NAME: 'types',
EXTERNAL_EXPORTS_SECTION_NAME: 'external exports', EXTERNAL_EXPORTS_SECTION_NAME: 'external exports',
TYPE_TO_SYNTAX: { TYPE_TO_SYNTAX: {
[SupportedDocJson.Doxity]: 'solidity', [SupportedDocJson.SolDoc]: 'solidity',
[SupportedDocJson.TypeDoc]: 'typescript', [SupportedDocJson.TypeDoc]: 'typescript',
} as { [supportedDocType: string]: string }, } as { [supportedDocType: string]: string },
}; };

View File

@@ -1,176 +0,0 @@
import * as _ from 'lodash';
import {
AbiTypes,
DocAgnosticFormat,
DocSection,
DoxityAbiDoc,
DoxityContractObj,
DoxityDocObj,
DoxityInput,
EventArg,
Parameter,
Property,
SolidityMethod,
Type,
TypeDocTypes,
} from '../types';
export const doxityUtils = {
convertToDocAgnosticFormat(doxityDocObj: DoxityDocObj): DocAgnosticFormat {
const docAgnosticFormat: DocAgnosticFormat = {};
_.each(doxityDocObj, (doxityContractObj: DoxityContractObj, contractName: string) => {
const doxityConstructor = _.find(doxityContractObj.abiDocs, (abiDoc: DoxityAbiDoc) => {
return abiDoc.type === AbiTypes.Constructor;
});
const constructors = [];
if (!_.isUndefined(doxityConstructor)) {
const constructor = {
isConstructor: true,
name: doxityContractObj.name,
comment: doxityConstructor.details,
returnComment: doxityConstructor.return,
callPath: '',
parameters: doxityUtils._convertParameters(doxityConstructor.inputs),
returnType: doxityUtils._convertType(doxityContractObj.name),
};
constructors.push(constructor);
}
const doxityMethods: DoxityAbiDoc[] = _.filter<DoxityAbiDoc>(
doxityContractObj.abiDocs,
(abiDoc: DoxityAbiDoc) => {
return doxityUtils._isMethod(abiDoc);
},
);
const methods: SolidityMethod[] = _.map<DoxityAbiDoc, SolidityMethod>(
doxityMethods,
(doxityMethod: DoxityAbiDoc) => {
const outputs = !_.isUndefined(doxityMethod.outputs) ? doxityMethod.outputs : [];
let returnTypeIfExists: Type;
if (outputs.length === 0) {
// no-op. It's already undefined
} else if (outputs.length === 1) {
const outputsType = outputs[0].type;
returnTypeIfExists = doxityUtils._convertType(outputsType);
} else {
const outputsType = `[${_.map(outputs, output => output.type).join(', ')}]`;
returnTypeIfExists = doxityUtils._convertType(outputsType);
}
// For ZRXToken, we want to convert it to zrxToken, rather then simply zRXToken
const callPath =
contractName !== 'ZRXToken'
? `${contractName[0].toLowerCase()}${contractName.slice(1)}.`
: `${contractName.slice(0, 3).toLowerCase()}${contractName.slice(3)}.`;
const method = {
isConstructor: false,
isConstant: doxityMethod.constant,
isPayable: doxityMethod.payable,
name: doxityMethod.name,
comment: doxityMethod.details,
returnComment: doxityMethod.return,
callPath,
parameters: doxityUtils._convertParameters(doxityMethod.inputs),
returnType: returnTypeIfExists,
};
return method;
},
);
const doxityProperties: DoxityAbiDoc[] = _.filter<DoxityAbiDoc>(
doxityContractObj.abiDocs,
(abiDoc: DoxityAbiDoc) => {
return doxityUtils._isProperty(abiDoc);
},
);
const properties = _.map<DoxityAbiDoc, Property>(doxityProperties, (doxityProperty: DoxityAbiDoc) => {
// We assume that none of our functions return more then a single return value
let typeName = doxityProperty.outputs[0].type;
if (!_.isEmpty(doxityProperty.inputs)) {
// Properties never have more then a single input
typeName = `(${doxityProperty.inputs[0].type} => ${typeName})`;
}
const property = {
name: doxityProperty.name,
type: doxityUtils._convertType(typeName),
comment: doxityProperty.details,
};
return property;
});
const doxityEvents = _.filter(
doxityContractObj.abiDocs,
(abiDoc: DoxityAbiDoc) => abiDoc.type === AbiTypes.Event,
);
const events = _.map(doxityEvents, doxityEvent => {
const event = {
name: doxityEvent.name,
eventArgs: doxityUtils._convertEventArgs(doxityEvent.inputs),
};
return event;
});
const docSection: DocSection = {
comment: doxityContractObj.title,
constructors,
methods,
properties,
types: [],
functions: [],
events,
};
docAgnosticFormat[contractName] = docSection;
});
return docAgnosticFormat;
},
_convertParameters(inputs: DoxityInput[]): Parameter[] {
const parameters = _.map(inputs, input => {
const parameter = {
name: input.name,
comment: input.description,
isOptional: false,
type: doxityUtils._convertType(input.type),
};
return parameter;
});
return parameters;
},
_convertType(typeName: string): Type {
const type = {
name: typeName,
typeDocType: TypeDocTypes.Intrinsic,
};
return type;
},
_isMethod(abiDoc: DoxityAbiDoc): boolean {
if (abiDoc.type !== AbiTypes.Function) {
return false;
}
const hasInputs = !_.isEmpty(abiDoc.inputs);
const hasNamedOutputIfExists = !hasInputs || !_.isEmpty(abiDoc.inputs[0].name);
const isNameAllCaps = abiDoc.name === abiDoc.name.toUpperCase();
const isMethod = hasNamedOutputIfExists && !isNameAllCaps;
return isMethod;
},
_isProperty(abiDoc: DoxityAbiDoc): boolean {
if (abiDoc.type !== AbiTypes.Function) {
return false;
}
const hasInputs = !_.isEmpty(abiDoc.inputs);
const hasNamedOutputIfExists = !hasInputs || !_.isEmpty(abiDoc.inputs[0].name);
const isNameAllCaps = abiDoc.name === abiDoc.name.toUpperCase();
const isProperty = !hasNamedOutputIfExists || isNameAllCaps;
return isProperty;
},
_convertEventArgs(inputs: DoxityInput[]): EventArg[] {
const eventArgs = _.map(inputs, input => {
const eventArg = {
isIndexed: input.indexed,
name: input.name,
type: doxityUtils._convertType(input.type),
};
return eventArg;
});
return eventArgs;
},
};

View File

@@ -1,7 +1,3 @@
import { errorUtils } from '@0xproject/utils';
import * as _ from 'lodash';
import { DocsInfo } from '../docs_info';
import { import {
CustomType, CustomType,
CustomTypeChild, CustomTypeChild,
@@ -11,7 +7,6 @@ import {
ExternalTypeToLink, ExternalTypeToLink,
GeneratedDocJson, GeneratedDocJson,
IndexSignature, IndexSignature,
KindString,
Parameter, Parameter,
Property, Property,
Type, Type,
@@ -21,7 +16,12 @@ import {
TypeParameter, TypeParameter,
TypescriptFunction, TypescriptFunction,
TypescriptMethod, TypescriptMethod,
} from '../types'; } from '@0xproject/types';
import { errorUtils } from '@0xproject/utils';
import * as _ from 'lodash';
import { DocsInfo } from '../docs_info';
import { KindString } from '../types';
import { constants } from './constants'; import { constants } from './constants';
@@ -419,7 +419,10 @@ export class TypeDocUtils {
return func; return func;
} }
private _convertTypeParameter(entity: TypeDocNode, sectionName: string): TypeParameter { private _convertTypeParameter(entity: TypeDocNode, sectionName: string): TypeParameter {
const type = this._convertType(entity.type, sectionName); let type;
if (!_.isUndefined(entity.type)) {
type = this._convertType(entity.type, sectionName);
}
const parameter = { const parameter = {
name: entity.name, name: entity.name,
type, type,
@@ -468,6 +471,8 @@ export class TypeDocUtils {
methodIfExists = this._convertMethod(entity.declaration, isConstructor, sectionName); methodIfExists = this._convertMethod(entity.declaration, isConstructor, sectionName);
} else if (entity.type === TypeDocTypes.Tuple) { } else if (entity.type === TypeDocTypes.Tuple) {
tupleElementsIfExists = _.map(entity.elements, el => { tupleElementsIfExists = _.map(entity.elements, el => {
// the following line is required due to an open tslint issue, https://github.com/palantir/tslint/issues/3540
// tslint:disable-next-line:no-unnecessary-type-assertion
return { name: el.name, typeDocType: el.type as TypeDocTypes }; return { name: el.name, typeDocType: el.type as TypeDocTypes };
}); });
} }

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "1.0.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.0.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "1.0.11", "version": "1.0.11",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.0.13 - _September 28, 2018_
* Dependencies updated
## v1.0.12 - _September 25, 2018_
* Dependencies updated
## v1.0.11 - _September 25, 2018_ ## v1.0.11 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/react-shared", "name": "@0xproject/react-shared",
"version": "1.0.11", "version": "1.0.13",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -24,7 +24,7 @@
"url": "https://github.com/0xProject/0x-monorepo.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/dev-utils": "^1.0.9", "@0xproject/dev-utils": "^1.0.11",
"@0xproject/tslint-config": "^1.0.7", "@0xproject/tslint-config": "^1.0.7",
"copyfiles": "^2.0.0", "copyfiles": "^2.0.0",
"make-promises-safe": "^1.1.0", "make-promises-safe": "^1.1.0",

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "1.1.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "1.1.4", "version": "1.1.4",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v1.1.6 - _September 28, 2018_
* Dependencies updated
## v1.1.5 - _September 25, 2018_
* Dependencies updated
## v1.1.4 - _September 25, 2018_ ## v1.1.4 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/sol-compiler", "name": "@0xproject/sol-compiler",
"version": "1.1.4", "version": "1.1.6",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -41,7 +41,7 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-compiler/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-compiler/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/dev-utils": "^1.0.9", "@0xproject/dev-utils": "^1.0.11",
"@0xproject/tslint-config": "^1.0.7", "@0xproject/tslint-config": "^1.0.7",
"@types/mkdirp": "^0.5.2", "@types/mkdirp": "^0.5.2",
"@types/require-from-string": "^1.2.0", "@types/require-from-string": "^1.2.0",
@@ -64,16 +64,16 @@
"zeppelin-solidity": "1.8.0" "zeppelin-solidity": "1.8.0"
}, },
"dependencies": { "dependencies": {
"@0xproject/assert": "^1.0.10", "@0xproject/assert": "^1.0.12",
"@0xproject/json-schemas": "^1.0.3", "@0xproject/json-schemas": "^1.0.5",
"@0xproject/sol-resolver": "^1.0.10", "@0xproject/sol-resolver": "^1.0.12",
"@0xproject/types": "^1.1.0", "@0xproject/types": "^1.1.2",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"@types/yargs": "^11.0.0", "@types/yargs": "^11.0.0",
"chalk": "^2.3.0", "chalk": "^2.3.0",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "^5.1.1",
"lodash": "^4.17.5", "lodash": "^4.17.5",
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",

View File

@@ -10,7 +10,7 @@ import {
} from '@0xproject/sol-resolver'; } from '@0xproject/sol-resolver';
import { fetchAsync, logUtils } from '@0xproject/utils'; import { fetchAsync, logUtils } from '@0xproject/utils';
import chalk from 'chalk'; import chalk from 'chalk';
import { CompilerOptions, ContractArtifact, ContractVersionData } from 'ethereum-types'; import { CompilerOptions, ContractArtifact, ContractVersionData, StandardOutput } from 'ethereum-types';
import * as ethUtil from 'ethereumjs-util'; import * as ethUtil from 'ethereumjs-util';
import * as fs from 'fs'; import * as fs from 'fs';
import * as _ from 'lodash'; import * as _ from 'lodash';
@@ -94,7 +94,7 @@ export class Compiler {
if (await fsWrapper.doesFileExistAsync(compilerBinFilename)) { if (await fsWrapper.doesFileExistAsync(compilerBinFilename)) {
solcjs = (await fsWrapper.readFileAsync(compilerBinFilename)).toString(); solcjs = (await fsWrapper.readFileAsync(compilerBinFilename)).toString();
} else { } else {
logUtils.log(`Downloading ${fullSolcVersion}...`); logUtils.warn(`Downloading ${fullSolcVersion}...`);
const url = `${constants.BASE_COMPILER_URL}${fullSolcVersion}`; const url = `${constants.BASE_COMPILER_URL}${fullSolcVersion}`;
const response = await fetchAsync(url); const response = await fetchAsync(url);
const SUCCESS_STATUS = 200; const SUCCESS_STATUS = 200;
@@ -110,6 +110,21 @@ export class Compiler {
const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename)); const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename));
return { solcInstance, fullSolcVersion }; return { solcInstance, fullSolcVersion };
} }
private static _addHexPrefixToContractBytecode(compiledContract: solc.StandardContractOutput): void {
if (!_.isUndefined(compiledContract.evm)) {
if (!_.isUndefined(compiledContract.evm.bytecode) && !_.isUndefined(compiledContract.evm.bytecode.object)) {
compiledContract.evm.bytecode.object = ethUtil.addHexPrefix(compiledContract.evm.bytecode.object);
}
if (
!_.isUndefined(compiledContract.evm.deployedBytecode) &&
!_.isUndefined(compiledContract.evm.deployedBytecode.object)
) {
compiledContract.evm.deployedBytecode.object = ethUtil.addHexPrefix(
compiledContract.evm.deployedBytecode.object,
);
}
}
}
/** /**
* Instantiates a new instance of the Compiler class. * Instantiates a new instance of the Compiler class.
* @param opts Optional compiler options * @param opts Optional compiler options
@@ -144,22 +159,40 @@ export class Compiler {
public async compileAsync(): Promise<void> { public async compileAsync(): Promise<void> {
await createDirIfDoesNotExistAsync(this._artifactsDir); await createDirIfDoesNotExistAsync(this._artifactsDir);
await createDirIfDoesNotExistAsync(SOLC_BIN_DIR); await createDirIfDoesNotExistAsync(SOLC_BIN_DIR);
let contractNamesToCompile: string[] = []; await this._compileContractsAsync(this._getContractNamesToCompile(), true);
}
/**
* Compiles Solidity files specified during instantiation, and returns the
* compiler output given by solc. Return value is an array of outputs:
* Solidity modules are batched together by version required, and each
* element of the returned array corresponds to a compiler version, and
* each element contains the output for all of the modules compiled with
* that version.
*/
public async getCompilerOutputsAsync(): Promise<StandardOutput[]> {
const promisedOutputs = this._compileContractsAsync(this._getContractNamesToCompile(), false);
return promisedOutputs;
}
private _getContractNamesToCompile(): string[] {
let contractNamesToCompile;
if (this._specifiedContracts === ALL_CONTRACTS_IDENTIFIER) { if (this._specifiedContracts === ALL_CONTRACTS_IDENTIFIER) {
const allContracts = this._nameResolver.getAll(); const allContracts = this._nameResolver.getAll();
contractNamesToCompile = _.map(allContracts, contractSource => contractNamesToCompile = _.map(allContracts, contractSource =>
path.basename(contractSource.path, constants.SOLIDITY_FILE_EXTENSION), path.basename(contractSource.path, constants.SOLIDITY_FILE_EXTENSION),
); );
} else { } else {
contractNamesToCompile = this._specifiedContracts; contractNamesToCompile = this._specifiedContracts.map(specifiedContract =>
path.basename(specifiedContract, constants.SOLIDITY_FILE_EXTENSION),
);
} }
await this._compileContractsAsync(contractNamesToCompile); return contractNamesToCompile;
} }
/** /**
* Compiles contract and saves artifact to artifactsDir. * Compiles contracts, and, if `shouldPersist` is true, saves artifacts to artifactsDir.
* @param fileName Name of contract with '.sol' extension. * @param fileName Name of contract with '.sol' extension.
* @return an array of compiler outputs, where each element corresponds to a different version of solc-js.
*/ */
private async _compileContractsAsync(contractNames: string[]): Promise<void> { private async _compileContractsAsync(contractNames: string[], shouldPersist: boolean): Promise<StandardOutput[]> {
// batch input contracts together based on the version of the compiler that they require. // batch input contracts together based on the version of the compiler that they require.
const versionToInputs: VersionToInputs = {}; const versionToInputs: VersionToInputs = {};
@@ -200,10 +233,12 @@ export class Compiler {
versionToInputs[solcVersion].contractsToCompile.push(contractSource.path); versionToInputs[solcVersion].contractsToCompile.push(contractSource.path);
} }
const compilerOutputs: StandardOutput[] = [];
const solcVersions = _.keys(versionToInputs); const solcVersions = _.keys(versionToInputs);
for (const solcVersion of solcVersions) { for (const solcVersion of solcVersions) {
const input = versionToInputs[solcVersion]; const input = versionToInputs[solcVersion];
logUtils.log( logUtils.warn(
`Compiling ${input.contractsToCompile.length} contracts (${ `Compiling ${input.contractsToCompile.length} contracts (${
input.contractsToCompile input.contractsToCompile
}) with Solidity v${solcVersion}...`, }) with Solidity v${solcVersion}...`,
@@ -212,19 +247,35 @@ export class Compiler {
const { solcInstance, fullSolcVersion } = await Compiler._getSolcAsync(solcVersion); const { solcInstance, fullSolcVersion } = await Compiler._getSolcAsync(solcVersion);
const compilerOutput = this._compile(solcInstance, input.standardInput); const compilerOutput = this._compile(solcInstance, input.standardInput);
compilerOutputs.push(compilerOutput);
for (const contractPath of input.contractsToCompile) { for (const contractPath of input.contractsToCompile) {
await this._verifyAndPersistCompiledContractAsync( const contractName = contractPathToData[contractPath].contractName;
const compiledContract = compilerOutput.contracts[contractPath][contractName];
if (_.isUndefined(compiledContract)) {
throw new Error(
`Contract ${contractName} not found in ${contractPath}. Please make sure your contract has the same name as it's file name`,
);
}
Compiler._addHexPrefixToContractBytecode(compiledContract);
if (shouldPersist) {
await this._persistCompiledContractAsync(
contractPath, contractPath,
contractPathToData[contractPath].currentArtifactIfExists, contractPathToData[contractPath].currentArtifactIfExists,
contractPathToData[contractPath].sourceTreeHashHex, contractPathToData[contractPath].sourceTreeHashHex,
contractPathToData[contractPath].contractName, contractName,
fullSolcVersion, fullSolcVersion,
compilerOutput, compilerOutput,
); );
} }
} }
} }
return compilerOutputs;
}
private _shouldCompile(contractData: ContractData): boolean { private _shouldCompile(contractData: ContractData): boolean {
if (_.isUndefined(contractData.currentArtifactIfExists)) { if (_.isUndefined(contractData.currentArtifactIfExists)) {
return true; return true;
@@ -236,7 +287,7 @@ export class Compiler {
return !isUserOnLatestVersion || didCompilerSettingsChange || didSourceChange; return !isUserOnLatestVersion || didCompilerSettingsChange || didSourceChange;
} }
} }
private async _verifyAndPersistCompiledContractAsync( private async _persistCompiledContractAsync(
contractPath: string, contractPath: string,
currentArtifactIfExists: ContractArtifact | void, currentArtifactIfExists: ContractArtifact | void,
sourceTreeHashHex: string, sourceTreeHashHex: string,
@@ -244,32 +295,13 @@ export class Compiler {
fullSolcVersion: string, fullSolcVersion: string,
compilerOutput: solc.StandardOutput, compilerOutput: solc.StandardOutput,
): Promise<void> { ): Promise<void> {
const compiledData = compilerOutput.contracts[contractPath][contractName]; const compiledContract = compilerOutput.contracts[contractPath][contractName];
if (_.isUndefined(compiledData)) {
throw new Error(
`Contract ${contractName} not found in ${contractPath}. Please make sure your contract has the same name as it's file name`,
);
}
if (!_.isUndefined(compiledData.evm)) {
if (!_.isUndefined(compiledData.evm.bytecode) && !_.isUndefined(compiledData.evm.bytecode.object)) {
compiledData.evm.bytecode.object = ethUtil.addHexPrefix(compiledData.evm.bytecode.object);
}
if (
!_.isUndefined(compiledData.evm.deployedBytecode) &&
!_.isUndefined(compiledData.evm.deployedBytecode.object)
) {
compiledData.evm.deployedBytecode.object = ethUtil.addHexPrefix(
compiledData.evm.deployedBytecode.object,
);
}
}
const sourceCodes = _.mapValues( const sourceCodes = _.mapValues(
compilerOutput.sources, compilerOutput.sources,
(_1, sourceFilePath) => this._resolver.resolve(sourceFilePath).source, (_1, sourceFilePath) => this._resolver.resolve(sourceFilePath).source,
); );
const contractVersion: ContractVersionData = { const contractVersion: ContractVersionData = {
compilerOutput: compiledData, compilerOutput: compiledContract,
sources: compilerOutput.sources, sources: compilerOutput.sources,
sourceCodes, sourceCodes,
sourceTreeHashHex, sourceTreeHashHex,
@@ -299,7 +331,7 @@ export class Compiler {
const artifactString = utils.stringifyWithFormatting(newArtifact); const artifactString = utils.stringifyWithFormatting(newArtifact);
const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`; const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`;
await fsWrapper.writeFileAsync(currentArtifactPath, artifactString); await fsWrapper.writeFileAsync(currentArtifactPath, artifactString);
logUtils.log(`${contractName} artifact saved!`); logUtils.warn(`${contractName} artifact saved!`);
} }
private _compile(solcInstance: solc.SolcInstance, standardInput: solc.StandardInput): solc.StandardOutput { private _compile(solcInstance: solc.SolcInstance, standardInput: solc.StandardInput): solc.StandardOutput {
const compiled: solc.StandardOutput = JSON.parse( const compiled: solc.StandardOutput = JSON.parse(
@@ -315,13 +347,13 @@ export class Compiler {
if (!_.isEmpty(errors)) { if (!_.isEmpty(errors)) {
errors.forEach(error => { errors.forEach(error => {
const normalizedErrMsg = getNormalizedErrMsg(error.formattedMessage || error.message); const normalizedErrMsg = getNormalizedErrMsg(error.formattedMessage || error.message);
logUtils.log(chalk.red(normalizedErrMsg)); logUtils.warn(chalk.red(normalizedErrMsg));
}); });
throw new Error('Compilation errors encountered'); throw new Error('Compilation errors encountered');
} else { } else {
warnings.forEach(warning => { warnings.forEach(warning => {
const normalizedWarningMsg = getNormalizedErrMsg(warning.formattedMessage || warning.message); const normalizedWarningMsg = getNormalizedErrMsg(warning.formattedMessage || warning.message);
logUtils.log(chalk.yellow(normalizedWarningMsg)); logUtils.warn(chalk.yellow(normalizedWarningMsg));
}); });
} }
} }

View File

@@ -1,8 +1,29 @@
export { Compiler } from './compiler'; export { Compiler } from './compiler';
export { export {
AbiDefinition,
CompilerOptions, CompilerOptions,
CompilerSettings, CompilerSettings,
DataItem,
DevdocOutput,
ErrorSeverity,
ErrorType,
EventAbi,
EventParameter,
EvmBytecodeOutput,
EvmOutput,
FallbackAbi,
FunctionAbi,
MethodAbi,
ConstructorAbi,
ConstructorStateMutability,
ContractAbi,
OutputField, OutputField,
CompilerSettingsMetadata, CompilerSettingsMetadata,
OptimizerSettings, OptimizerSettings,
ParamDescription,
SolcError,
StandardContractOutput,
StandardOutput,
StateMutability,
SourceLocation,
} from 'ethereum-types'; } from 'ethereum-types';

View File

@@ -26,7 +26,7 @@ export async function getContractArtifactIfExistsAsync(
contractArtifact = JSON.parse(contractArtifactString); contractArtifact = JSON.parse(contractArtifactString);
return contractArtifact; return contractArtifact;
} catch (err) { } catch (err) {
logUtils.log(`Artifact for ${contractName} does not exist`); logUtils.warn(`Artifact for ${contractName} does not exist`);
return undefined; return undefined;
} }
} }
@@ -37,7 +37,7 @@ export async function getContractArtifactIfExistsAsync(
*/ */
export async function createDirIfDoesNotExistAsync(dirPath: string): Promise<void> { export async function createDirIfDoesNotExistAsync(dirPath: string): Promise<void> {
if (!fsWrapper.doesPathExistSync(dirPath)) { if (!fsWrapper.doesPathExistSync(dirPath)) {
logUtils.log(`Creating directory at ${dirPath}...`); logUtils.warn(`Creating directory at ${dirPath}...`);
await fsWrapper.mkdirpAsync(dirPath); await fsWrapper.mkdirpAsync(dirPath);
} }
} }

View File

@@ -1,4 +1,22 @@
[ [
{
"timestamp": 1538157789,
"version": "2.1.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "2.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1537875740, "timestamp": 1537875740,
"version": "2.1.4", "version": "2.1.4",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v2.1.6 - _September 28, 2018_
* Dependencies updated
## v2.1.5 - _September 25, 2018_
* Dependencies updated
## v2.1.4 - _September 25, 2018_ ## v2.1.4 - _September 25, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/sol-cov", "name": "@0xproject/sol-cov",
"version": "2.1.4", "version": "2.1.6",
"engines": { "engines": {
"node": ">=6.12" "node": ">=6.12"
}, },
@@ -41,13 +41,13 @@
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md", "homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md",
"dependencies": { "dependencies": {
"@0xproject/dev-utils": "^1.0.9", "@0xproject/dev-utils": "^1.0.11",
"@0xproject/sol-compiler": "^1.1.4", "@0xproject/sol-compiler": "^1.1.6",
"@0xproject/subproviders": "^2.0.4", "@0xproject/subproviders": "^2.0.6",
"@0xproject/typescript-typings": "^2.0.1", "@0xproject/typescript-typings": "^3.0.0",
"@0xproject/utils": "^1.0.10", "@0xproject/utils": "^2.0.0",
"@0xproject/web3-wrapper": "^3.0.0", "@0xproject/web3-wrapper": "^3.0.2",
"ethereum-types": "^1.0.7", "ethereum-types": "^1.0.9",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "^5.1.1",
"glob": "^7.1.2", "glob": "^7.1.2",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",

View File

@@ -0,0 +1,21 @@
[
{
"timestamp": 1538157789,
"version": "1.0.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.0",
"changes": [
{
"note":
"Utility to generate documentation for Solidity smart contracts, outputting a format compliant with @0xproject/types.DocAgnosticFormat",
"pr": 1004
}
]
}
]

Some files were not shown because too many files have changed in this diff Show More