diff options
Diffstat (limited to 'packages/abi-gen')
-rw-r--r-- | packages/abi-gen/CHANGELOG.json | 9 | ||||
-rw-r--r-- | packages/abi-gen/CHANGELOG.md | 4 | ||||
-rw-r--r-- | packages/abi-gen/package.json | 12 | ||||
-rw-r--r-- | packages/abi-gen/src/index.ts | 14 | ||||
-rw-r--r-- | packages/abi-gen/src/types.ts | 9 | ||||
-rw-r--r-- | packages/abi-gen/src/utils.ts | 4 |
6 files changed, 31 insertions, 21 deletions
diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json index e720cc04b..84f3e318c 100644 --- a/packages/abi-gen/CHANGELOG.json +++ b/packages/abi-gen/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "timestamp": 1523462196, + "version": "0.2.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1522673609, "version": "0.2.9", "changes": [ diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md index 4b8158ebf..5b3b68af3 100644 --- a/packages/abi-gen/CHANGELOG.md +++ b/packages/abi-gen/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v0.2.10 - _April 11, 2018_ + + * Dependencies updated + ## v0.2.9 - _April 2, 2018_ * Dependencies updated diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index f6252e5ef..6aabb054a 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/abi-gen", - "version": "0.2.9", + "version": "0.2.10", "description": "Generate contract wrappers from ABI and handlebars templates", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -24,9 +24,9 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md", "dependencies": { - "@0xproject/types": "^0.5.0", - "@0xproject/typescript-typings": "^0.0.3", - "@0xproject/utils": "^0.5.0", + "@0xproject/types": "^0.6.0", + "@0xproject/typescript-typings": "^0.1.0", + "@0xproject/utils": "^0.5.1", "chalk": "^2.3.0", "glob": "^7.1.2", "handlebars": "^4.0.11", @@ -36,8 +36,8 @@ "yargs": "^10.0.3" }, "devDependencies": { - "@0xproject/monorepo-scripts": "^0.1.16", - "@0xproject/tslint-config": "^0.4.14", + "@0xproject/monorepo-scripts": "^0.1.17", + "@0xproject/tslint-config": "^0.4.15", "@types/glob": "^5.0.33", "@types/handlebars": "^4.0.36", "@types/mkdirp": "^0.5.1", diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts index 942bb12db..ecef33b16 100644 --- a/packages/abi-gen/src/index.ts +++ b/packages/abi-gen/src/index.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from '@0xproject/types'; -import { logUtils } from '@0xproject/utils'; +import { abiUtils, logUtils } from '@0xproject/utils'; import chalk from 'chalk'; import * as fs from 'fs'; import { sync as globSync } from 'glob'; @@ -12,7 +12,7 @@ import * as yargs from 'yargs'; import toSnakeCase = require('to-snake-case'); -import { ContextData, ContractsBackend, ParamKind } from './types'; +import { ContextData, ContractsBackend, Method, ParamKind } from './types'; import { utils } from './utils'; const ABI_TYPE_CONSTRUCTOR = 'constructor'; @@ -83,7 +83,6 @@ function writeOutputFile(name: string, renderedTsCode: string): void { Handlebars.registerHelper('parameterType', utils.solTypeToTsType.bind(utils, ParamKind.Input, args.backend)); Handlebars.registerHelper('returnType', utils.solTypeToTsType.bind(utils, ParamKind.Output, args.backend)); - if (args.partials) { registerPartials(args.partials); } @@ -126,11 +125,12 @@ for (const abiFileName of abiFileNames) { } const methodAbis = ABI.filter((abi: AbiDefinition) => abi.type === ABI_TYPE_METHOD) as MethodAbi[]; - const methodsData = _.map(methodAbis, methodAbi => { - _.map(methodAbi.inputs, (input, i: number) => { + const sanitizedMethodAbis = abiUtils.renameOverloadedMethods(methodAbis) as MethodAbi[]; + const methodsData = _.map(methodAbis, (methodAbi, methodAbiIndex: number) => { + _.forEach(methodAbi.inputs, (input, inputIndex: number) => { if (_.isEmpty(input.name)) { // Auto-generated getters don't have parameter names - input.name = `index_${i}`; + input.name = `index_${inputIndex}`; } }); // This will make templates simpler @@ -138,6 +138,8 @@ for (const abiFileName of abiFileNames) { ...methodAbi, singleReturnValue: methodAbi.outputs.length === 1, hasReturnValue: methodAbi.outputs.length !== 0, + tsName: sanitizedMethodAbis[methodAbiIndex].name, + functionSignature: abiUtils.getFunctionSignature(methodAbi), }; return methodData; }); diff --git a/packages/abi-gen/src/types.ts b/packages/abi-gen/src/types.ts index df5b1feaf..648281774 100644 --- a/packages/abi-gen/src/types.ts +++ b/packages/abi-gen/src/types.ts @@ -5,13 +5,6 @@ export enum ParamKind { Output = 'output', } -export enum AbiType { - Function = 'function', - Constructor = 'constructor', - Event = 'event', - Fallback = 'fallback', -} - export enum ContractsBackend { Web3 = 'web3', Ethers = 'ethers', @@ -20,6 +13,8 @@ export enum ContractsBackend { export interface Method extends MethodAbi { singleReturnValue: boolean; hasReturnValue: boolean; + tsName: string; + functionSignature: string; } export interface ContextData { diff --git a/packages/abi-gen/src/utils.ts b/packages/abi-gen/src/utils.ts index 755fbc71a..20b734959 100644 --- a/packages/abi-gen/src/utils.ts +++ b/packages/abi-gen/src/utils.ts @@ -1,9 +1,9 @@ -import { ConstructorAbi, DataItem } from '@0xproject/types'; +import { AbiType, ConstructorAbi, DataItem } from '@0xproject/types'; import * as fs from 'fs'; import * as _ from 'lodash'; import * as path from 'path'; -import { AbiType, ContractsBackend, ParamKind } from './types'; +import { ContractsBackend, ParamKind } from './types'; export const utils = { solTypeToTsType(paramKind: ParamKind, backend: ContractsBackend, solType: string, components?: DataItem[]): string { |