diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index b91f23ecbc..b09aadd7ee 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -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", diff --git a/packages/0x.js/src/contract_wrappers/generated/ether_token.ts b/packages/0x.js/src/contract_wrappers/generated/ether_token.ts index aae6230c9c..1e42307888 100644 --- a/packages/0x.js/src/contract_wrappers/generated/ether_token.ts +++ b/packages/0x.js/src/contract_wrappers/generated/ether_token.ts @@ -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'; diff --git a/packages/0x.js/src/contract_wrappers/generated/exchange.ts b/packages/0x.js/src/contract_wrappers/generated/exchange.ts index 512cc80d73..e6bc74c65c 100644 --- a/packages/0x.js/src/contract_wrappers/generated/exchange.ts +++ b/packages/0x.js/src/contract_wrappers/generated/exchange.ts @@ -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'; diff --git a/packages/0x.js/src/contract_wrappers/generated/token.ts b/packages/0x.js/src/contract_wrappers/generated/token.ts index f8f578dd9c..7762a29e56 100644 --- a/packages/0x.js/src/contract_wrappers/generated/token.ts +++ b/packages/0x.js/src/contract_wrappers/generated/token.ts @@ -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'; diff --git a/packages/0x.js/src/contract_wrappers/generated/token_registry.ts b/packages/0x.js/src/contract_wrappers/generated/token_registry.ts index 5638a92d66..ce03449d8d 100644 --- a/packages/0x.js/src/contract_wrappers/generated/token_registry.ts +++ b/packages/0x.js/src/contract_wrappers/generated/token_registry.ts @@ -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'; diff --git a/packages/0x.js/src/contract_wrappers/generated/token_transfer_proxy.ts b/packages/0x.js/src/contract_wrappers/generated/token_transfer_proxy.ts index 33e244d8d4..41c9669e3d 100644 --- a/packages/0x.js/src/contract_wrappers/generated/token_transfer_proxy.ts +++ b/packages/0x.js/src/contract_wrappers/generated/token_transfer_proxy.ts @@ -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'; diff --git a/packages/typed-contracts-templates/contract.mustache b/packages/abi-gen-templates/contract.mustache similarity index 86% rename from packages/typed-contracts-templates/contract.mustache rename to packages/abi-gen-templates/contract.mustache index cb3bb3631a..27783fb6ef 100644 --- a/packages/typed-contracts-templates/contract.mustache +++ b/packages/abi-gen-templates/contract.mustache @@ -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'; diff --git a/packages/typed-contracts-templates/package.json b/packages/abi-gen-templates/package.json similarity index 66% rename from packages/typed-contracts-templates/package.json rename to packages/abi-gen-templates/package.json index e690e93a1f..622c35478e 100644 --- a/packages/typed-contracts-templates/package.json +++ b/packages/abi-gen-templates/package.json @@ -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" } diff --git a/packages/typed-contracts-templates/partials/call.mustache b/packages/abi-gen-templates/partials/call.mustache similarity index 100% rename from packages/typed-contracts-templates/partials/call.mustache rename to packages/abi-gen-templates/partials/call.mustache diff --git a/packages/typed-contracts-templates/partials/params.mustache b/packages/abi-gen-templates/partials/params.mustache similarity index 100% rename from packages/typed-contracts-templates/partials/params.mustache rename to packages/abi-gen-templates/partials/params.mustache diff --git a/packages/typed-contracts-templates/partials/return_type.mustache b/packages/abi-gen-templates/partials/return_type.mustache similarity index 100% rename from packages/typed-contracts-templates/partials/return_type.mustache rename to packages/abi-gen-templates/partials/return_type.mustache diff --git a/packages/typed-contracts-templates/partials/tx.mustache b/packages/abi-gen-templates/partials/tx.mustache similarity index 100% rename from packages/typed-contracts-templates/partials/tx.mustache rename to packages/abi-gen-templates/partials/tx.mustache diff --git a/packages/typed-contracts-templates/partials/typed_params.mustache b/packages/abi-gen-templates/partials/typed_params.mustache similarity index 100% rename from packages/typed-contracts-templates/partials/typed_params.mustache rename to packages/abi-gen-templates/partials/typed_params.mustache diff --git a/packages/typed-contracts/README.md b/packages/abi-gen/README.md similarity index 87% rename from packages/typed-contracts/README.md rename to packages/abi-gen/README.md index 5649af0dda..77dcae2ada 100644 --- a/packages/typed-contracts/README.md +++ b/packages/abi-gen/README.md @@ -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. diff --git a/packages/typed-contracts/package.json b/packages/abi-gen/package.json similarity index 82% rename from packages/typed-contracts/package.json rename to packages/abi-gen/package.json index 6d8aa5016f..01bede2492 100644 --- a/packages/typed-contracts/package.json +++ b/packages/abi-gen/package.json @@ -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", diff --git a/packages/typed-contracts/src/globals.d.ts b/packages/abi-gen/src/globals.d.ts similarity index 100% rename from packages/typed-contracts/src/globals.d.ts rename to packages/abi-gen/src/globals.d.ts diff --git a/packages/typed-contracts/src/index.ts b/packages/abi-gen/src/index.ts similarity index 100% rename from packages/typed-contracts/src/index.ts rename to packages/abi-gen/src/index.ts diff --git a/packages/typed-contracts/src/types.ts b/packages/abi-gen/src/types.ts similarity index 100% rename from packages/typed-contracts/src/types.ts rename to packages/abi-gen/src/types.ts diff --git a/packages/typed-contracts/src/utils.ts b/packages/abi-gen/src/utils.ts similarity index 100% rename from packages/typed-contracts/src/utils.ts rename to packages/abi-gen/src/utils.ts diff --git a/packages/typed-contracts/tsconfig.json b/packages/abi-gen/tsconfig.json similarity index 100% rename from packages/typed-contracts/tsconfig.json rename to packages/abi-gen/tsconfig.json diff --git a/packages/typed-contracts/tslint.json b/packages/abi-gen/tslint.json similarity index 100% rename from packages/typed-contracts/tslint.json rename to packages/abi-gen/tslint.json