From a6f72de09d7b2c9738b78d2097baa9906838fbe9 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 8 May 2018 15:42:07 +0200 Subject: Rename deployer to sol-compiler --- packages/sol-compiler/src/utils/encoder.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 packages/sol-compiler/src/utils/encoder.ts (limited to 'packages/sol-compiler/src/utils/encoder.ts') diff --git a/packages/sol-compiler/src/utils/encoder.ts b/packages/sol-compiler/src/utils/encoder.ts new file mode 100644 index 000000000..806efbbca --- /dev/null +++ b/packages/sol-compiler/src/utils/encoder.ts @@ -0,0 +1,18 @@ +import { AbiDefinition, AbiType, ContractAbi, DataItem } from '@0xproject/types'; +import * as _ from 'lodash'; +import * as web3Abi from 'web3-eth-abi'; + +export const encoder = { + encodeConstructorArgsFromAbi(args: any[], abi: ContractAbi): string { + const constructorTypes: string[] = []; + _.each(abi, (element: AbiDefinition) => { + if (element.type === AbiType.Constructor) { + _.each(element.inputs, (input: DataItem) => { + constructorTypes.push(input.type); + }); + } + }); + const encodedParameters = web3Abi.encodeParameters(constructorTypes, args); + return encodedParameters; + }, +}; -- cgit v1.2.3