aboutsummaryrefslogtreecommitdiffstats
path: root/packages/abi-gen/src
diff options
context:
space:
mode:
authorOlaf Tomalka <olaf@tomalka.me>2017-12-30 23:13:32 +0800
committerOlaf Tomalka <olaf@tomalka.me>2017-12-30 23:13:32 +0800
commit161a9d6ad20d7b127ef41a55dc12892e809127e5 (patch)
treed3f05247cd26c205bdaf51bcd03a2aa2c724606a /packages/abi-gen/src
parentf684cc371104b594358fb8cd274e453c81f48881 (diff)
downloaddexon-sol-tools-161a9d6ad20d7b127ef41a55dc12892e809127e5.tar
dexon-sol-tools-161a9d6ad20d7b127ef41a55dc12892e809127e5.tar.gz
dexon-sol-tools-161a9d6ad20d7b127ef41a55dc12892e809127e5.tar.bz2
dexon-sol-tools-161a9d6ad20d7b127ef41a55dc12892e809127e5.tar.lz
dexon-sol-tools-161a9d6ad20d7b127ef41a55dc12892e809127e5.tar.xz
dexon-sol-tools-161a9d6ad20d7b127ef41a55dc12892e809127e5.tar.zst
dexon-sol-tools-161a9d6ad20d7b127ef41a55dc12892e809127e5.zip
Added Event generation to abi-gen
Diffstat (limited to 'packages/abi-gen/src')
-rw-r--r--packages/abi-gen/src/index.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts
index 19d289e49..6bd8bfe94 100644
--- a/packages/abi-gen/src/index.ts
+++ b/packages/abi-gen/src/index.ts
@@ -15,6 +15,7 @@ import {ContextData, ParamKind} from './types';
import {utils} from './utils';
const ABI_TYPE_METHOD = 'function';
+const ABI_TYPE_EVENT = 'event';
const MAIN_TEMPLATE_NAME = 'contract.mustache';
const args = yargs
@@ -74,6 +75,7 @@ for (const abiFileName of abiFileNames) {
utils.log(`Please make sure your ABI file is either an array with ABI entries or an object with the abi key`);
process.exit(1);
}
+
const methodAbis = ABI.filter((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_METHOD) as Web3.MethodAbi[];
const methodsData = _.map(methodAbis, methodAbi => {
_.map(methodAbi.inputs, input => {
@@ -89,9 +91,13 @@ for (const abiFileName of abiFileNames) {
};
return methodData;
});
+
+ const eventAbis = ABI.filter((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_EVENT) as Web3.MethodAbi[];
+
const contextData = {
contractName: namedContent.name,
methods: methodsData,
+ events: eventAbis,
};
const renderedTsCode = template(contextData);
writeOutputFile(namedContent.name, renderedTsCode);