From e019ae4aed610c4645894c2999871fd3c0b57388 Mon Sep 17 00:00:00 2001 From: Olaf Tomalka Date: Fri, 5 Jan 2018 02:07:25 +0100 Subject: Changes to abi-gen after code review * Added change to CHANGELOG * Renamed variable and context to ctor to avoid keyword * Used lodash' isUndefined to better check ctor --- packages/abi-gen/CHANGELOG.md | 1 + packages/abi-gen/src/index.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'packages/abi-gen') diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md index 346bba4bf..0afd6abd4 100644 --- a/packages/abi-gen/CHANGELOG.md +++ b/packages/abi-gen/CHANGELOG.md @@ -4,3 +4,4 @@ v0.x.x - _TBD, 2018_ ------------------------ * Fixed array typings with union types (#295) * Add event ABIs to context data passed to templates (#302) +* Add constructor ABIs to context data passed to templates (#304) \ No newline at end of file diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts index 65dc1c607..527af32b1 100644 --- a/packages/abi-gen/src/index.ts +++ b/packages/abi-gen/src/index.ts @@ -76,9 +76,9 @@ for (const abiFileName of abiFileNames) { process.exit(1); } - let constructor = ABI.find((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_CONSTRUCTOR) as Web3.ConstructorAbi; - if (!constructor) { - constructor = utils.getEmptyConstructor(); // The constructor exists, but it's implicit in JSON's ABI definition + let ctor = ABI.find((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_CONSTRUCTOR) as Web3.ConstructorAbi; + if (_.isUndefined(ctor)) { + ctor = utils.getEmptyConstructor(); // The constructor exists, but it's implicit in JSON's ABI definition } const methodAbis = ABI.filter((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_METHOD) as Web3.MethodAbi[]; @@ -101,7 +101,7 @@ for (const abiFileName of abiFileNames) { const contextData = { contractName: namedContent.name, - constructor, + ctor, methods: methodsData, events: eventAbis, }; -- cgit v1.2.3