Update README.md (#2077)

* Update README.md

* top-level README.md: explain Python dependency

* top-level README.md: suggest node v6 OR v8
This commit is contained in:
F. Eugene Aumson
2019-08-19 13:55:06 -04:00
committed by GitHub
parent 0ae2d8bab5
commit 28561e765a
2 changed files with 37 additions and 11 deletions

View File

@@ -109,7 +109,7 @@ These packages are all under development. See [/contracts/README.md](/contracts/
## Usage
Node version >= 6.12 is required.
Node version 6.x or 8.x is required.
Most of the packages require additional typings for external dependencies.
You can include those by prepending the `@0x/typescript-typings` package to your [`typeRoots`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) config.
@@ -138,6 +138,8 @@ Then install dependencies
yarn install
```
You will also need to have Python 3 installed, in order to build and run the tests of `abi-gen`'s command-line interface, which is integrated with the yarn build, yarn test, and yarn lint commands described below. More specifically, your local pip should resolve to the Python 3 version of pip, not a Python 2.x version.
### Build
To build all packages:

View File

@@ -1,10 +1,10 @@
# ABI Gen
This package allows you to generate TypeScript contract wrappers from ABI files.
This package allows you to generate TypeScript or Python contract wrappers from ABI files.
It's heavily inspired by [Geth abigen](https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) but takes a different approach.
You can write your custom handlebars templates which will allow you to seamlessly integrate the generated code into your existing codebase with existing conventions.
[Here](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/abi-gen-templates) are the templates used to generate the contract wrappers used by 0x.js.e
[Here](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/abi-gen-templates) are the templates used to generate the contract wrappers used by 0x.js.
## Installation
@@ -13,7 +13,7 @@ You can write your custom handlebars templates which will allow you to seamlessl
## Usage
```
abi-gen
$ abi-gen --help
Options:
--help Show help [boolean]
--version Show version number [boolean]
@@ -23,12 +23,24 @@ Options:
--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.
--backend The backing Ethereum library your app uses. For
TypeScript, either 'web3' or 'ethers'. Ethers
auto-converts small ints to numbers whereas Web3 doesn't.
For Python, the only possibility is Web3.py
[string] [choices: "web3", "ethers"] [default: "web3"]
--network-id ID of the network where contract ABIs are nested in
artifacts [number] [default: 50]
--language Language of output file to generate
[string] [choices: "TypeScript", "Python"] [default: "TypeScript"]
Examples:
abi-gen --abis 'src/artifacts/**/*.json' Full usage example
--out 'src/contracts/generated/'
--partials
'src/templates/partials/**/*.handlebars'
--template
'src/templates/contract.handlebars'
```
You're required to pass a [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) template where your abi files are located.
@@ -55,7 +67,9 @@ See the [type definition](https://github.com/0xProject/0x-monorepo/tree/developm
## Output files
Output files will be generated within an output folder with names converted to camel case and taken from abi file names. If you already have some files in that folder they will be overwritten.
Output files will be generated within the specified output folder. If you already have some files in that folder they will be overwritten.
Names of files, classes and methods will be converted to the standard naming conventions for the given target language.
## Contributing
@@ -77,6 +91,8 @@ Then install dependencies
yarn install
```
You will also need to have Python 3 installed in order to build and run the tests of the command-line interface, which is integrated with the `yarn build`, `yarn test`, and `yarn lint` commands described below. More specifically, your local `pip` should resolve to the Python 3 version of `pip`, not a Python 2.x version.
### Build
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
@@ -105,15 +121,17 @@ yarn lint
### CLI tests
The files in `test-cli/` are used to test the CLI output against a set of dummy contracts.
The files in `test-cli/` are used to test the output generated by running the command-line tool against a set of fixture contracts. These tests are integrated with `yarn build`, `yarn test`, etc, but can be run independently per the instructions below.
Compile dummy contracts and generate wrappers:
Compile fixture contracts:
```
yarn compile:sol
```
Build generated wrappers and unit tests:
Compiling the fixture contracts into ABI is done ahead of time, and the ABI is checked in to `git`, in order to speed up test run time. Therefore, this compilation does not happen automatically as part of `yarn build`, and must be run explicitly after making any changes to the fixture contracts; and, any proposed changes to the fixture contracts should be accompanied by changes to the corresponding compilation artifacts.
Generate wrappers (and build them, in the case of TypeScript), and build unit tests:
```
yarn test_cli:build
@@ -126,3 +144,9 @@ yarn test_cli
```
Known-good wrappers have been previously committed and are kept in `test-cli/expected-output/{language}`. They are intended to provide sample output and should be kept in sync with the generating code. When making changes to this project or `@0x/abi-gen-templates`, run `yarn test_cli:prebuild` to generate fresh code into `test-cli/output/{language}`, and then manually copy it to `test-cli/expected-output/{language}`.
Run linters against generated code:
```
yarn test_cli:lint
```