aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-compiler/src/utils/encoder.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-05-11 18:12:39 +0800
committerGitHub <noreply@github.com>2018-05-11 18:12:39 +0800
commitf42f608f3f97a5244f09f17ae5ee184c0f775de3 (patch)
tree08fd03d69f8a7dfcc7beadcd56c5d1624928c430 /packages/sol-compiler/src/utils/encoder.ts
parent44f17c1706e7b3208fdc0702c54a8cd943132fd3 (diff)
parentc093aab350dfbd86972d6388c3923ec60fc4501a (diff)
downloaddexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.tar
dexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.tar.gz
dexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.tar.bz2
dexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.tar.lz
dexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.tar.xz
dexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.tar.zst
dexon-sol-tools-f42f608f3f97a5244f09f17ae5ee184c0f775de3.zip
Merge pull request #574 from 0xProject/feature/rm-rf-deployer
Remove @0xproject/deployer.Deployer. Make contracts able to deploy themselves
Diffstat (limited to 'packages/sol-compiler/src/utils/encoder.ts')
-rw-r--r--packages/sol-compiler/src/utils/encoder.ts18
1 files changed, 18 insertions, 0 deletions
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;
+ },
+};