diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-10-05 07:06:05 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-10-05 07:06:05 +0800 |
commit | e5153737d8386380675f28dd7cda70deeb1ea37c (patch) | |
tree | 81b061d2fa1af5952acc5abb41003f043ff8fce1 /packages/sol-doc/src/cli.ts | |
parent | 88766a02c7e6688e72d5c4c69ce68028b322f154 (diff) | |
parent | b04b649ec044b05f5c37bec214b7f992feb5998e (diff) | |
download | dexon-sol-tools-e5153737d8386380675f28dd7cda70deeb1ea37c.tar dexon-sol-tools-e5153737d8386380675f28dd7cda70deeb1ea37c.tar.gz dexon-sol-tools-e5153737d8386380675f28dd7cda70deeb1ea37c.tar.bz2 dexon-sol-tools-e5153737d8386380675f28dd7cda70deeb1ea37c.tar.lz dexon-sol-tools-e5153737d8386380675f28dd7cda70deeb1ea37c.tar.xz dexon-sol-tools-e5153737d8386380675f28dd7cda70deeb1ea37c.tar.zst dexon-sol-tools-e5153737d8386380675f28dd7cda70deeb1ea37c.zip |
Merge branch 'development'
* development: (939 commits)
Add asset-buyer to published packages section in README
Publish
Updated CHANGELOGS
Update BuyQuote interface
force re-build
Add website build to instructions
Revert format and re-add changes
Build website in parallel with other tests since no other test relies on it being built to run
Add back sourceMap support for both dev/prod
Upgrade webpack
Add missing default options
Remove unused constants
Add fee order with a takerFee
Add additional order factory methods and refactor test to use them
Add comments about buy quote calculation
Update CHANGELOG
Fix linter
Add additional test for slippage
Add buy_quote_calculator_test
Add 0x Instant to bundle analysis
...
Diffstat (limited to 'packages/sol-doc/src/cli.ts')
-rw-r--r-- | packages/sol-doc/src/cli.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/packages/sol-doc/src/cli.ts b/packages/sol-doc/src/cli.ts new file mode 100644 index 000000000..a1847e868 --- /dev/null +++ b/packages/sol-doc/src/cli.ts @@ -0,0 +1,41 @@ +import 'source-map-support/register'; +import * as yargs from 'yargs'; + +import { logUtils } from '@0xproject/utils'; + +import { SolDoc } from './sol_doc'; + +const JSON_TAB_WIDTH = 4; + +(async () => { + const argv = yargs + .option('contracts-dir', { + type: 'string', + description: 'path of contracts directory to compile', + }) + .option('contracts', { + type: 'string', + description: 'comma separated list of contracts to compile', + }) + .demandOption('contracts-dir') + .array('contracts') + .help().argv; + // Unfortunately, the only way to currently retrieve the declared structs within Solidity contracts + // is to tease them out of the params/return values included in the ABI. These structures do + // not include the structs actual name, so we need a mapping to assign the proper name to a + // struct. If the name is not in this mapping, the structs name will default to the param/return value + // name (which mostly coincide). + const customTypeHashToName: { [hash: string]: string } = { + '52d4a768701076c7bac06e386e430883975eb398732eccba797fd09dd064a60e': 'Order', + '46f7e8c4d144d11a72ce5338458ea37b933500d7a65e740cbca6d16e350eaa48': 'FillResults', + c22239cf0d29df1e6cf1be54f21692a8c0b3a48b9367540d4ffff4608b331ce9: 'OrderInfo', + c21e9ff31a30941c22e1cb43752114bb467c34dea58947f98966c9030fc8e4a9: 'TraderInfo', + '6de3264a1040e027d4bdd29c71e963028238ac4ef060541078a7aced44a4d46f': 'MatchedFillResults', + }; + const solDoc = new SolDoc(); + const doc = await solDoc.generateSolDocAsync(argv.contractsDir, argv.contracts, customTypeHashToName); + process.stdout.write(JSON.stringify(doc, null, JSON_TAB_WIDTH)); +})().catch(err => { + logUtils.warn(err); + process.exit(1); +}); |