diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-04 19:54:16 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-04 23:32:03 +0800 |
commit | c700046b7673a0f470c8d8abeec3cf873049a78a (patch) | |
tree | c7bdfc8e6d17d587f47ee23ef4a295ed192ae633 /packages/abi-gen | |
parent | 326a6b729fe6cf96f0b4787d84903282738b6863 (diff) | |
download | dexon-sol-tools-c700046b7673a0f470c8d8abeec3cf873049a78a.tar dexon-sol-tools-c700046b7673a0f470c8d8abeec3cf873049a78a.tar.gz dexon-sol-tools-c700046b7673a0f470c8d8abeec3cf873049a78a.tar.bz2 dexon-sol-tools-c700046b7673a0f470c8d8abeec3cf873049a78a.tar.lz dexon-sol-tools-c700046b7673a0f470c8d8abeec3cf873049a78a.tar.xz dexon-sol-tools-c700046b7673a0f470c8d8abeec3cf873049a78a.tar.zst dexon-sol-tools-c700046b7673a0f470c8d8abeec3cf873049a78a.zip |
Apply prettify on json and md files
Diffstat (limited to 'packages/abi-gen')
-rw-r--r-- | packages/abi-gen/CHANGELOG.md | 4 | ||||
-rw-r--r-- | packages/abi-gen/README.md | 13 | ||||
-rw-r--r-- | packages/abi-gen/package.json | 92 | ||||
-rw-r--r-- | packages/abi-gen/tsconfig.json | 26 | ||||
-rw-r--r-- | packages/abi-gen/tslint.json | 4 |
5 files changed, 72 insertions, 67 deletions
diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md index 346bba4bf..700cfb549 100644 --- a/packages/abi-gen/CHANGELOG.md +++ b/packages/abi-gen/CHANGELOG.md @@ -1,6 +1,6 @@ # CHANGELOG -v0.x.x - _TBD, 2018_ ------------------------- +## v0.x.x - _TBD, 2018_ + * Fixed array typings with union types (#295) * Add event ABIs to context data passed to templates (#302) diff --git a/packages/abi-gen/README.md b/packages/abi-gen/README.md index ab2315232..1188bd437 100644 --- a/packages/abi-gen/README.md +++ b/packages/abi-gen/README.md @@ -8,8 +8,11 @@ For an example of the generated [wrapper files](https://github.com/0xProject/0x. [Here](https://github.com/0xProject/0x.js/tree/development/packages/0x.js/contract_templates) are the templates used to generate those files. ## Installation + `yarn add -g @0xproject/abi-gen` + ## Usage + ``` abi-gen Options: @@ -19,8 +22,10 @@ Options: --templates Folder where to search for templates [string] [required] --output Folder where to put the output files [string] [required] ``` + ## ABI files -You're required to pass a [glob](https://en.wikipedia.org/wiki/Glob_(programming)) template where your abi files are located. + +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` @@ -28,12 +33,18 @@ TL;DR - here is the example from 0x.js. We could've just used `--abiGlob '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. + ## 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/0x.js/contract_templates) and start adjusting them for your needs. We use [handlebars](http://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 a 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, some useful helpers and a contract name because it was enough for our use-case, but if you need something else - create a PR. See the [type definition](https://github.com/0xProject/0x.js/tree/development/packages/abi-gen/src/types.ts) of what we pass to the render method. + ## 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. diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index 91438eff5..e2307bccd 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -1,48 +1,48 @@ { - "name": "@0xproject/abi-gen", - "version": "0.0.4", - "description": "Generate contract wrappers from ABI and handlebars templates", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "scripts": { - "lint": "tslint --project . 'src/**/*.ts'", - "clean": "shx rm -rf lib", - "build": "tsc" - }, - "bin": { - "abi-gen": "lib/index.js" - }, - "repository": { - "type": "git", - "url": "https://github.com/0xProject/0x.js.git" - }, - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/0xProject/0x.js/issues" - }, - "homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md", - "dependencies": { - "@0xproject/utils": "^0.1.2", - "chalk": "^2.3.0", - "glob": "^7.1.2", - "handlebars": "^4.0.11", - "lodash": "^4.17.4", - "mkdirp": "^0.5.1", - "to-snake-case": "^1.0.0", - "web3": "^0.20.0", - "yargs": "^10.0.3" - }, - "devDependencies": { - "@0xproject/tslint-config": "^0.4.0", - "@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", - "npm-run-all": "^4.1.2", - "shx": "^0.2.2", - "tslint": "5.8.0", - "typescript": "~2.6.1", - "web3-typescript-typings": "^0.7.2" - } + "name": "@0xproject/abi-gen", + "version": "0.0.4", + "description": "Generate contract wrappers from ABI and handlebars templates", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "scripts": { + "lint": "tslint --project . 'src/**/*.ts'", + "clean": "shx rm -rf lib", + "build": "tsc" + }, + "bin": { + "abi-gen": "lib/index.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x.js.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x.js/issues" + }, + "homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md", + "dependencies": { + "@0xproject/utils": "^0.1.2", + "chalk": "^2.3.0", + "glob": "^7.1.2", + "handlebars": "^4.0.11", + "lodash": "^4.17.4", + "mkdirp": "^0.5.1", + "to-snake-case": "^1.0.0", + "web3": "^0.20.0", + "yargs": "^10.0.3" + }, + "devDependencies": { + "@0xproject/tslint-config": "^0.4.0", + "@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", + "npm-run-all": "^4.1.2", + "shx": "^0.2.2", + "tslint": "5.8.0", + "typescript": "~2.6.1", + "web3-typescript-typings": "^0.7.2" + } } diff --git a/packages/abi-gen/tsconfig.json b/packages/abi-gen/tsconfig.json index 695f2a47e..c9a7e9189 100644 --- a/packages/abi-gen/tsconfig.json +++ b/packages/abi-gen/tsconfig.json @@ -1,17 +1,13 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "lib": ["es2015", "dom"], - "outDir": "lib", - "sourceMap": true, - "declaration": true, - "noImplicitAny": true, - "strictNullChecks": true - }, - "include": [ - "./src/**/*", - "./test/**/*", - "../../node_modules/web3-typescript-typings/index.d.ts" - ] + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": ["es2015", "dom"], + "outDir": "lib", + "sourceMap": true, + "declaration": true, + "noImplicitAny": true, + "strictNullChecks": true + }, + "include": ["./src/**/*", "./test/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"] } diff --git a/packages/abi-gen/tslint.json b/packages/abi-gen/tslint.json index a07795151..ffaefe83a 100644 --- a/packages/abi-gen/tslint.json +++ b/packages/abi-gen/tslint.json @@ -1,5 +1,3 @@ { - "extends": [ - "@0xproject/tslint-config" - ] + "extends": ["@0xproject/tslint-config"] } |