aboutsummaryrefslogtreecommitdiffstats
path: root/packages/abi-gen/src/index.ts
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-04-04 08:39:55 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-04-10 08:22:58 +0800
commit61fc3346c2fe2adc33dfe84aa50780d61e10efdf (patch)
tree1f5ab2cddf7093db8f8fb419ef70da66a9997c7b /packages/abi-gen/src/index.ts
parent073bf738ddb271b6b4158798baf4cac3cb0608e9 (diff)
downloaddexon-sol-tools-61fc3346c2fe2adc33dfe84aa50780d61e10efdf.tar
dexon-sol-tools-61fc3346c2fe2adc33dfe84aa50780d61e10efdf.tar.gz
dexon-sol-tools-61fc3346c2fe2adc33dfe84aa50780d61e10efdf.tar.bz2
dexon-sol-tools-61fc3346c2fe2adc33dfe84aa50780d61e10efdf.tar.lz
dexon-sol-tools-61fc3346c2fe2adc33dfe84aa50780d61e10efdf.tar.xz
dexon-sol-tools-61fc3346c2fe2adc33dfe84aa50780d61e10efdf.tar.zst
dexon-sol-tools-61fc3346c2fe2adc33dfe84aa50780d61e10efdf.zip
Updated deployer to accept a list of contract directories as input. Contract directories are namespaced to a void clashes. Also in this commit is a fix for overloading contract functions.
Diffstat (limited to 'packages/abi-gen/src/index.ts')
-rw-r--r--packages/abi-gen/src/index.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts
index 942bb12db..9ceebe02b 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 methodAbisSanitized = 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: methodAbisSanitized[methodAbiIndex].name,
+ functionSignature: abiUtils.getFunctionSignature(methodAbi),
};
return methodData;
});