Compare commits

..

172 Commits

Author SHA1 Message Date
Fabio Berger
fffcb98ac4 Updated CHANGELOGS 2018-03-18 19:22:55 +01:00
Brandon Millman
d4c1b3b0bd Merge pull request #456 from 0xProject/feature/connect/consolidate-types
Add SignedOrder, Order, and ECSignature types to the types package
2018-03-16 11:23:28 -07:00
Brandon Millman
bbdb072634 Fix quotation marks 2018-03-16 11:22:43 -07:00
Leonid Logvinov
2acb767640 Merge pull request #457 from 0xProject/feature/sol-cov-tests
Add tests for sol-cov
2018-03-16 13:32:21 +01:00
Leonid Logvinov
a9b1dcb32a Add a complex test for ast visitor 2018-03-16 10:49:20 +01:00
Leonid Logvinov
8f8577b7c6 Move opcodes to constants 2018-03-16 10:27:12 +01:00
Fabio Berger
0225d34b74 Fix issue with bundling subproviders for the browser by ignoring the ganache-core dependency 2018-03-15 19:51:07 +01:00
Fabio Berger
8137d41ce5 Add changelog entry about pragma addition 2018-03-15 19:25:06 +01:00
Fabio Berger
4b7f0bd374 Add pragma above command-line script 2018-03-15 19:23:57 +01:00
Leonid Logvinov
f6c01520ae Add tests for sol-cov 2018-03-15 16:19:01 +01:00
Brandon Millman
0fb4de85c4 Updated CHANGELOGs 2018-03-14 16:36:21 -07:00
Brandon Millman
ffe7363776 Add SignedOrder, Order, and ECSignature types to the types package 2018-03-14 16:33:10 -07:00
Brandon Millman
4a27a7dc58 Merge pull request #452 from 0xProject/feature/utils/console-log
Consolidate all console.log utils into @0xproject/utils
2018-03-14 15:30:59 -07:00
Brandon Millman
3b3d5b12bc Keep console.log in monorepo-scripts 2018-03-14 14:58:16 -07:00
Brandon Millman
380e51ca50 Merge branch 'development' into feature/utils/console-log
* development: (25 commits)
  Enable coverage for all other packages with tests
  Fix parallel coverage results reporting
  Fix linter issuesx
  Remove outdated comment
  Add script copying to build command
  Add postpublish script to sol-cov
  Move configuration into package.json configs section
  Transform input data before encoding for callAsync and getABIEncodedTransactionData
  Consolidate docs generation and uploading logic
  Use async/await instead of promise syntax
  Move changelog entry
  remove unneeded include
  remove unused dep
  Fix lint issues
  Re-add linter to monorepo-scripts but with tslint-config dep at earlier version to avoid cyclical dependency
  small fixes
  move scripts to monorepro-scripts
  Fix gitignore
  Move abi-gen scripts to src
  Add missing dep
  ...
2018-03-14 14:36:04 -07:00
Leonid Logvinov
aea7207b9f Merge pull request #455 from 0xProject/fix/coveralls
Enable coverage reporting for all packages that have tests
2018-03-14 17:36:23 +01:00
Leonid Logvinov
40ebb533b3 Enable coverage for all other packages with tests 2018-03-14 17:15:38 +01:00
Leonid Logvinov
7fe26ee719 Fix parallel coverage results reporting 2018-03-14 17:14:25 +01:00
Fabio Berger
e16feb27f4 Merge pull request #450 from 0xProject/convertScriptsToTs
Convert Scripts to TS & Other Misc. Fixes
2018-03-14 15:18:16 +01:00
Fabio Berger
83ae7ba08d Fix linter issuesx 2018-03-14 14:50:09 +01:00
Fabio Berger
28abcef1ca Remove outdated comment 2018-03-14 14:32:45 +01:00
Fabio Berger
32d15d79f1 Add script copying to build command 2018-03-14 14:30:15 +01:00
Fabio Berger
538ac604a8 Add postpublish script to sol-cov 2018-03-14 14:27:36 +01:00
Fabio Berger
009b70f5b2 Merge branch 'development' into convertScriptsToTs
* development: (71 commits)
  Transform input data before encoding for callAsync and getABIEncodedTransactionData
  Update coverage badge to show development coverage
  Configure post build hook
  Notify coveralls after all tasks have finished
  Address feedback
  Revert "Report all coverage reports together"
  Separate published packages and typescript typings on README
  Report all coverage reports together
  Add other statement types
  Properly and consistently parse ENV vars
  Add forgotten file
  Start using solidity-parser-antlr
  Fix the default always overriding to address
  Submit a TD PR
  Add an explanatory comment for making ranges unique
  Fix a typo in handling env variables
  Introduce TESTRPC_FIRST_ADDRESS
  Make BlockchainLifecycle accept only web3Wrapper
  Fix comments
  Fix deployer CHANGELOG
  ...

# Conflicts:
#	README.md
#	packages/deployer/package.json
#	packages/subproviders/src/globals.d.ts
#	yarn.lock
2018-03-14 14:16:08 +01:00
Fabio Berger
f7c1e10b5a Move configuration into package.json configs section 2018-03-14 14:07:24 +01:00
Leonid Logvinov
3f3e8be004 Merge pull request #453 from 0xProject/fix/contract-templates/transformData
Transform input data before encoding
2018-03-14 05:50:02 +01:00
Amir Bandeali
cb612360ca Transform input data before encoding for callAsync and getABIEncodedTransactionData 2018-03-13 20:41:07 -07:00
Brandon Millman
6a8c2cb717 Update CHANGELOGs 2018-03-13 18:16:31 -07:00
Brandon Millman
c8a8b851d8 Consolidate all console.log into the @0xproject/utils package 2018-03-13 18:13:48 -07:00
Leonid Logvinov
c2f8858aab Update coverage badge to show development coverage 2018-03-13 20:47:21 +01:00
Leonid Logvinov
1f81fa1c6c Configure post build hook 2018-03-13 20:38:33 +01:00
Leonid Logvinov
db44a5bca7 Merge pull request #426 from 0xProject/feature/solcov
Sol-cover
2018-03-13 19:49:30 +01:00
Leonid Logvinov
53e1815c1d Notify coveralls after all tasks have finished 2018-03-13 19:30:54 +01:00
Leonid Logvinov
20985d515f Address feedback 2018-03-13 19:13:37 +01:00
Leonid Logvinov
0334004b11 Revert "Report all coverage reports together"
This reverts commit 11ed5d62ba.
2018-03-13 19:09:16 +01:00
Brandon Millman
95e2b37d62 Separate published packages and typescript typings on README 2018-03-13 09:57:28 -07:00
Fabio Berger
dba1b8a7e9 Consolidate docs generation and uploading logic 2018-03-13 17:55:16 +01:00
Fabio Berger
ee29ed26ff Use async/await instead of promise syntax 2018-03-13 17:36:12 +01:00
Fabio Berger
a08ae722c1 Move changelog entry 2018-03-13 17:04:38 +01:00
Fabio Berger
b3c1c0ccad remove unneeded include 2018-03-13 17:04:31 +01:00
Fabio Berger
e1fa65f5ef remove unused dep 2018-03-13 17:04:14 +01:00
Fabio Berger
a2e848a7fa Fix lint issues 2018-03-13 16:55:50 +01:00
Fabio Berger
67fbffc964 Re-add linter to monorepo-scripts but with tslint-config dep at earlier version to avoid cyclical dependency 2018-03-13 16:55:35 +01:00
Fabio Berger
c3b4359e87 small fixes 2018-03-13 16:36:05 +01:00
Leonid Logvinov
11ed5d62ba Report all coverage reports together 2018-03-13 16:34:37 +01:00
Leonid Logvinov
5827170815 Add other statement types 2018-03-13 15:49:46 +01:00
Fabio Berger
ca25b816fa move scripts to monorepro-scripts 2018-03-13 15:29:12 +01:00
Leonid Logvinov
a9db0e8ebe Properly and consistently parse ENV vars 2018-03-13 15:19:31 +01:00
Leonid Logvinov
a0791455e1 Add forgotten file 2018-03-13 14:41:46 +01:00
Leonid Logvinov
efb0ee4c02 Start using solidity-parser-antlr 2018-03-13 11:53:45 +01:00
Fabio Berger
df1968157c Fix gitignore 2018-03-13 10:59:53 +01:00
Fabio Berger
355aac2a1a Move abi-gen scripts to src 2018-03-13 10:42:33 +01:00
Fabio Berger
b93b66edfb Add missing dep 2018-03-13 10:42:14 +01:00
Fabio Berger
92a4e77288 Make git-ignore generic for all package scripts 2018-03-13 10:42:06 +01:00
Fabio Berger
7ac646ff94 Move monorepo_scripts into src dir removing the need for a separate globals.d.ts and tsconfig files 2018-03-13 10:25:10 +01:00
Fabio Berger
ef6aa9f41b Convert 0x.js scripts to TS, move the prepublishUtils script to dev-utils and also convert it to TS. 2018-03-12 22:13:24 +01:00
Fabio Berger
df9e7385ad Merge pull request #449 from 0xProject/bug/website/portal-history-etherscan-tx
Fix the Portal Etherscan Link always overriding to address
2018-03-12 16:53:10 +01:00
Jacob Evans
e065ac45dc Fix the default always overriding to address 2018-03-12 11:34:55 -04:00
Fabio Berger
745af5309d Add missing prettier devDep 2018-03-12 16:04:01 +01:00
Fabio Berger
952f1cf8d0 Use isMetaMask flag rather then constructor name for Metamask provider detection 2018-03-12 15:22:04 +01:00
Fabio Berger
86a55fe55a Add OrderRelevantState to public types in 0x.js docs configs 2018-03-12 13:58:15 +01:00
Leonid Logvinov
88c6694ffc Submit a TD PR 2018-03-12 13:24:07 +01:00
Leonid Logvinov
20826e0f08 Add an explanatory comment for making ranges unique 2018-03-12 12:56:22 +01:00
Leonid Logvinov
e474096119 Fix a typo in handling env variables 2018-03-12 12:53:51 +01:00
Leonid Logvinov
075f286130 Introduce TESTRPC_FIRST_ADDRESS 2018-03-12 12:53:07 +01:00
Leonid Logvinov
32e3cab116 Make BlockchainLifecycle accept only web3Wrapper 2018-03-12 12:51:37 +01:00
Leonid Logvinov
49ff4299c6 Fix comments 2018-03-12 12:42:14 +01:00
Leonid Logvinov
4d18a4802d Fix deployer CHANGELOG 2018-03-12 12:40:00 +01:00
Fabio Berger
d613791104 Merge branch 'feature/solcov' of github.com:0xProject/0x-monorepo into feature/solcov
* 'feature/solcov' of github.com:0xProject/0x-monorepo:
  Add a HACK to detect coverage of the modifiers with no parameters
2018-03-12 12:32:32 +01:00
Fabio Berger
44f7f79bd9 Improve the sol-cov readme 2018-03-12 12:32:07 +01:00
Leonid Logvinov
1cdfbbadaa Add a HACK to detect coverage of the modifiers with no parameters 2018-03-12 12:31:33 +01:00
Fabio Berger
76a31b6fd6 Merge pull request #447 from 0xProject/refactorAnalytics
Refactor Website Analytics
2018-03-12 11:28:34 +01:00
Leonid Logvinov
0ad3d06ef9 Merge pull request #448 from 0xProject/fix/abi-gen-readme
Update README for abi-gen
2018-03-12 11:28:06 +01:00
Leonid Logvinov
fb0fd8ddc4 Update README 2018-03-12 11:24:37 +01:00
Leonid Logvinov
2a9913b8fb Treap transactions to address 0x0 as contract creation 2018-03-12 06:07:01 +01:00
Leonid Logvinov
9b8d2ed469 Add sol-cov README 2018-03-12 04:03:51 +01:00
Leonid Logvinov
17148df06d Add an example deployment script 2018-03-12 03:47:46 +01:00
Leonid Logvinov
d93089fcc0 Fix subproviders CHANGELOG 2018-03-12 03:37:31 +01:00
Leonid Logvinov
870995933a Remove redundant Date.now() 2018-03-12 03:37:30 +01:00
Leonid Logvinov
d6c2e47bbd Make env variables parsing more strict and add docs 2018-03-12 03:37:30 +01:00
Leonid Logvinov
e2b2bf1e0d Fix a typo 2018-03-12 03:37:30 +01:00
Leonid Logvinov
c4a18ee64b Make Deployer configurable by jsonrpcUrl instead of jsonrpcPort 2018-03-12 03:37:30 +01:00
Leonid Logvinov
7143996d26 Use locks instead of semaphores in ledger subprovider 2018-03-12 03:37:30 +01:00
Leonid Logvinov
22f78a2c52 Don't await lock releases 2018-03-12 03:37:30 +01:00
Leonid Logvinov
bd7517cfd4 Add support for async calls under coverage 2018-03-12 03:37:30 +01:00
Leonid Logvinov
9bffce9dc5 Fix coverage:report:html 2018-03-12 03:37:30 +01:00
Leonid Logvinov
10f6a17857 Add builtin modifier 'constant' 2018-03-12 03:37:30 +01:00
Leonid Logvinov
2197c2481a Increase timeout 2018-03-12 03:37:30 +01:00
Leonid Logvinov
8d90e640b0 Keep coverage directory 2018-03-12 03:37:30 +01:00
Leonid Logvinov
368870a2fc Fix sources list generation in a compiler 2018-03-12 03:37:30 +01:00
Leonid Logvinov
945a19bb61 Fix a typo in tests 2018-03-12 03:37:30 +01:00
Leonid Logvinov
b0abc384bc Disable completed docs rule 2018-03-12 03:37:30 +01:00
Leonid Logvinov
8f45e9a518 Run coverage on CI 2018-03-12 03:37:29 +01:00
Leonid Logvinov
b06f1d1982 Use custom fork of ganache-core 2018-03-12 03:37:29 +01:00
Leonid Logvinov
4365350430 Don't do parallel calls 2018-03-12 03:37:29 +01:00
Leonid Logvinov
3b158cb726 Address feedback 2018-03-12 03:37:29 +01:00
Leonid Logvinov
2298a34c37 Make _getSingleFileCoverageForTrace a private static method 2018-03-12 03:37:29 +01:00
Leonid Logvinov
633039c528 Use better variable name 2018-03-12 03:37:29 +01:00
Leonid Logvinov
ee31d5e24d Introduce redundant vars 2018-03-12 03:37:29 +01:00
Leonid Logvinov
f590aa11f7 Throw an error if artifacts not found 2018-03-12 03:37:29 +01:00
Leonid Logvinov
6b7f48644c Fix a typo 2018-03-12 03:37:29 +01:00
Leonid Logvinov
21aac75533 Use string enum for branch types 2018-03-12 03:37:29 +01:00
Leonid Logvinov
95b02a3197 Fix a typo 2018-03-12 03:37:29 +01:00
Leonid Logvinov
be7c444959 Remove initial implementation entry 2018-03-12 03:37:29 +01:00
Leonid Logvinov
f02d3f689d Document env variables 2018-03-12 03:37:29 +01:00
Leonid Logvinov
981752059c Add double negation before using shouldUseInProcessGanache 2018-03-12 03:37:29 +01:00
Leonid Logvinov
6c87ebac01 Rename useInProcessGanache to shouldUseInProcessGanache 2018-03-12 03:37:28 +01:00
Leonid Logvinov
a9479b3c01 Make coverage a module instead of a function 2018-03-12 03:37:28 +01:00
Leonid Logvinov
c5afca53a4 Rename COVERAGE to SOLIDITY_COVERAGS 2018-03-12 03:37:28 +01:00
Leonid Logvinov
b4cb88ab26 Add better error handling in deployer constructor 2018-03-12 03:37:28 +01:00
Leonid Logvinov
ad4f607643 Move compiler URL to constants 2018-03-12 03:37:28 +01:00
Leonid Logvinov
c7d340e822 Handle an error while loading the compiler 2018-03-12 03:37:28 +01:00
Leonid Logvinov
2c501d2380 Introduce isCompilerAvailableLocally 2018-03-12 03:37:28 +01:00
Leonid Logvinov
3787e4a83c Fix variable name 2018-03-12 03:37:28 +01:00
Leonid Logvinov
3b77e4ebf1 Rename getCoverageSubprovider to getCoverageSubproviderSingleton 2018-03-12 03:37:28 +01:00
Leonid Logvinov
6eebf717d5 Improve migrations comment 2018-03-12 03:37:28 +01:00
Leonid Logvinov
98f32d6f1f Stop making an assumption that contract code is immutable 2018-03-12 03:37:28 +01:00
Leonid Logvinov
62f45f7b41 Cache code parsing 2018-03-12 03:37:28 +01:00
Leonid Logvinov
a7d8f6599a use sourceList instead of sources 2018-03-12 03:37:28 +01:00
Leonid Logvinov
4da6db8418 Improve compiler output type 2018-03-12 03:37:28 +01:00
Leonid Logvinov
d991291f2a Use in-process Ganache in contracts 2018-03-12 03:37:27 +01:00
Leonid Logvinov
392fb42973 Revert mocha timeout increase 2018-03-12 03:37:27 +01:00
Leonid Logvinov
13299158d1 Add sol-cover implementation 2018-03-12 03:37:27 +01:00
Fabio Berger
a6571b09d2 Improve README 2018-03-11 13:24:34 +01:00
Fabio Berger
870ba445b8 Merge pull request #444 from 0xProject/dedupWeb3Wrapper
Remove custom web3Wrapper from website
2018-03-11 12:49:15 +01:00
Fabio Berger
caaa70f630 Fix getTokenBalanceAndAllowanceAsync to take ownerAddressIfExists so that we don't sometimes pass an empty string and sometimes undefined 2018-03-11 12:33:34 +01:00
Fabio Berger
56a8e0a09a Fix userAddress bugs 2018-03-11 12:04:46 +01:00
Fabio Berger
4c08667a07 Replace local PRECISION constants with global config.AMOUNT_DISPLAY_PRECISION 2018-03-10 22:43:13 +01:00
Fabio Berger
4ac6b6828c Get rid of getFirstAccountIfExistsAsync since no longer needed 2018-03-10 22:38:31 +01:00
Fabio Berger
c050186014 Use undefined rather then an empty string in blockchainWatcher 2018-03-10 22:36:54 +01:00
Fabio Berger
63f2606863 Refactor blockchain to store userAddress as address or undefined 2018-03-10 22:31:19 +01:00
Fabio Berger
5160e0ba18 Add pr number to changelog 2018-03-10 22:24:13 +01:00
Fabio Berger
0aad2ee005 Merge pull request #442 from 0xProject/addPackagePublishConfig
Add Package Publish Config
2018-03-10 17:07:38 +01:00
Fabio Berger
8a58ffda86 Fix tslint issues 2018-03-10 16:59:59 +01:00
Fabio Berger
cea8dcae3d Refactor Analytics so that calls to ReactGA are all in a single module, combining the provider type util function, moving GA id to configs and using utils.onPageLoadAsync 2018-03-10 16:53:42 +01:00
Brandon Millman
fc7e7d9331 Merge pull request #445 from 0xProject/feature/web3-logging
Fixed merge issue
2018-03-09 16:19:01 -08:00
Tom Schmidt
494bff4bc0 Fixed merge issue 2018-03-09 16:10:25 -08:00
Tom Schmidt
824ee8a3dc Merge pull request #441 from 0xProject/feature/website/web3-logging
Add web3 provider logging to GA
2018-03-09 15:31:21 -08:00
Tom Schmidt
47af38ecb8 Merge branch 'development' into feature/website/web3-logging 2018-03-09 15:22:59 -08:00
Tom Schmidt
654c790c3d Fixed Parity detection 2018-03-09 12:44:11 -08:00
Fabio Berger
7ebebb5bd9 Create blockchainWatcher class and refactor Portal such that Ether amounts are always passed around as baseUnits 2018-03-09 19:02:07 +01:00
Fabio Berger
8f921a61da Add getProvider method to web3Wrapper 2018-03-09 18:52:02 +01:00
Fabio Berger
cfd734d84f remove remaining declaration 2018-03-09 15:09:25 +01:00
Fabio Berger
342a697e42 Remove _exchangeAddress instance var from blockchain class 2018-03-09 15:08:22 +01:00
Fabio Berger
918f3cde94 Remove duplicitous methods from website's webWrapper 2018-03-09 15:08:02 +01:00
Fabio Berger
7b82a8669d Fix comment 2018-03-09 15:07:39 +01:00
Leonid Logvinov
7116f100ee Fix tests by passing DummyToken args 2018-03-09 14:16:38 +01:00
Fabio Berger
42fce45585 Merge pull request #443 from 0xProject/moveReactDocExample
Move `react-doc` example to separate sub-package
2018-03-09 14:10:56 +01:00
Fabio Berger
9da57daa7f Fix tslint error 2018-03-09 13:51:44 +01:00
Fabio Berger
e302d23317 Extend top-level tsconfigs 2018-03-09 13:44:56 +01:00
Fabio Berger
0edfa83951 Update README 2018-03-09 13:44:25 +01:00
Fabio Berger
a5ba049427 Update README 2018-03-09 13:41:31 +01:00
Fabio Berger
adba69a589 rm unnecessary npmignore 2018-03-09 11:06:03 +01:00
Fabio Berger
cc73f72d13 remove example top-level dir 2018-03-09 11:00:47 +01:00
Fabio Berger
e4f90996af Remove example from react-docs package to react-docs-example package 2018-03-09 10:49:57 +01:00
Fabio Berger
974c0d2b95 Fix isse of sourceMapLoader looking at node_modules 2018-03-09 10:18:15 +01:00
Fabio Berger
d1fc2a115e Export DocsState 2018-03-09 10:17:49 +01:00
Fabio Berger
a9373c7fb0 Remove unused dep from subproviders 2018-03-09 10:17:35 +01:00
Fabio Berger
8b604462ac Add missing dependencies 2018-03-09 10:17:23 +01:00
Fabio Berger
51e4a73439 Add missing package.json fields 2018-03-09 09:48:49 +01:00
Fabio Berger
d42cdcfd43 Improve README 2018-03-09 09:38:50 +01:00
Fabio Berger
c18acd0859 Remove screenshot and host it on S3 2018-03-09 09:37:03 +01:00
Fabio Berger
9699ee4eff Merge branch 'development' into addPackagePublishConfig
* development: (94 commits)
  Update CHANGELOG
  Add solc 0.4.20 and 0.4.21
  Prettier sra-report README
  Add new packages to top level README
  Updated @0xproject/utils in top level package.json
  Publish
  Updated CHANGELOGs
  Detail tests in the README
  Add support for ropsten and rinkeby
  Fix yarn.lock
  Update list of packages and organize them alphabetically
  Fix prettier issues
  Add support for going back to previous hashes via the browser back button to wiki
  Scroll to previous hashed elements when user clicks back button
  Add back strict null checks to react-shared package and fix issues
  remove ability to have implicit dependencies and add missing deps
  update license
  remove no-implicit-this
  Add example & screenshot to npmignore
  Remove `;` to be nice to windows users
  ...
2018-03-09 08:39:38 +01:00
Tom Schmidt
c78e504bfb Fixed lint 2018-03-08 17:08:43 -08:00
Amir Bandeali
0eeaac1f2b Update CHANGELOG 2018-03-08 17:01:02 -08:00
Amir Bandeali
b578517f91 Add solc 0.4.20 and 0.4.21 2018-03-08 16:43:32 -08:00
Tom Schmidt
c009e9979e Added web3 provider logging 2018-03-08 16:06:44 -08:00
Brandon Millman
22b6097e95 Prettier sra-report README 2018-03-08 10:44:49 -08:00
Brandon Millman
8e3446a389 Add new packages to top level README 2018-03-08 10:43:54 -08:00
Brandon Millman
1747d7a1bb Updated @0xproject/utils in top level package.json 2018-03-08 10:30:52 -08:00
Fabio Berger
da277f5b27 Add package.json publishConfig so that these packages are published as public. 2018-03-08 16:57:09 +01:00
Tom Schmidt
f27e943258 Added provider canonical name mapping 2018-03-06 09:47:13 -08:00
384 changed files with 12110 additions and 2686 deletions

View File

@@ -40,6 +40,10 @@ jobs:
command: npm run testrpc -- --db testrpc_snapshot
background: true
- run: yarn lerna:run --scope 0x.js test:circleci
- save_cache:
key: coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/0x.js/coverage/lcov.info
test-contracts:
docker:
- image: circleci/node:6.12
@@ -53,6 +57,10 @@ jobs:
command: npm run testrpc -- --db testrpc_snapshot
background: true
- run: yarn lerna:run --scope contracts test:circleci
- save_cache:
key: coverage-contracts-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/contracts/coverage/lcov.info
test-deployer:
docker:
- image: circleci/node:6.12
@@ -66,6 +74,10 @@ jobs:
command: npm run testrpc -- --db testrpc_snapshot
background: true
- run: yarn lerna:run --scope @0xproject/deployer test:circleci
- save_cache:
key: coverage-deployer-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/deployer/coverage/lcov.info
test-rest:
docker:
- image: circleci/node:6.12
@@ -79,6 +91,30 @@ jobs:
command: npm run testrpc -- --db testrpc_snapshot
background: true
- run: yarn lerna:run --ignore contracts --ignore 0x.js --ignore @0xproject/deployer test:circleci
- save_cache:
key: coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/assert/coverage/lcov.info
- save_cache:
key: coverage-connect-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/connect/coverage/lcov.info
- save_cache:
key: coverage-dev-utils-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/dev-utils/coverage/lcov.info
- save_cache:
key: coverage-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/json-schemas/coverage/lcov.info
- save_cache:
key: coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/subproviders/coverage/lcov.info
- save_cache:
key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/sol-cov/coverage/lcov.info
lint:
working_directory: ~/repo
docker:
@@ -97,6 +133,42 @@ jobs:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn prettier:ci
submit-coverage:
docker:
- image: circleci/node:6.12
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-contracts-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-connect-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-dev-utils-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-deployer-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn report_coverage
workflows:
version: 2
main:
@@ -120,3 +192,9 @@ workflows:
- lint:
requires:
- build
- submit-coverage:
requires:
- test-0xjs
- test-deployer
- test-rest
- test-contracts

3
.gitignore vendored
View File

@@ -75,3 +75,6 @@ bin/
# generated contract artifacts
packages/contracts/src/artifacts
# Monorepo scripts
packages/*/scripts/

View File

@@ -10,7 +10,7 @@ This repository is a monorepo including the 0x protocol smart contracts and nume
[whitepaper-url]: https://0xproject.com/pdfs/0x_white_paper.pdf
[![CircleCI](https://circleci.com/gh/0xProject/0x-monorepo.svg?style=svg&circle-token=61bf7cd8c9b4e11b132089dfcffdd1be277d1e0c)](https://circleci.com/gh/0xProject/0x-monorepo)
[![Coverage Status](https://coveralls.io/repos/github/0xProject/0x-monorepo/badge.svg?branch=master&t=fp0cXD)](https://coveralls.io/github/0xProject/0x-monorepo?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/0xProject/0x-monorepo/badge.svg?branch=development)](https://coveralls.io/github/0xProject/0x-monorepo?branch=development)
[![Discord](https://img.shields.io/badge/chat-rocket.chat-yellow.svg?style=flat)](https://chat.0xproject.com)
[![Join the chat at https://gitter.im/0xProject/Lobby](https://badges.gitter.im/0xProject/Lobby.svg)](https://gitter.im/0xProject/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
@@ -18,34 +18,42 @@ This repository is a monorepo including the 0x protocol smart contracts and nume
### Published Packages
| Package | Version | Description |
| ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [`0x.js`](/packages/0x.js) | [![npm](https://img.shields.io/npm/v/0x.js.svg)](https://www.npmjs.com/package/0x.js) | A Javascript library for interacting with the 0x protocol |
| [`@0xproject/abi-gen`](/packages/abi-gen) | [![npm](https://img.shields.io/npm/v/@0xproject/abi-gen.svg)](https://www.npmjs.com/package/@0xproject/abi-gen) | Tool to generate TS wrappers from smart contract ABIs |
| [`@0xproject/assert`](/packages/assert) | [![npm](https://img.shields.io/npm/v/@0xproject/assert.svg)](https://www.npmjs.com/package/@0xproject/assert) | Type and schema assertions used by our packages |
| [`@0xproject/base-contract`](/packages/base-contract) | [![npm](https://img.shields.io/npm/v/@0xproject/base-contract.svg)](https://www.npmjs.com/package/@0xproject/base-contract) | BaseContract used by auto-generated `abi-gen` wrapper contracts |
| [`@0xproject/connect`](/packages/connect) | [![npm](https://img.shields.io/npm/v/@0xproject/connect.svg)](https://www.npmjs.com/package/@0xproject/connect) | A Javascript library for interacting with the Standard Relayer API |
| [`@0xproject/deployer`](/packages/deployer) | [![npm](https://img.shields.io/npm/v/@0xproject/deployer.svg)](https://www.npmjs.com/package/@0xproject/deployer) | Solidity project compiler and deployer framework |
| [`@0xproject/dev-utils`](/packages/dev-utils) | [![npm](https://img.shields.io/npm/v/@0xproject/dev-utils.svg)](https://www.npmjs.com/package/@0xproject/dev-utils) | Dev utils to be shared across 0x projects and packages |
| [`@0xproject/json-schemas`](/packages/json-schemas) | [![npm](https://img.shields.io/npm/v/@0xproject/json-schemas.svg)](https://www.npmjs.com/package/@0xproject/json-schemas) | 0x-related json schemas |
| [`@0xproject/react-docs`](/packages/react-docs) | [![npm](https://img.shields.io/npm/v/@0xproject/react-docs.svg)](https://www.npmjs.com/package/@0xproject/react-docs) | React documentation component for rendering TypeDoc & Doxity generated JSON |
| [`@0xproject/react-shared`](/packages/react-shared) | [![npm](https://img.shields.io/npm/v/@0xproject/react-shared.svg)](https://www.npmjs.com/package/@0xproject/react-shared) | 0x shared react components |
| [`@0xproject/sra-report`](/packages/sra-report) | [![npm](https://img.shields.io/npm/v/@0xproject/sra-report.svg)](https://www.npmjs.com/package/@0xproject/sra-report) | Generate reports for standard relayer API compliance |
| [`@0xproject/subproviders`](/packages/subproviders) | [![npm](https://img.shields.io/npm/v/@0xproject/subproviders.svg)](https://www.npmjs.com/package/@0xproject/subproviders) | Useful web3 subproviders (e.g LedgerSubprovider) |
| [`@0xproject/tslint-config`](/packages/tslint-config) | [![npm](https://img.shields.io/npm/v/@0xproject/tslint-config.svg)](https://www.npmjs.com/package/@0xproject/tslint-config) | Custom 0x development TSLint rules |
| [`@0xproject/types`](/packages/types) | [![npm](https://img.shields.io/npm/v/@0xproject/types.svg)](https://www.npmjs.com/package/@0xproject/types) | Shared type declarations |
| [`@0xproject/utils`](/packages/utils) | [![npm](https://img.shields.io/npm/v/@0xproject/utils.svg)](https://www.npmjs.com/package/@0xproject/utils) | Shared utilities |
| [`@0xproject/web3-wrapper`](/packages/web3-wrapper) | [![npm](https://img.shields.io/npm/v/@0xproject/web3-wrapper.svg)](https://www.npmjs.com/package/@0xproject/web3-wrapper) | Web3 wrapper |
### TypeScript Typings
| Package | Version | Description |
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [`0x.js`](/packages/0x.js) | [![npm](https://img.shields.io/npm/v/0x.js.svg)](https://www.npmjs.com/package/0x.js) | A Javascript library for interacting with the 0x protocol |
| [`@0xproject/abi-gen`](/packages/abi-gen) | [![npm](https://img.shields.io/npm/v/@0xproject/abi-gen.svg)](https://www.npmjs.com/package/@0xproject/abi-gen) | Tool to generate TS wrappers from smart contract ABIs |
| [`@0xproject/assert`](/packages/assert) | [![npm](https://img.shields.io/npm/v/@0xproject/assert.svg)](https://www.npmjs.com/package/@0xproject/assert) | Type and schema assertions used by our packages |
| [`@0xproject/base-contract`](/packages/base-contract) | [![npm](https://img.shields.io/npm/v/@0xproject/base-contract.svg)](https://www.npmjs.com/package/@0xproject/base-contract) | BaseContract to derive all auto-generated wrappers from |
| [`chai-as-promised-typescript-typings`](/packages/chai-as-promised-typescript-typings) | [![npm](https://img.shields.io/npm/v/chai-as-promised-typescript-typings.svg)](https://www.npmjs.com/package/chai-as-promised-typescript-typings) | Chai as promised typescript typings |
| [`chai-typescript-typings`](/packages/chai-typescript-typings) | [![npm](https://img.shields.io/npm/v/chai-typescript-typings.svg)](https://www.npmjs.com/package/chai-typescript-typings) | Chai typescript typings |
| [`@0xproject/connect`](/packages/connect) | [![npm](https://img.shields.io/npm/v/@0xproject/connect.svg)](https://www.npmjs.com/package/@0xproject/connect) | A Javascript library for interacting with the standard relayer api |
| [`@0xproject/deployer`](/packages/deployer) | [![npm](https://img.shields.io/npm/v/@0xproject/deployer.svg)](https://www.npmjs.com/package/@0xproject/deployer) | Smart contract deployer |
| [`@0xproject/dev-utils`](/packages/dev-utils) | [![npm](https://img.shields.io/npm/v/@0xproject/dev-utils.svg)](https://www.npmjs.com/package/@0xproject/dev-utils) | Dev utils to be shared across 0x projects and packages |
| [`ethers-typescript-typings`](/packages/ethers-typescript-typings) | [![npm](https://img.shields.io/npm/v/@0xproject/deployer.svg)](https://www.npmjs.com/package/ethers-typescript-typings) | [Ethers.js](https://github.com/ethers-io/ethers.js/) typescript typings |
| [`@0xproject/json-schemas`](/packages/json-schemas) | [![npm](https://img.shields.io/npm/v/@0xproject/json-schemas.svg)](https://www.npmjs.com/package/@0xproject/json-schemas) | 0x-related json schemas |
| [`@0xproject/subproviders`](/packages/subproviders) | [![npm](https://img.shields.io/npm/v/@0xproject/subproviders.svg)](https://www.npmjs.com/package/@0xproject/subproviders) | Useful web3 subproviders (e.g LedgerSubprovider) |
| [`@0xproject/tslint-config`](/packages/tslint-config) | [![npm](https://img.shields.io/npm/v/@0xproject/tslint-config.svg)](https://www.npmjs.com/package/@0xproject/tslint-config) | Custom 0x development TSLint rules |
| [`@0xproject/types`](/packages/types) | [![npm](https://img.shields.io/npm/v/@0xproject/types.svg)](https://www.npmjs.com/package/@0xproject/types) | Shared type declarations |
| [`@0xproject/utils`](/packages/utils) | [![npm](https://img.shields.io/npm/v/@0xproject/utils.svg)](https://www.npmjs.com/package/@0xproject/utils) | Shared utilities |
| [`web3-typescript-typings`](/packages/web3-typescript-typings) | [![npm](https://img.shields.io/npm/v/web3-typescript-typings.svg)](https://www.npmjs.com/package/web3-typescript-typings) | Web3 typescript typings |
| [`@0xproject/web3-wrapper`](/packages/web3-wrapper) | [![npm](https://img.shields.io/npm/v/@0xproject/web3-wrapper.svg)](https://www.npmjs.com/package/@0xproject/web3-wrapper) | Web3 wrapper |
### Private Packages
| Package | Description |
| ----------------------------------------------------------- | ---------------------------------------------------------------- |
| [`@0xproject/contracts`](/packages/contracts) | 0x solidity smart contracts & tests |
| [`@0xproject/monorepo-scripts`](/packages/monorepo-scripts) | Shared monorepo scripts |
| [`@0xproject/testnet-faucets`](/packages/testnet-faucets) | A faucet micro-service that dispenses test ERC20 tokens or Ether |
| [`@0xproject/website`](/packages/website) | 0x website & Portal DApp |
| Package | Description |
| --------------------------------------------------------------- | ---------------------------------------------------------------- |
| [`@0xproject/contracts`](/packages/contracts) | 0x solidity smart contracts & tests |
| [`@0xproject/react-docs-example`](/packages/react-docs-example) | Example documentation site created with `@0xproject/react-docs` |
| [`@0xproject/testnet-faucets`](/packages/testnet-faucets) | A faucet micro-service that dispenses test ERC20 tokens or Ether |
| [`@0xproject/website`](/packages/website) | 0x website & Portal DApp |
## Usage

View File

@@ -7,6 +7,7 @@
"testrpc": "testrpc -p 8545 --networkId 50 -m \"${npm_package_config_mnemonic}\"",
"prettier": "prettier --write '**/*.{ts,tsx,json,md}' --config .prettierrc",
"prettier:ci": "prettier --list-different '**/*.{ts,tsx,json,md}' --config .prettierrc",
"report_coverage": "lcov-result-merger 'packages/*/coverage/lcov.info' | coveralls",
"lerna:run": "lerna run",
"lerna:rebuild": "lerna run clean; lerna run build;",
"lerna:publish":
@@ -16,12 +17,12 @@
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic"
},
"devDependencies": {
"@0xproject/utils": "^0.4.0",
"@0xproject/utils": "^0.4.1",
"async-child-process": "^1.1.1",
"coveralls": "^3.0.0",
"ethereumjs-testrpc": "^6.0.3",
"lcov-result-merger": "^2.0.0",
"lerna": "^2.5.1",
"prettier": "^1.11.1",
"publish-release": "0xproject/publish-release",
"semver-sort": "^0.0.4"
"prettier": "^1.11.1"
}
}

View File

@@ -1,5 +1,10 @@
# CHANGELOG
## v0.33.2 - _March 18, 2018_
* Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package (#452)
* Consolidate `Order`, `SignedOrder`, and `ECSignature` into the `@0xproject/types` package (#456)
## v0.33.1 - _March 8, 2018_
* Add missing EthersJs typescript typings as dependency

View File

View File

@@ -19,19 +19,27 @@
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json",
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"test:circleci": "run-s test:coverage report_test_coverage",
"test:circleci": "run-s test:coverage",
"test": "run-s clean test:commonjs",
"test:coverage": "nyc npm run test --all",
"report_test_coverage": "nyc report --reporter=text-lcov | coveralls",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"update_contracts": "for i in ${npm_package_config_artifacts}; do copyfiles -u 4 ../contracts/build/contracts/$i.json ../0x.js/src/artifacts; done;",
"clean": "shx rm -rf _bundles lib test_temp",
"clean": "shx rm -rf _bundles lib test_temp scripts",
"build:umd:prod": "NODE_ENV=production webpack",
"build:commonjs": "tsc && copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts;",
"build:commonjs": "tsc && copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"test:commonjs": "run-s build:commonjs run_mocha",
"run_mocha": "mocha lib/test/**/*_test.js --timeout 10000 --bail --exit"
},
"config": {
"artifacts": "TokenTransferProxy Exchange TokenRegistry Token EtherToken"
"artifacts": "TokenTransferProxy Exchange TokenRegistry Token EtherToken",
"postpublish": {
"assets": ["_bundles/index.js", "_bundles/index.min.js"],
"docPublishConfigs": {
"extraFileIncludes": ["../types/src/index.ts"],
"s3BucketPath": "s3://0xjs-docs-jsons/",
"s3StagingBucketPath": "s3://staging-0xjs-docs-jsons/"
}
}
},
"repository": {
"type": "git",
@@ -44,6 +52,7 @@
"devDependencies": {
"@0xproject/abi-gen": "^0.2.5",
"@0xproject/dev-utils": "^0.2.1",
"@0xproject/monorepo-scripts": "^0.1.12",
"@0xproject/tslint-config": "^0.4.10",
"@types/bintrees": "^1.0.2",
"@types/jsonschema": "^1.1.1",
@@ -59,13 +68,13 @@
"chai-bignumber": "^2.0.1",
"chai-typescript-typings": "^0.0.4",
"copyfiles": "^1.2.0",
"coveralls": "^3.0.0",
"dirty-chai": "^2.0.1",
"json-loader": "^0.5.4",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",
"nyc": "^11.0.1",
"opn-cli": "^3.1.0",
"prettier": "^1.11.1",
"request": "^2.81.0",
"request-promise-native": "^1.0.5",
"shx": "^0.2.2",
@@ -98,5 +107,8 @@
"uuid": "^3.1.0",
"web3": "^0.20.0",
"web3-typescript-typings": "^0.10.0"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,47 +0,0 @@
const execAsync = require('async-child-process').execAsync;
const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const tsConfig = require('../tsconfig.json');
const cwd = __dirname + '/..';
const subPackageName = packageJSON.name;
// Include any external packages that are part of the 0x.js public interface
// to this array so that TypeDoc picks it up and adds it to the Docs JSON
// So far, we only have @0xproject/types as part of 0x.js's public interface.
const fileIncludes = [...tsConfig.include, '../types/src/index.ts'];
const fileIncludesAdjusted = postpublish_utils.adjustFileIncludePaths(fileIncludes, __dirname);
const projectFiles = fileIncludesAdjusted.join(' ');
const S3BucketPath = 's3://0xjs-docs-jsons/';
let tag;
let version;
postpublish_utils
.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
tag = result.tag;
version = result.version;
const releaseName = postpublish_utils.getReleaseName(subPackageName, version);
const assets = [__dirname + '/../_bundles/index.js', __dirname + '/../_bundles/index.min.js'];
return postpublish_utils.publishReleaseNotesAsync(tag, releaseName, assets);
})
.then(function(release) {
console.log('POSTPUBLISH: Release successful, generating docs...');
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
return execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_FILES="' + projectFiles + '" yarn docs:json', {
cwd,
});
})
.then(function(result) {
if (result.stderr !== '') {
throw new Error(result.stderr);
}
const fileName = 'v' + version + '.json';
console.log('POSTPUBLISH: Doc generation successful, uploading docs... as ', fileName);
const s3Url = S3BucketPath + fileName;
return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', {
cwd,
});
})
.catch(function(err) {
throw err;
});

View File

@@ -1,31 +0,0 @@
const execAsync = require('async-child-process').execAsync;
const postpublish_utils = require('../../../scripts/postpublish_utils');
const tsConfig = require('../tsconfig.json');
const cwd = __dirname + '/..';
const S3BucketPath = 's3://staging-0xjs-docs-jsons/';
// Include any external packages that are part of the 0x.js public interface
// to this array so that TypeDoc picks it up and adds it to the Docs JSON
// So far, we only have @0xproject/types as part of 0x.js's public interface.
const fileIncludes = [...tsConfig.include, '../types/src/index.ts'];
const fileIncludesAdjusted = postpublish_utils.adjustFileIncludePaths(fileIncludes, __dirname);
const projectFiles = fileIncludesAdjusted.join(' ');
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
const version = process.env.DOCS_VERSION;
execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_FILES="' + projectFiles + '" yarn docs:json', {
cwd,
})
.then(function(result) {
if (result.stderr !== '') {
throw new Error(result.stderr);
}
const fileName = 'v' + version + '.json';
const s3Url = S3BucketPath + fileName;
return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', {
cwd,
});
})
.catch(function(err) {
console.log(err);
});

View File

@@ -1,5 +1,5 @@
import { schemas, SchemaValidator } from '@0xproject/json-schemas';
import { TransactionReceiptWithDecodedLogs } from '@0xproject/types';
import { ECSignature, Order, SignedOrder, TransactionReceiptWithDecodedLogs } from '@0xproject/types';
import { AbiDecoder, BigNumber, intervalUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as ethUtil from 'ethereumjs-util';
@@ -15,7 +15,7 @@ import { OrderStateWatcher } from './order_watcher/order_state_watcher';
import { zeroExConfigSchema } from './schemas/zero_ex_config_schema';
import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema';
import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema';
import { ECSignature, Order, SignedOrder, Web3Provider, ZeroExConfig, ZeroExError } from './types';
import { Web3Provider, ZeroExConfig, ZeroExError } from './types';
import { assert } from './utils/assert';
import { constants } from './utils/constants';
import { decorators } from './utils/decorators';

View File

@@ -1,5 +1,12 @@
import { schemas } from '@0xproject/json-schemas';
import { BlockParamLiteral, DecodedLogArgs, LogWithDecodedArgs } from '@0xproject/types';
import {
BlockParamLiteral,
DecodedLogArgs,
ECSignature,
LogWithDecodedArgs,
Order,
SignedOrder,
} from '@0xproject/types';
import { AbiDecoder, BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
@@ -8,19 +15,16 @@ import * as Web3 from 'web3';
import { artifacts } from '../artifacts';
import {
BlockRange,
ECSignature,
EventCallback,
ExchangeContractErrCodes,
ExchangeContractErrs,
IndexedFilterValues,
MethodOpts,
Order,
OrderAddresses,
OrderCancellationRequest,
OrderFillRequest,
OrderTransactionOpts,
OrderValues,
SignedOrder,
ValidateOrderFillableOpts,
} from '../types';
import { assert } from '../utils/assert';

View File

@@ -4,6 +4,12 @@ declare module 'dirty-chai';
declare module 'request-promise-native';
declare module 'web3-provider-engine';
declare module 'web3-provider-engine/subproviders/rpc';
declare module 'publish-release';
// semver-sort declarations
declare module 'semver-sort' {
const desc: (versions: string[]) => string[];
}
// HACK: In order to merge the bignumber declaration added by chai-bignumber to the chai Assertion
// interface we must use `namespace` as the Chai definitelyTyped definition does. Since we otherwise

View File

@@ -1,9 +1,6 @@
export { ZeroEx } from './0x';
export {
Order,
SignedOrder,
ECSignature,
ZeroExError,
EventCallback,
ExchangeContractErrs,
@@ -34,6 +31,9 @@ export {
BlockParam,
ContractEventArg,
LogWithDecodedArgs,
Order,
SignedOrder,
ECSignature,
TransactionReceipt,
TransactionReceiptWithDecodedLogs,
} from '@0xproject/types';

View File

@@ -0,0 +1,8 @@
import { postpublishUtils } from '@0xproject/monorepo-scripts';
import * as packageJSON from '../package.json';
import * as tsConfigJSON from '../tsconfig.json';
const cwd = `${__dirname}/..`;
// tslint:disable-next-line:no-floating-promises
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);

View File

@@ -0,0 +1,8 @@
import { postpublishUtils } from '@0xproject/monorepo-scripts';
import * as packageJSON from '../package.json';
import * as tsConfigJSON from '../tsconfig.json';
const cwd = `${__dirname}/..`;
// tslint:disable-next-line:no-floating-promises
postpublishUtils.publishDocsToStagingAsync(packageJSON, tsConfigJSON, cwd);

View File

@@ -1,5 +1,5 @@
import { schemas } from '@0xproject/json-schemas';
import { BlockParamLiteral, LogWithDecodedArgs } from '@0xproject/types';
import { BlockParamLiteral, LogWithDecodedArgs, SignedOrder } from '@0xproject/types';
import { AbiDecoder, intervalUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
@@ -31,7 +31,6 @@ import {
OnOrderStateChangeCallback,
OrderState,
OrderStateWatcherConfig,
SignedOrder,
ZeroExError,
} from '../types';
import { assert } from '../utils/assert';

View File

@@ -1,7 +1,6 @@
import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { SignedOrder } from '../types';
export class RemainingFillableCalculator {
private _signedOrder: SignedOrder;
private _isMakerTokenZRX: boolean;

View File

@@ -1,6 +1,13 @@
import { BigNumber } from '@0xproject/utils';
import { BlockParam, BlockParamLiteral, ContractEventArg, LogWithDecodedArgs } from '@0xproject/types';
import {
BlockParam,
BlockParamLiteral,
ContractEventArg,
LogWithDecodedArgs,
Order,
SignedOrder,
} from '@0xproject/types';
import * as Web3 from 'web3';
@@ -37,15 +44,6 @@ export enum InternalZeroExError {
WethNotInTokenRegistry = 'WETH_NOT_IN_TOKEN_REGISTRY',
}
/**
* Elliptic Curve signature
*/
export interface ECSignature {
v: number;
r: string;
s: string;
}
export type OrderAddresses = [string, string, string, string, string];
export type OrderValues = [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber];
@@ -107,25 +105,6 @@ export interface ContractEvent {
export type ContractEventArgs = ExchangeContractEventArgs | TokenContractEventArgs | EtherTokenContractEventArgs;
export interface Order {
maker: string;
taker: string;
makerFee: BigNumber;
takerFee: BigNumber;
makerTokenAmount: BigNumber;
takerTokenAmount: BigNumber;
makerTokenAddress: string;
takerTokenAddress: string;
salt: BigNumber;
exchangeContractAddress: string;
feeRecipient: string;
expirationUnixTimestampSec: BigNumber;
}
export interface SignedOrder extends Order {
ecSignature: ECSignature;
}
// [address, name, symbol, decimals, ipfsHash, swarmHash]
export type TokenMetadata = [string, string, string, number, string, string];

View File

@@ -3,11 +3,11 @@ import { assert as sharedAssert } from '@0xproject/assert';
// tslint:disable-next-line:no-unused-variable
import { Schema } from '@0xproject/json-schemas';
// tslint:disable-next-line:no-unused-variable
import { ECSignature } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import { ECSignature } from '../types';
import { signatureUtils } from '../utils/signature_utils';
export const assert = {

View File

@@ -1,3 +1,4 @@
import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
@@ -6,14 +7,7 @@ import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
import { RemainingFillableCalculator } from '../order_watcher/remaining_fillable_calculator';
import { BalanceAndProxyAllowanceLazyStore } from '../stores/balance_proxy_allowance_lazy_store';
import { OrderFilledCancelledLazyStore } from '../stores/order_filled_cancelled_lazy_store';
import {
ExchangeContractErrs,
OrderRelevantState,
OrderState,
OrderStateInvalid,
OrderStateValid,
SignedOrder,
} from '../types';
import { ExchangeContractErrs, OrderRelevantState, OrderState, OrderStateInvalid, OrderStateValid } from '../types';
const ACCEPTABLE_RELATIVE_ROUNDING_ERROR = 0.0001;

View File

@@ -1,9 +1,10 @@
import { Order, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import { ZeroEx } from '../0x';
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
import { ExchangeContractErrs, Order, SignedOrder, TradeSide, TransferType, ZeroExError } from '../types';
import { ExchangeContractErrs, TradeSide, TransferType, ZeroExError } from '../types';
import { constants } from '../utils/constants';
import { utils } from '../utils/utils';

View File

@@ -1,7 +1,6 @@
import { ECSignature } from '@0xproject/types';
import * as ethUtil from 'ethereumjs-util';
import { ECSignature } from '../types';
export const signatureUtils = {
isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean {
const dataBuff = ethUtil.toBuffer(data);

View File

@@ -1,12 +1,10 @@
import { SolidityTypes } from '@0xproject/types';
import { Order, SignedOrder, SolidityTypes } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import BN = require('bn.js');
import * as ethABI from 'ethereumjs-abi';
import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash';
import { Order, SignedOrder } from '../types';
export const utils = {
/**
* Converts BigNumber instance to BN
@@ -17,10 +15,6 @@ export const utils = {
bigNumberToBN(value: BigNumber) {
return new BN(value.toString(), 10);
},
consoleLog(message: string): void {
// tslint:disable-next-line: no-console
console.log(message);
},
spawnSwitchErr(name: string, value: any): Error {
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
},

View File

@@ -10,15 +10,15 @@ import { ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, Zero
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
chaiSetup.configure();
const expect = chai.expect;
const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false;
describe('ZeroEx library', () => {
const web3 = web3Factory.create();
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
};

View File

@@ -23,10 +23,11 @@ import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
// Since the address depositing/withdrawing ETH/WETH also needs to pay gas costs for the transaction,
// a small amount of ETH will be used to pay this gas cost. We therefore check that the difference between
@@ -35,7 +36,6 @@ const blockchainLifecycle = new BlockchainLifecycle();
const MAX_REASONABLE_GAS_COST_IN_WEI = 62517;
describe('EtherTokenWrapper', () => {
let web3: Web3;
let zeroEx: ZeroEx;
let tokens: Token[];
let userAddresses: string[];
@@ -54,7 +54,6 @@ describe('EtherTokenWrapper', () => {
const depositAmount = new BigNumber(42);
const withdrawalAmount = new BigNumber(42);
before(async () => {
web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig);
tokens = await zeroEx.tokenRegistry.getTokensAsync();
userAddresses = await zeroEx.getAvailableAddressesAsync();

View File

@@ -1,4 +1,4 @@
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
import { BlockParamLiteral } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
@@ -9,13 +9,13 @@ import { ExchangeTransferSimulator } from '../src/utils/exchange_transfer_simula
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { web3, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('ExchangeTransferSimulator', () => {
const web3 = web3Factory.create();
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
};

View File

@@ -26,15 +26,15 @@ import { constants } from './utils/constants';
import { FillScenarios } from './utils/fill_scenarios';
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const NON_EXISTENT_ORDER_HASH = '0x79370342234e7acd6bbeac335bd3bb1d368383294b64b8160a00f4060e4d3777';
describe('ExchangeWrapper', () => {
let web3: Web3;
let zeroEx: ZeroEx;
let tokenUtils: TokenUtils;
let tokens: Token[];
@@ -46,7 +46,6 @@ describe('ExchangeWrapper', () => {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider, config);
exchangeContractAddress = zeroEx.exchange.getContractAddress();
userAddresses = await zeroEx.getAvailableAddressesAsync();

View File

@@ -1,4 +1,4 @@
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
@@ -16,13 +16,13 @@ import { constants } from './utils/constants';
import { FillScenarios } from './utils/fill_scenarios';
import { reportNoErrorCallbackErrors } from './utils/report_callback_errors';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('ExpirationWatcher', () => {
let web3: Web3;
let zeroEx: ZeroEx;
let tokenUtils: TokenUtils;
let tokens: Token[];
@@ -41,7 +41,6 @@ describe('ExpirationWatcher', () => {
let timer: Sinon.SinonFakeTimers;
let expirationWatcher: ExpirationWatcher;
before(async () => {
web3 = web3Factory.create();
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
};

View File

@@ -1,4 +1,4 @@
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
@@ -22,15 +22,15 @@ import { constants } from './utils/constants';
import { FillScenarios } from './utils/fill_scenarios';
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
const TIMEOUT_MS = 150;
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('OrderStateWatcher', () => {
let web3: Web3;
let zeroEx: ZeroEx;
let tokens: Token[];
let tokenUtils: TokenUtils;
@@ -49,7 +49,6 @@ describe('OrderStateWatcher', () => {
const decimals = constants.ZRX_DECIMALS;
const fillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals);
before(async () => {
web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider, config);
exchangeContractAddress = zeroEx.exchange.getContractAddress();
userAddresses = await zeroEx.getAvailableAddressesAsync();

View File

@@ -1,4 +1,4 @@
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
import { BlockParamLiteral } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
@@ -14,13 +14,13 @@ import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { FillScenarios } from './utils/fill_scenarios';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('OrderValidation', () => {
let web3: Web3;
let zeroEx: ZeroEx;
let userAddresses: string[];
let tokens: Token[];
@@ -40,7 +40,6 @@ describe('OrderValidation', () => {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider, config);
exchangeContractAddress = zeroEx.exchange.getContractAddress();
userAddresses = await zeroEx.getAvailableAddressesAsync();

View File

@@ -1,10 +1,10 @@
import { ECSignature, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import 'mocha';
import { ZeroEx } from '../src/0x';
import { RemainingFillableCalculator } from '../src/order_watcher/remaining_fillable_calculator';
import { ECSignature, SignedOrder } from '../src/types';
import { chaiSetup } from './utils/chai_setup';

View File

@@ -1,4 +1,4 @@
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import 'mocha';
@@ -11,12 +11,12 @@ import { DoneCallback } from '../src/types';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { assertNodeCallbackError } from './utils/report_callback_errors';
import { web3, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('SubscriptionTest', () => {
let web3: Web3;
let zeroEx: ZeroEx;
let userAddresses: string[];
let tokens: Token[];
@@ -26,7 +26,6 @@ describe('SubscriptionTest', () => {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider, config);
userAddresses = await zeroEx.getAvailableAddressesAsync();
tokens = await zeroEx.tokenRegistry.getTokensAsync();

View File

@@ -1,4 +1,4 @@
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
import { schemas, SchemaValidator } from '@0xproject/json-schemas';
import * as chai from 'chai';
import * as _ from 'lodash';
@@ -8,10 +8,11 @@ import { Token, ZeroEx } from '../src';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { web3, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const TOKEN_REGISTRY_SIZE_AFTER_MIGRATION = 7;
@@ -30,7 +31,6 @@ describe('TokenRegistryWrapper', () => {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
const web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider, config);
tokens = await zeroEx.tokenRegistry.getTokensAsync();
_.map(tokens, token => {

View File

@@ -8,6 +8,7 @@ import { constants } from './utils/constants';
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
describe('TokenTransferProxyWrapper', () => {
let zeroEx: ZeroEx;
@@ -15,7 +16,6 @@ describe('TokenTransferProxyWrapper', () => {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
const web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider, config);
});
describe('#isAuthorizedAsync', () => {

View File

@@ -22,27 +22,24 @@ import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('TokenWrapper', () => {
let web3: Web3;
let zeroEx: ZeroEx;
let userAddresses: string[];
let tokens: Token[];
let tokenUtils: TokenUtils;
let coinbase: string;
let addressWithoutFunds: string;
let web3Wrapper: Web3Wrapper;
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider, config);
web3Wrapper = new Web3Wrapper(web3.currentProvider);
userAddresses = await zeroEx.getAvailableAddressesAsync();
tokens = await zeroEx.tokenRegistry.getTokensAsync();
tokenUtils = new TokenUtils(tokens);
@@ -194,7 +191,7 @@ describe('TokenWrapper', () => {
let zeroExWithoutAccounts: ZeroEx;
before(async () => {
const hasAddresses = false;
const web3WithoutAccounts = web3Factory.create(hasAddresses);
const web3WithoutAccounts = web3Factory.create({ hasAddresses });
zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config);
});
it('should return balance even when called with Web3 provider instance without addresses', async () => {
@@ -306,7 +303,7 @@ describe('TokenWrapper', () => {
let zeroExWithoutAccounts: ZeroEx;
before(async () => {
const hasAddresses = false;
const web3WithoutAccounts = web3Factory.create(hasAddresses);
const web3WithoutAccounts = web3Factory.create({ hasAddresses });
zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config);
});
it('should get the proxy allowance', async () => {

View File

@@ -0,0 +1,6 @@
import { web3Factory } from '@0xproject/dev-utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as Web3 from 'web3';
export const web3 = web3Factory.create();
export const web3Wrapper = new Web3Wrapper(web3.currentProvider);

View File

@@ -1,5 +1,9 @@
# CHANGELOG
## v0.2.5 - _March 18, 2018_
* Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package (#452)
## v0.2.4 - _March 4, 2018_
* Add a `backend` parameter that allows you to specify the Ethereum library you use in your templates (`web3` or `ethers`). Ethers auto-converts small ints to numbers whereas Web3 doesn't. Defaults to `web3` (#413)

View File

@@ -16,24 +16,33 @@ For an example of the generated [wrapper files](https://github.com/0xProject/0x-
```
abi-gen
Options:
--help Show help [boolean]
--version Show version number [boolean]
--abiGlob Glob pattern to search for ABI JSON files [string] [required]
--templates Folder where to search for templates [string] [required]
--output Folder where to put the output files [string] [required]
--help Show help [boolean]
--version Show version number [boolean]
--abis Glob pattern to search for ABI JSON files
[string] [required]
--output, -o, --out Folder where to put the output files [string] [required]
--partials Glob pattern for the partial template files [string]
--template Path for the main template file that will be used to
generate each contract [string] [required]
--backend The backing Ethereum library your app uses. Either 'web3'
or 'ethers'. Ethers auto-converts small ints to numbers
whereas Web3 doesn't.
[string] [choices: "web3", "ethers"] [default: "web3"]
--network-id ID of the network where contract ABIs are nested in
artifacts [number] [default: 50]
```
## ABI files
You're required to pass a [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) template where your abi files are located.
TL;DR - here is the example from 0x.js.
`--abiGlob 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry).json`
`--abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry).json`
We could've just used `--abiGlob 'src/artifacts/*.json` but we wanted to exclude some of the abi files.
We could've just used `--abis 'src/artifacts/*.json` but we wanted to exclude some of the abi files.
The abi file should be either a [Truffle](http://truffleframework.com/) contract artifact (a JSON object with an abi key) or a JSON abi array.
You need to also specify the location of your main template used for every contract `--template` as well as the partial templates `--partials` that can later be used from the main one.
## How to write custom templates?
The best way to get started is to copy [0x.js templates](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/contract_templates) and start adjusting them for your needs.

View File

@@ -7,8 +7,8 @@
"scripts": {
"build:watch": "tsc -w",
"lint": "tslint --project . 'src/**/*.ts'",
"clean": "shx rm -rf lib",
"build": "tsc"
"clean": "shx rm -rf lib scripts",
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts"
},
"bin": {
"abi-gen": "lib/index.js"
@@ -34,16 +34,21 @@
"yargs": "^10.0.3"
},
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.12",
"@0xproject/tslint-config": "^0.4.10",
"@types/glob": "^5.0.33",
"@types/handlebars": "^4.0.36",
"@types/mkdirp": "^0.5.1",
"@types/node": "^8.0.53",
"@types/yargs": "^10.0.0",
"copyfiles": "^1.2.0",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.10.0"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,5 +0,0 @@
const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -2,3 +2,10 @@ declare function toSnakeCase(str: string): string;
declare module 'to-snake-case' {
export = toSnakeCase;
}
declare module '*.json' {
const json: any;
/* tslint:disable */
export default json;
/* tslint:enable */
}

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env node
import { logUtils } from '@0xproject/utils';
import chalk from 'chalk';
import * as fs from 'fs';
import { sync as globSync } from 'glob';
@@ -62,7 +63,7 @@ const args = yargs
function registerPartials(partialsGlob: string) {
const partialTemplateFileNames = globSync(partialsGlob);
utils.log(`Found ${chalk.green(`${partialTemplateFileNames.length}`)} ${chalk.bold('partial')} templates`);
logUtils.log(`Found ${chalk.green(`${partialTemplateFileNames.length}`)} ${chalk.bold('partial')} templates`);
for (const partialTemplateFileName of partialTemplateFileNames) {
const namedContent = utils.getNamedContent(partialTemplateFileName);
Handlebars.registerPartial(namedContent.name, namedContent.content);
@@ -77,7 +78,7 @@ function writeOutputFile(name: string, renderedTsCode: string): void {
}
const filePath = `${args.output}/${fileName}.ts`;
fs.writeFileSync(filePath, renderedTsCode);
utils.log(`Created: ${chalk.bold(filePath)}`);
logUtils.log(`Created: ${chalk.bold(filePath)}`);
}
Handlebars.registerHelper('parameterType', utils.solTypeToTsType.bind(utils, ParamKind.Input, args.backend));
@@ -91,17 +92,17 @@ const template = Handlebars.compile<ContextData>(mainTemplate.content);
const abiFileNames = globSync(args.abis);
if (_.isEmpty(abiFileNames)) {
utils.log(`${chalk.red(`No ABI files found.`)}`);
utils.log(`Please make sure you've passed the correct folder name and that the files have
logUtils.log(`${chalk.red(`No ABI files found.`)}`);
logUtils.log(`Please make sure you've passed the correct folder name and that the files have
${chalk.bold('*.json')} extensions`);
process.exit(1);
} else {
utils.log(`Found ${chalk.green(`${abiFileNames.length}`)} ${chalk.bold('ABI')} files`);
logUtils.log(`Found ${chalk.green(`${abiFileNames.length}`)} ${chalk.bold('ABI')} files`);
mkdirp.sync(args.output);
}
for (const abiFileName of abiFileNames) {
const namedContent = utils.getNamedContent(abiFileName);
utils.log(`Processing: ${chalk.bold(namedContent.name)}...`);
logUtils.log(`Processing: ${chalk.bold(namedContent.name)}...`);
const parsedContent = JSON.parse(namedContent.content);
let ABI;
if (_.isArray(parsedContent)) {
@@ -112,8 +113,8 @@ for (const abiFileName of abiFileNames) {
ABI = parsedContent.networks[args.networkId].abi; // 0x contracts package artifact
}
if (_.isUndefined(ABI)) {
utils.log(`${chalk.red(`ABI not found in ${abiFileName}.`)}`);
utils.log(
logUtils.log(`${chalk.red(`ABI not found in ${abiFileName}.`)}`);
logUtils.log(
`Please make sure your ABI file is either an array with ABI entries or a truffle artifact or 0x deployer artifact`,
);
process.exit(1);

View File

@@ -0,0 +1,8 @@
import { postpublishUtils } from '@0xproject/monorepo-scripts';
import * as packageJSON from '../package.json';
import * as tsConfigJSON from '../tsconfig.json';
const cwd = `${__dirname}/..`;
// tslint:disable-next-line:no-floating-promises
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);

View File

@@ -73,9 +73,6 @@ export const utils = {
isObjectType(tsType: string): boolean {
return /^{.*}$/.test(tsType);
},
log(...args: any[]): void {
console.log(...args); // tslint:disable-line:no-console
},
getPartialNameFromFileName(filename: string): string {
const name = path.parse(filename).name;
return name;

View File

View File

@@ -6,13 +6,15 @@
"types": "lib/src/index.d.ts",
"scripts": {
"build:watch": "tsc -w",
"build": "tsc",
"clean": "shx rm -rf _bundles lib test_temp",
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"clean": "shx rm -rf _bundles lib test_temp scripts",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"run_mocha": "mocha lib/test/**/*_test.js",
"prepublishOnly": "run-p build",
"test": "run-s clean build run_mocha",
"test:circleci": "yarn test"
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"test:circleci": "yarn test:coverage"
},
"license": "Apache-2.0",
"repository": {
@@ -24,12 +26,15 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md",
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.12",
"@0xproject/tslint-config": "^0.4.10",
"@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42",
"@types/valid-url": "^1.0.2",
"nyc": "^11.0.1",
"chai": "^4.0.1",
"chai-typescript-typings": "^0.0.4",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",
@@ -42,5 +47,8 @@
"@0xproject/utils": "^0.4.1",
"lodash": "^4.17.4",
"valid-url": "^1.0.9"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,5 +0,0 @@
const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -1 +1,8 @@
declare module 'dirty-chai';
declare module '*.json' {
const json: any;
/* tslint:disable */
export default json;
/* tslint:enable */
}

View File

@@ -0,0 +1,8 @@
import { postpublishUtils } from '@0xproject/monorepo-scripts';
import * as packageJSON from '../package.json';
import * as tsConfigJSON from '../tsconfig.json';
const cwd = `${__dirname}/..`;
// tslint:disable-next-line:no-floating-promises
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);

View File

@@ -6,8 +6,8 @@
"types": "lib/index.d.ts",
"scripts": {
"build:watch": "tsc -w",
"build": "tsc",
"clean": "shx rm -rf lib",
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
"clean": "shx rm -rf lib scripts",
"lint": "tslint --project . 'src/**/*.ts'"
},
"license": "Apache-2.0",
@@ -20,8 +20,10 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md",
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.12",
"@0xproject/tslint-config": "^0.4.10",
"@types/lodash": "^4.14.86",
"copyfiles": "^1.2.0",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.8.0",
@@ -35,5 +37,8 @@
"lodash": "^4.17.4",
"web3": "^0.20.0",
"web3-typescript-typings": "^0.10.0"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -0,0 +1,6 @@
declare module '*.json' {
const json: any;
/* tslint:disable */
export default json;
/* tslint:enable */
}

View File

@@ -0,0 +1,8 @@
import { postpublishUtils } from '@0xproject/monorepo-scripts';
import * as packageJSON from '../package.json';
import * as tsConfigJSON from '../tsconfig.json';
const cwd = `${__dirname}/..`;
// tslint:disable-next-line:no-floating-promises
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);

View File

@@ -0,0 +1,6 @@
declare module '*.json' {
const json: any;
/* tslint:disable */
export default json;
/* tslint:enable */
}

View File

@@ -0,0 +1,8 @@
import { postpublishUtils } from '@0xproject/monorepo-scripts';
import * as packageJSON from '../package.json';
import * as tsConfigJSON from '../tsconfig.json';
const cwd = `${__dirname}/..`;
// tslint:disable-next-line:no-floating-promises
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);

View File

@@ -4,6 +4,10 @@
"description": "Typescript type definitions for chai-as-promised",
"main": "index.d.ts",
"types": "index.d.ts",
"scripts": {
"build": "tsc && copyfiles -u 1 './lib/**/*' ./scripts",
"clean": "shx rm -rf scripts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/0xProject/0x-monorepo.git"
@@ -19,5 +23,13 @@
"homepage": "https://github.com/0xProject/0x-monorepo/packages/chai-as-promised-typescript-typings#readme",
"dependencies": {
"chai-typescript-typings": "^0.0.4"
},
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.12",
"copyfiles": "^1.2.0",
"shx": "^0.2.2"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,5 +0,0 @@
const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
},
"include": ["./monorepo_scripts/**/*"]
}

View File

@@ -0,0 +1,6 @@
declare module '*.json' {
const json: any;
/* tslint:disable */
export default json;
/* tslint:enable */
}

View File

@@ -0,0 +1,8 @@
import { postpublishUtils } from '@0xproject/monorepo-scripts';
import * as packageJSON from '../package.json';
import * as tsConfigJSON from '../tsconfig.json';
const cwd = `${__dirname}/..`;
// tslint:disable-next-line:no-floating-promises
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);

View File

@@ -4,6 +4,10 @@
"description": "Typescript type definitions for chai",
"main": "index.d.ts",
"types": "index.d.ts",
"scripts": {
"build": "tsc && copyfiles -u 1 './lib/**/*' ./scripts",
"clean": "shx rm -rf scripts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/0xProject/0x-monorepo.git"
@@ -12,5 +16,13 @@
"bugs": {
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/chai-typescript-typings#readme"
"homepage": "https://github.com/0xProject/0x-monorepo/packages/chai-typescript-typings#readme",
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.12",
"copyfiles": "^1.2.0",
"shx": "^0.2.2"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,5 +0,0 @@
const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
},
"include": ["./monorepo_scripts/**/*"]
}

View File

@@ -1,5 +1,9 @@
# CHANGELOG
## v0.6.3 - _March 18, 2018_
* Consolidate `Order`, `SignedOrder`, and `ECSignature` into the `@0xproject/types` package (#456)
## v0.6.2 - _February 16, 2018_
* Fix JSON parse empty response (#407)

View File

View File

@@ -13,15 +13,26 @@
"types": "lib/src/index.d.ts",
"scripts": {
"build:watch": "tsc -w",
"build": "tsc",
"clean": "shx rm -rf _bundles lib test_temp",
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"clean": "shx rm -rf _bundles lib test_temp scripts",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json",
"copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"run_mocha": "mocha lib/test/**/*_test.js",
"test": "run-s clean build copy_test_fixtures run_mocha",
"test:circleci": "yarn test"
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"test:circleci": "yarn test:coverage"
},
"config": {
"postpublish": {
"assets": ["_bundles/index.js", "_bundles/index.min.js"],
"docPublishConfigs": {
"s3BucketPath": "s3://connect-docs-jsons/",
"s3StagingBucketPath": "s3://staging-connect-docs-jsons/"
}
}
},
"repository": {
"type": "git",
@@ -39,6 +50,7 @@
"dependencies": {
"@0xproject/assert": "^0.2.0",
"@0xproject/json-schemas": "^0.7.14",
"@0xproject/types": "^0.3.1",
"@0xproject/utils": "^0.4.1",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4",
@@ -46,12 +58,15 @@
"websocket": "^1.0.25"
},
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.12",
"@0xproject/tslint-config": "^0.4.10",
"@types/fetch-mock": "^5.12.1",
"@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42",
"@types/query-string": "^5.0.1",
"@types/websocket": "^0.0.34",
"nyc": "^11.0.1",
"async-child-process": "^1.1.1",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.10",
@@ -66,5 +81,8 @@
"typedoc": "~0.8.0",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.10.0"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -1,45 +0,0 @@
const execAsync = require('async-child-process').execAsync;
const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const tsConfig = require('../tsconfig.json');
const cwd = __dirname + '/..';
const subPackageName = packageJSON.name;
const S3BucketPath = 's3://connect-docs-jsons/';
// Include any external packages that are part of the @0xproject/connect public interface
// to this array so that TypeDoc picks it up and adds it to the Docs JSON
const fileIncludes = [...tsConfig.include];
const fileIncludesAdjusted = postpublish_utils.adjustFileIncludePaths(fileIncludes, __dirname);
const projectFiles = fileIncludesAdjusted.join(' ');
let tag;
let version;
postpublish_utils
.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
tag = result.tag;
version = result.version;
const releaseName = postpublish_utils.getReleaseName(subPackageName, version);
return postpublish_utils.publishReleaseNotesAsync(tag, releaseName);
})
.then(function(release) {
console.log('POSTPUBLISH: Release successful, generating docs...');
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
return execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_FILES="' + projectFiles + '" yarn docs:json', {
cwd,
});
})
.then(function(result) {
if (result.stderr !== '') {
throw new Error(result.stderr);
}
const fileName = 'v' + version + '.json';
console.log('POSTPUBLISH: Doc generation successful, uploading docs... as ', fileName);
const s3Url = S3BucketPath + fileName;
return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', {
cwd,
});
})
.catch(function(err) {
throw err;
});

View File

@@ -1,30 +0,0 @@
const execAsync = require('async-child-process').execAsync;
const postpublish_utils = require('../../../scripts/postpublish_utils');
const tsConfig = require('../tsconfig.json');
const cwd = __dirname + '/..';
const S3BucketPath = 's3://staging-connect-docs-jsons/';
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
const version = process.env.DOCS_VERSION;
// Include any external packages that are part of the @0xproject/connect public interface
// to this array so that TypeDoc picks it up and adds it to the Docs JSON
const fileIncludes = [...tsConfig.include];
const fileIncludesAdjusted = postpublish_utils.adjustFileIncludePaths(fileIncludes, __dirname);
const projectFiles = fileIncludesAdjusted.join(' ');
execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_FILES="' + projectFiles + '" yarn docs:json', {
cwd,
})
.then(function(result) {
if (result.stderr !== '') {
throw new Error(result.stderr);
}
const fileName = 'v' + version + '.json';
const s3Url = S3BucketPath + fileName;
return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', {
cwd,
});
})
.catch(function(err) {
console.log(err);
});

View File

@@ -1,3 +1,4 @@
declare module 'async-child-process';
declare module 'dirty-chai';
declare module '*.json' {

View File

@@ -1,5 +1,6 @@
import { assert } from '@0xproject/assert';
import { schemas } from '@0xproject/json-schemas';
import { SignedOrder } from '@0xproject/types';
import 'isomorphic-fetch';
import * as _ from 'lodash';
import * as queryString from 'query-string';
@@ -15,7 +16,6 @@ import {
OrderbookResponse,
OrdersRequestOpts,
PagedRequestOpts,
SignedOrder,
TokenPairsItem,
TokenPairsRequestOpts,
} from './types';

View File

@@ -2,10 +2,8 @@ export { HttpClient } from './http_client';
export { WebSocketOrderbookChannel } from './ws_orderbook_channel';
export {
Client,
ECSignature,
FeesRequest,
FeesResponse,
Order,
OrderbookChannel,
OrderbookChannelHandler,
OrderbookChannelSubscriptionOpts,
@@ -13,9 +11,10 @@ export {
OrderbookResponse,
OrdersRequestOpts,
PagedRequestOpts,
SignedOrder,
TokenPairsItem,
TokenPairsRequestOpts,
TokenTradeInfo,
WebSocketOrderbookChannelConfig,
} from './types';
export { ECSignature, Order, SignedOrder } from '@0xproject/types';

View File

@@ -0,0 +1,8 @@
import { postpublishUtils } from '@0xproject/monorepo-scripts';
import * as packageJSON from '../package.json';
import * as tsConfigJSON from '../tsconfig.json';
const cwd = `${__dirname}/..`;
// tslint:disable-next-line:no-floating-promises
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);

View File

@@ -0,0 +1,8 @@
import { postpublishUtils } from '@0xproject/monorepo-scripts';
import * as packageJSON from '../package.json';
import * as tsConfigJSON from '../tsconfig.json';
const cwd = `${__dirname}/..`;
// tslint:disable-next-line:no-floating-promises
postpublishUtils.publishDocsToStagingAsync(packageJSON, tsConfigJSON, cwd);

View File

@@ -1,34 +1,6 @@
import { ECSignature, Order, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
// TODO: Consolidate Order, SignedOrder and ECSignature into a shared package instead of duplicating them from 0x.js
export interface Order {
maker: string;
taker: string;
makerFee: BigNumber;
takerFee: BigNumber;
makerTokenAmount: BigNumber;
takerTokenAmount: BigNumber;
makerTokenAddress: string;
takerTokenAddress: string;
salt: BigNumber;
exchangeContractAddress: string;
feeRecipient: string;
expirationUnixTimestampSec: BigNumber;
}
export interface SignedOrder extends Order {
ecSignature: ECSignature;
}
/**
* Elliptic Curve signature
*/
export interface ECSignature {
v: number;
r: string;
s: string;
}
export interface Client {
getTokenPairsAsync: (requestOpts?: TokenPairsRequestOpts & PagedRequestOpts) => Promise<TokenPairsItem[]>;
getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<SignedOrder[]>;

View File

@@ -1,8 +1,9 @@
import { assert } from '@0xproject/assert';
import { schemas } from '@0xproject/json-schemas';
import { SignedOrder } from '@0xproject/types';
import * as _ from 'lodash';
import { FeesResponse, OrderbookResponse, SignedOrder, TokenPairsItem } from '../types';
import { FeesResponse, OrderbookResponse, TokenPairsItem } from '../types';
import { typeConverters } from './type_converters';

View File

@@ -32,6 +32,8 @@ public {{this.name}} = {
txData: TxData = {},
): Promise<number> {
const self = this as {{contractName}}Contract;
const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs;
[{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
const encodedData = this._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}}
).data
@@ -49,6 +51,8 @@ public {{this.name}} = {
txData: TxData = {},
): string {
const self = this as {{contractName}}Contract;
const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs;
[{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
const abiEncodedTransactionData = this._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}}
).data

View File

View File

@@ -1,4 +1,4 @@
import { MultiSigConfigByNetwork } from '../../types';
import { MultiSigConfigByNetwork } from '../types';
// Make a copy of this file named `multisig.js` and input custom params as needed
export const multiSig: MultiSigConfigByNetwork = {

View File

@@ -1,5 +1,5 @@
import { Token } from '../../types';
import { constants } from '../../utils/constants';
import { constants } from '../../util/constants';
import { Token } from '../types';
export const tokenInfo: Token[] = [
{

View File

@@ -0,0 +1,20 @@
import { Deployer } from '@0xproject/deployer';
import { devConstants } from '@0xproject/dev-utils';
import * as path from 'path';
import { constants } from '../util/constants';
import { runMigrationsAsync } from './migrate';
const deployerOpts = {
artifactsDir: path.resolve('src', 'artifacts'),
jsonrpcUrl: devConstants.RPC_URL,
networkId: constants.TESTRPC_NETWORK_ID,
defaults: {
gas: devConstants.GAS_ESTIMATE,
},
};
export const deployer = new Deployer(deployerOpts);
runMigrationsAsync(deployer).catch(console.log);

View File

@@ -0,0 +1,90 @@
import { Deployer } from '@0xproject/deployer';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import { constants } from '../util/constants';
import { ContractName } from '../util/types';
import { tokenInfo } from './config/token_info';
/**
* Custom migrations should be defined in this function. This will be called with the CLI 'migrate' command.
* Migrations could be written to run in parallel, but if you want contract addresses to be created deterministically,
* the migration should be written to run synchronously.
* @param deployer Deployer instance.
*/
export const runMigrationsAsync = async (deployer: Deployer) => {
const web3Wrapper: Web3Wrapper = deployer.web3Wrapper;
const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync();
const tokenTransferProxy = await deployer.deployAndSaveAsync(ContractName.TokenTransferProxy);
const zrxToken = await deployer.deployAndSaveAsync(ContractName.ZRXToken);
const etherToken = await deployer.deployAndSaveAsync(ContractName.EtherToken);
const tokenReg = await deployer.deployAndSaveAsync(ContractName.TokenRegistry);
const exchangeArgs = [zrxToken.address, tokenTransferProxy.address];
const owners = [accounts[0], accounts[1]];
const confirmationsRequired = new BigNumber(2);
const secondsRequired = new BigNumber(0);
const multiSigArgs = [owners, confirmationsRequired, secondsRequired, tokenTransferProxy.address];
const exchange = await deployer.deployAndSaveAsync(ContractName.Exchange, exchangeArgs);
const multiSig = await deployer.deployAndSaveAsync(
ContractName.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,
multiSigArgs,
);
const owner = accounts[0];
await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner });
await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, { from: owner });
const addTokenGasEstimate = await tokenReg.addToken.estimateGasAsync(
zrxToken.address,
tokenInfo[0].name,
tokenInfo[0].symbol,
tokenInfo[0].decimals,
tokenInfo[0].ipfsHash,
tokenInfo[0].swarmHash,
{ from: owner },
);
await tokenReg.addToken.sendTransactionAsync(
zrxToken.address,
'0x Protocol Token',
'ZRX',
18,
constants.NULL_BYTES,
constants.NULL_BYTES,
{
from: owner,
gas: addTokenGasEstimate,
},
);
await tokenReg.addToken.sendTransactionAsync(
etherToken.address,
'Ether Token',
'WETH',
18,
constants.NULL_BYTES,
constants.NULL_BYTES,
{
from: owner,
gas: addTokenGasEstimate,
},
);
for (const token of tokenInfo) {
const totalSupply = new BigNumber(0);
const args = [token.name, token.symbol, token.decimals, totalSupply];
const dummyToken = await deployer.deployAsync(ContractName.DummyToken, args);
await tokenReg.addToken.sendTransactionAsync(
dummyToken.address,
token.name,
token.symbol,
token.decimals,
token.ipfsHash,
token.swarmHash,
{
from: owner,
gas: addTokenGasEstimate,
},
);
}
};

View File

@@ -13,14 +13,18 @@
"copy_artifacts": "copyfiles './src/artifacts/**/*' ./lib",
"build": "tsc",
"test": "run-s build run_mocha",
"run_mocha": "mocha 'lib/test/**/*.js' --timeout 10000 --bail --exit",
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
"run_mocha": "mocha 'lib/test/**/*.js' --timeout 100000 --bail --exit",
"compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846",
"compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir src/artifacts",
"clean": "shx rm -rf ./lib",
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|Arbitrage|EtherDelta|AccountLevels).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
"migrate": "node ../deployer/lib/src/cli.js migrate",
"migrate": "yarn build && yarn compile && node ./lib/migrations/index.js",
"lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
"test:circleci": "yarn test"
"coverage:report:text": "istanbul report text",
"coverage:report:html": "istanbul report html && open coverage/index.html",
"coverage:report:lcov": "istanbul report lcov",
"test:circleci": "yarn test:coverage"
},
"config": {
"contracts": "Exchange,DummyToken,ZRXToken,Token,WETH9,TokenTransferProxy,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,MaliciousToken,TokenRegistry,Arbitrage,EtherDelta,AccountLevels"

View File

@@ -363,4 +363,3 @@ contract MultiSigWallet {
_transactionIds[i - from] = transactionIdsTemp[i];
}
}

View File

@@ -9,12 +9,11 @@ import { ContractName } from '../util/types';
import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer';
import { web3, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('EtherToken', () => {
let account: string;

View File

@@ -22,12 +22,11 @@ import { OrderFactory } from '../../util/order_factory';
import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer';
import { web3, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('Exchange', () => {
let maker: string;

View File

@@ -17,13 +17,12 @@ import { OrderFactory } from '../../util/order_factory';
import { ContractName } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer';
import { web3, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('Exchange', () => {
let maker: string;

View File

@@ -22,12 +22,11 @@ import { OrderFactory } from '../../util/order_factory';
import { BalancesByOwner, ContractName } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer';
import { web3, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('Exchange', () => {
let maker: string;

View File

@@ -0,0 +1,8 @@
import { coverage, env, EnvVars } from '@0xproject/dev-utils';
after('generate coverage report', async () => {
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
const coverageSubprovider = coverage.getCoverageSubproviderSingleton();
await coverageSubprovider.writeCoverageAsync();
}
});

View File

@@ -1,5 +1,5 @@
import { LogWithDecodedArgs, ZeroEx } from '0x.js';
import { BlockchainLifecycle, RPC, web3Factory } from '@0xproject/dev-utils';
import { BlockchainLifecycle, web3Factory } from '@0xproject/dev-utils';
import { AbiDecoder, BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
@@ -15,14 +15,12 @@ import { ContractName, SubmissionContractEventArgs } from '../util/types';
import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer';
import { web3, web3Wrapper } from './utils/web3_wrapper';
const MULTI_SIG_ABI = artifacts.MultiSigWalletWithTimeLockArtifact.networks[constants.TESTRPC_NETWORK_ID].abi;
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID });
const abiDecoder = new AbiDecoder([MULTI_SIG_ABI]);
@@ -39,11 +37,6 @@ describe('MultiSigWalletWithTimeLock', () => {
let multiSigWrapper: MultiSigWrapper;
let txId: BigNumber;
let initialSecondsTimeLocked: number;
let rpc: RPC;
before(async () => {
rpc = new RPC();
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
});
@@ -192,7 +185,7 @@ describe('MultiSigWalletWithTimeLock', () => {
});
it('should execute if it has enough confirmations and is past the time lock', async () => {
await rpc.increaseTimeAsync(SECONDS_TIME_LOCKED.toNumber());
await web3Wrapper.increaseTimeAsync(SECONDS_TIME_LOCKED.toNumber());
await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] });
const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync());

View File

@@ -16,6 +16,7 @@ import { ContractName, SubmissionContractEventArgs, TransactionDataParams } from
import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer';
import { web3, web3Wrapper } from './utils/web3_wrapper';
const PROXY_ABI = artifacts.TokenTransferProxyArtifact.networks[constants.TESTRPC_NETWORK_ID].abi;
const MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI =
artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressArtifact.networks[constants.TESTRPC_NETWORK_ID]
@@ -23,9 +24,7 @@ const MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI =
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const abiDecoder = new AbiDecoder([MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI]);
describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {

View File

@@ -14,12 +14,11 @@ import { ContractName } from '../util/types';
import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer';
import { web3, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('TokenRegistry', () => {
let owner: string;

View File

@@ -8,12 +8,11 @@ import { constants } from '../../util/constants';
import { ContractName } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer';
import { web3, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('TokenTransferProxy', () => {
let owner: string;

View File

@@ -11,12 +11,11 @@ import { constants } from '../../util/constants';
import { ContractName } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer';
import { web3, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('TokenTransferProxy', () => {
let accounts: string[];

View File

@@ -17,12 +17,11 @@ import { OrderFactory } from '../../util/order_factory';
import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer';
import { web3, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('Arbitrage', () => {
let coinbase: string;
@@ -55,8 +54,8 @@ describe('Arbitrage', () => {
before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
[coinbase, maker, edMaker, edFrontRunner] = accounts;
weth = await deployer.deployAsync(ContractName.DummyToken);
zrx = await deployer.deployAsync(ContractName.DummyToken);
weth = await deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS);
zrx = await deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS);
const accountLevels = await deployer.deployAsync(ContractName.AccountLevels);
const edAdminAddress = accounts[0];
const edMakerFee = 0;

View File

@@ -11,12 +11,11 @@ import { ContractName } from '../util/types';
import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer';
import { web3, web3Wrapper } from './utils/web3_wrapper';
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('UnlimitedAllowanceToken', () => {
let owner: string;

View File

@@ -4,9 +4,12 @@ import * as path from 'path';
import { constants } from '../../util/constants';
import { web3 } from './web3_wrapper';
const deployerOpts = {
web3Provider: web3.currentProvider,
artifactsDir: path.resolve('src', 'artifacts'),
jsonrpcPort: devConstants.RPC_PORT,
jsonrpcUrl: devConstants.RPC_URL,
networkId: constants.TESTRPC_NETWORK_ID,
defaults: {
gas: devConstants.GAS_ESTIMATE,

View File

@@ -0,0 +1,6 @@
import { web3Factory } from '@0xproject/dev-utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
const web3ProviderConfig = { shouldUseInProcessGanache: true };
export const web3 = web3Factory.create(web3ProviderConfig);
export const web3Wrapper = new Web3Wrapper(web3.currentProvider);

View File

@@ -11,12 +11,11 @@ import { ContractName } from '../util/types';
import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer';
import { web3, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('ZRXToken', () => {
let owner: string;

View File

@@ -1,5 +1,18 @@
# CHANGELOG
## v0.3.0 - _March 18, 2018_
* Add support for Solidity 0.4.20 and 0.4.21
* Replace `jsonrpcPort` config with `jsonrpcUrl` (#426)
* Replace `jsonrpc-port` CLI option with `jsonrpc-url` (#426)
* Export the `Compiler` (#426)
* Load solc from remote source instead of having it locally (#426)
* Add `bytecode`, `runtime_bytecode`, `source_map`, `source_map_runtime` and `sources` fields to artifacts (#426)
* Remove 0x-specific `migrate` command (#426)
* Allow deployer to accept a provider instead of port and host. This makes it possible to run it with in-process ganache-core (#426)
* Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package (#452)
* Add `#!/usr/bin/env node` pragma above `cli.ts` script to fix command-line error.
## v0.2.0 - _March 4, 2018_
* Check dependencies when determining if contracts should be recompiled (#408)

View File

@@ -10,13 +10,14 @@ yarn add @0xproject/deployer
## Usage
### CLI Usage
```bash
node ./node_modules/@0xproject/deployer/lib/cli.js --help
cli.js [command]
Commands:
cli.js compile compile contracts
cli.js migrate compile and deploy contracts using migration scripts
cli.js deploy deploy a single contract with provided arguments
Options:
@@ -34,6 +35,34 @@ Options:
--help Show help [boolean]
```
### API Usage
## Migrations
You might want to write a migration scripts (similar to `truffle migrate`), that deploys multiple contracts and configures them. Below you'll find a simple example of such a script to help you get started.
```typescript
import { Deployer } from '@0xproject/deployer';
import * as path from 'path';
const deployerOpts = {
artifactsDir: path.resolve('src', 'artifacts'),
jsonrpcUrl: 'http://localhost:8545',
networkId: 50,
defaults: {
gas: 1000000,
},
};
const deployer = new Deployer(deployerOpts);
(async () => {
const etherToken = await deployer.deployAndSaveAsync('WETH9');
})().catch(console.log);
```
A more sophisticated example can be found [here](https://github.com/0xProject/0x-monorepo/tree/development/packages/contracts/migrations)
## Contributing
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.

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