From f1b267cc9fe7f6e5566dc2535b064b92aef92df1 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 6 Dec 2017 20:55:09 +0300 Subject: Refactor web3Wrapper to a separate package --- packages/abi-gen/package.json | 4 ++-- packages/abi-gen/tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'packages/abi-gen') diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index defe4a621..0d61891e0 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -1,6 +1,6 @@ { "name": "abi-gen", - "version": "0.0.0", + "version": "0.0.1", "description": "Generate contract wrappers from ABI and handlebars templates", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -33,9 +33,9 @@ "yargs": "^10.0.3" }, "devDependencies": { - "@types/handlebars": "^4.0.36", "@0xproject/tslint-config": "^0.2.0", "@types/glob": "^5.0.33", + "@types/handlebars": "^4.0.36", "@types/mkdirp": "^0.5.1", "@types/node": "^8.0.53", "@types/yargs": "^8.0.2", diff --git a/packages/abi-gen/tsconfig.json b/packages/abi-gen/tsconfig.json index 2a3667890..695f2a47e 100644 --- a/packages/abi-gen/tsconfig.json +++ b/packages/abi-gen/tsconfig.json @@ -12,6 +12,6 @@ "include": [ "./src/**/*", "./test/**/*", - "../../node_modules/web3-typescript-typings/index.d.ts", + "../../node_modules/web3-typescript-typings/index.d.ts" ] } -- cgit v1.2.3 From 72ced622d7fddac4d17b7814f45aeea01db23959 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 8 Dec 2017 13:25:00 +0300 Subject: Stop supporting different file extensions in abi-gen --- packages/abi-gen/README.md | 7 +++---- packages/abi-gen/src/index.ts | 7 +------ 2 files changed, 4 insertions(+), 10 deletions(-) (limited to 'packages/abi-gen') diff --git a/packages/abi-gen/README.md b/packages/abi-gen/README.md index f1f8bd08f..b3e996269 100644 --- a/packages/abi-gen/README.md +++ b/packages/abi-gen/README.md @@ -1,6 +1,6 @@ # ABI Gen -This package allows you to generate contract wrappers in any language from ABI files. +This package allows you to generate TypeScript 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. @@ -18,10 +18,9 @@ Options: --abiGlob Glob pattern to search for ABI JSON files [string] [required] --templates Folder where to search for templates [string] [required] --output Folder where to put the output files [string] [required] - --fileExtension The extension of the output file [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` @@ -34,7 +33,7 @@ The best way to get started is to copy [0x.js templates](https://github.com/0xPr 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 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 and a contract name because it was enough for our use-case, but if you need something else - create a PR. +For now you don't get much on top of methods abi, some usefull helpers and a contract name because it 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/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 file names. If you already have some files in that folder they will be overwritten. diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts index 12b78f96f..19d289e49 100644 --- a/packages/abi-gen/src/index.ts +++ b/packages/abi-gen/src/index.ts @@ -33,16 +33,11 @@ const args = yargs type: 'string', demand: true, }) - .option('fileExtension', { - describe: 'The extension of the output file', - type: 'string', - demand: true, - }) .argv; function writeOutputFile(name: string, renderedTsCode: string): void { const fileName = toSnakeCase(name); - const filePath = `${args.output}/${fileName}.${args.fileExtension}`; + const filePath = `${args.output}/${fileName}.ts`; fs.writeFileSync(filePath, renderedTsCode); utils.log(`Created: ${chalk.bold(filePath)}`); } -- cgit v1.2.3 From 5eea829be9f5e8669c40dac965231051b668ed37 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 8 Dec 2017 11:05:53 -0600 Subject: Update README.md --- packages/abi-gen/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'packages/abi-gen') diff --git a/packages/abi-gen/README.md b/packages/abi-gen/README.md index b3e996269..16dd9b969 100644 --- a/packages/abi-gen/README.md +++ b/packages/abi-gen/README.md @@ -8,7 +8,7 @@ For an example of the generated [wrapper files](https://github.com/0xProject/0x. [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 abi-gen` +`yarn add -g @0xproject/abi-gen` ## Usage ``` abi-gen @@ -33,7 +33,7 @@ The best way to get started is to copy [0x.js templates](https://github.com/0xPr 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 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 usefull helpers and a contract name because it 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/abi-gen/src/types.ts) of what we pass to a render method. +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. -- cgit v1.2.3