aboutsummaryrefslogtreecommitdiffstats
path: root/packages/abi-gen/src/index.ts
diff options
context:
space:
mode:
authorOlaf Tomalka <olaf@tomalka.me>2018-01-03 22:48:29 +0800
committerOlaf Tomalka <olaf@tomalka.me>2018-01-03 22:48:29 +0800
commitf3b8bac47787a13ea4360b992bbe550bec2c3e19 (patch)
treef465267845939591e51291d265a83ed1f97bac3a /packages/abi-gen/src/index.ts
parentce6abad97f248a3557390dd1e1ff3ae84662838f (diff)
downloaddexon-sol-tools-f3b8bac47787a13ea4360b992bbe550bec2c3e19.tar
dexon-sol-tools-f3b8bac47787a13ea4360b992bbe550bec2c3e19.tar.gz
dexon-sol-tools-f3b8bac47787a13ea4360b992bbe550bec2c3e19.tar.bz2
dexon-sol-tools-f3b8bac47787a13ea4360b992bbe550bec2c3e19.tar.lz
dexon-sol-tools-f3b8bac47787a13ea4360b992bbe550bec2c3e19.tar.xz
dexon-sol-tools-f3b8bac47787a13ea4360b992bbe550bec2c3e19.tar.zst
dexon-sol-tools-f3b8bac47787a13ea4360b992bbe550bec2c3e19.zip
Added constructor ABIs to abi-gen
Additionally if the constructor is not existent in JSON, meaning it's implcite with no parameters, we're explicitly creating one, with actual JSON parameters that it should have.
Diffstat (limited to 'packages/abi-gen/src/index.ts')
-rw-r--r--packages/abi-gen/src/index.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts
index ed71087b2..65dc1c607 100644
--- a/packages/abi-gen/src/index.ts
+++ b/packages/abi-gen/src/index.ts
@@ -14,6 +14,7 @@ import * as Web3 from 'web3';
import { ContextData, ParamKind } from './types';
import { utils } from './utils';
+const ABI_TYPE_CONSTRUCTOR = 'constructor';
const ABI_TYPE_METHOD = 'function';
const ABI_TYPE_EVENT = 'event';
const MAIN_TEMPLATE_NAME = 'contract.mustache';
@@ -75,6 +76,11 @@ 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
+ }
+
const methodAbis = ABI.filter((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_METHOD) as Web3.MethodAbi[];
const methodsData = _.map(methodAbis, methodAbi => {
_.map(methodAbi.inputs, input => {
@@ -95,6 +101,7 @@ for (const abiFileName of abiFileNames) {
const contextData = {
contractName: namedContent.name,
+ constructor,
methods: methodsData,
events: eventAbis,
};