blob: 4f62662e11244305d94cbef76b9f4265997abed8 (
plain) (
tree)
|
|
import { AbiDefinition, ContractAbi, DataItem } from '@0xproject/types';
import * as _ from 'lodash';
import * as web3Abi from 'web3-eth-abi';
import { AbiType } from './types';
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;
},
};
|