Rename abi-gen to typed-contracts

This commit is contained in:
Leonid Logvinov
2017-12-05 19:53:59 +03:00
parent 63b1199bd5
commit 1ce66b4a81
21 changed files with 26 additions and 26 deletions

View File

@@ -16,7 +16,7 @@
"build": "run-p build:umd:prod build:commonjs; exit 0;",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_DIR",
"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": "typed-contracts --abiGlob 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry).json' --templates ../typed-contracts-templates/ --output src/contract_wrappers/generated",
"generate_contract_wrappers": "abi-gen --abiGlob 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry).json' --templates ../abi-gen-templates/ --output src/contract_wrappers/generated",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"test:circleci": "run-s test:coverage report_test_coverage && if [ $CIRCLE_BRANCH = \"development\" ]; then yarn test:umd; fi",
"test": "run-s clean test:commonjs",
@@ -46,8 +46,8 @@
},
"devDependencies": {
"@0xproject/tslint-config": "^0.2.0",
"@0xproject/typed-contracts": "^0.0.0",
"@0xproject/typed-contracts-templates": "^0.0.0",
"abi-gen": "^0.0.0",
"abi-gen-templates": "^0.0.0",
"@types/bintrees": "^1.0.2",
"@types/jsonschema": "^1.1.1",
"@types/lodash": "^4.14.64",

View File

@@ -1,6 +1,6 @@
/**
* This file is auto-generated using @0xproject/typed-contracts. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/typed-contracts-templates.
* This file is auto-generated using @0xproject/abi-gen. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
*/
import {BigNumber} from 'bignumber.js';
import * as Web3 from 'web3';

View File

@@ -1,6 +1,6 @@
/**
* This file is auto-generated using @0xproject/typed-contracts. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/typed-contracts-templates.
* This file is auto-generated using @0xproject/abi-gen. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
*/
import {BigNumber} from 'bignumber.js';
import * as Web3 from 'web3';

View File

@@ -1,6 +1,6 @@
/**
* This file is auto-generated using @0xproject/typed-contracts. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/typed-contracts-templates.
* This file is auto-generated using @0xproject/abi-gen. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
*/
import {BigNumber} from 'bignumber.js';
import * as Web3 from 'web3';

View File

@@ -1,6 +1,6 @@
/**
* This file is auto-generated using @0xproject/typed-contracts. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/typed-contracts-templates.
* This file is auto-generated using @0xproject/abi-gen. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
*/
import {BigNumber} from 'bignumber.js';
import * as Web3 from 'web3';

View File

@@ -1,6 +1,6 @@
/**
* This file is auto-generated using @0xproject/typed-contracts. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/typed-contracts-templates.
* This file is auto-generated using @0xproject/abi-gen. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
*/
import {BigNumber} from 'bignumber.js';
import * as Web3 from 'web3';

View File

@@ -1,6 +1,6 @@
/**
* This file is auto-generated using @0xproject/typed-contracts. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/typed-contracts-templates.
* This file is auto-generated using abi-gen. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
*/
import {BigNumber} from 'bignumber.js';
import * as Web3 from 'web3';

View File

@@ -1,5 +1,5 @@
{
"name": "@0xproject/typed-contracts-templates",
"name": "@0xproject/abi-gen-templates",
"version": "0.0.0",
"description": "Handlebars templates to generate TS contract wrappers",
"repository": {
@@ -10,5 +10,5 @@
"bugs": {
"url": "https://github.com/0xProject/0x.js/issues"
},
"homepage": "https://github.com/0xProject/0x.js/packages/typed-contracts-templates/README.md"
"homepage": "https://github.com/0xProject/0x.js/packages/abi-gen-templates/README.md"
}

View File

@@ -4,13 +4,13 @@ This package allows you to generate TS contract wrappers from ABI files.
You can write your custom handlebars templates which will allow you to seamlessly integrate the generated code into your existing codebase with existing conventions.
For the example of the generated [wrapper files](https://github.com/0xProject/0x.js/tree/development/packages/0x.js/src/contract_wrappers/generated) check out 0x.js.
[Here](https://github.com/0xProject/0x.js/tree/development/packages/typed-contracts-templates) are the templates used to generate those files.
[Here](https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates) are the templates used to generate those files.
## Instalation
`yarn add -g @0xproject/typed-contracts`
`yarn add -g @0xproject/abi-gen`
## Usage
```
typed-contracts
abi-gen
Options:
--help Show help [boolean]
--version Show version number [boolean]
@@ -28,11 +28,11 @@ We could've just used `--abiGlob 'src/artifacts/*.json` but we wanted to exclude
The abi file should be either a truffle contract artifact (a JSON object with the abi key) or a JSON abi array.
## How to write custom templates?
The best way to get started is to copy [0x.js templates](https://github.com/0xProject/0x.js/tree/development/packages/typed-contracts-templates) and start playing with them adjusting them for your needs.
The best way to get started is to copy [0x.js templates](https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates) and start playing with them adjusting them for your needs.
We use [handlebars](handlebarsjs.com) template engine under the hood.
You need to have a master template called `contract.mustache`. it will be used to generate each contract wrapper. Although - you don't need and probably shouldn't write all your logic in a single template file. You can write [partial templates](http://handlebarsjs.com/partials.html) and as long as they are within partials folder - they will be registered and available.
## Which data/context do I get in my templates?
For now you don't get much on top of methods abi and a contract name cause if was enough for our use-case, but if you need something else - create a PR.
[Type definition](https://github.com/0xProject/0x.js/tree/development/packages/typed-contracts/src/types.ts) of what we pass to a render method.
[Type definition](https://github.com/0xProject/0x.js/tree/development/packages/abi-gen/src/types.ts) of what we pass to a render method.
## Output files
Output files will be generated within an output folder with names converted to camel case and taken from abi files names. If you already have some files in that folder they will be overwritten.

View File

@@ -1,7 +1,7 @@
{
"name": "@0xproject/typed-contracts",
"name": "abi-gen",
"version": "0.0.0",
"description": "Generate TS contract wrappers from ABI",
"description": "Generate contract wrappers from ABI and handlebars templates",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
@@ -10,7 +10,7 @@
"build": "tsc"
},
"bin": {
"typed-contracts": "lib/index.js"
"abi-gen": "lib/index.js"
},
"repository": {
"type": "git",
@@ -20,7 +20,7 @@
"bugs": {
"url": "https://github.com/0xProject/0x.js/issues"
},
"homepage": "https://github.com/0xProject/0x.js/packages/typed-contracts/README.md",
"homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md",
"dependencies": {
"@types/handlebars": "^4.0.36",
"bignumber.js": "^5.0.0",