aboutsummaryrefslogtreecommitdiffstats
path: root/packages/deployer/src/utils/encoder.ts
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2018-01-19 20:43:32 +0800
committerGitHub <noreply@github.com>2018-01-19 20:43:32 +0800
commite1af25c8a6fa96c665d63fff2033d7611b023db2 (patch)
tree5769ca73d50c497e46e6c6c927700ae0fa00bec9 /packages/deployer/src/utils/encoder.ts
parent9ccf63b44afe1ae6ccc2b9298ee35697d6be9e30 (diff)
parent6091f818da7cddcb4a22a573f7726ba9b76b398e (diff)
downloaddexon-0x-contracts-e1af25c8a6fa96c665d63fff2033d7611b023db2.tar.gz
dexon-0x-contracts-e1af25c8a6fa96c665d63fff2033d7611b023db2.tar.zst
dexon-0x-contracts-e1af25c8a6fa96c665d63fff2033d7611b023db2.zip
Merge pull request #323 from 0xProject/feature/separate-deployer
Move deployer to a separate package
Diffstat (limited to 'packages/deployer/src/utils/encoder.ts')
-rw-r--r--packages/deployer/src/utils/encoder.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/deployer/src/utils/encoder.ts b/packages/deployer/src/utils/encoder.ts
new file mode 100644
index 000000000..d5f807774
--- /dev/null
+++ b/packages/deployer/src/utils/encoder.ts
@@ -0,0 +1,20 @@
+import * as _ from 'lodash';
+import * as Web3 from 'web3';
+import * as web3Abi from 'web3-eth-abi';
+
+import { AbiType } from './types';
+
+export const encoder = {
+ encodeConstructorArgsFromAbi(args: any[], abi: Web3.ContractAbi): string {
+ const constructorTypes: string[] = [];
+ _.each(abi, (element: Web3.AbiDefinition) => {
+ if (element.type === AbiType.Constructor) {
+ _.each(element.inputs, (input: Web3.FunctionParameter) => {
+ constructorTypes.push(input.type);
+ });
+ }
+ });
+ const encodedParameters = web3Abi.encodeParameters(constructorTypes, args);
+ return encodedParameters;
+ },
+};