aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-04-10 19:44:15 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-04-12 18:50:38 +0800
commitf2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1 (patch)
tree98ff3c9137cdce1a44b65dc7dc89a7a72f70b9de /packages/utils/src
parented0c64fdcf5c180107f54ad916c11c4901a4c01c (diff)
downloaddexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.tar
dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.tar.gz
dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.tar.bz2
dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.tar.lz
dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.tar.xz
dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.tar.zst
dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.zip
Revert "Merge pull request #493 from hysz/features/deployer/multipleCodebaseSupport"
This reverts commit 70d403e6f8c56bc70e6d3471a770b9bbff5d72e7, reversing changes made to 073bf738ddb271b6b4158798baf4cac3cb0608e9.
Diffstat (limited to 'packages/utils/src')
-rw-r--r--packages/utils/src/abi_utils.ts71
-rw-r--r--packages/utils/src/index.ts2
2 files changed, 0 insertions, 73 deletions
diff --git a/packages/utils/src/abi_utils.ts b/packages/utils/src/abi_utils.ts
deleted file mode 100644
index c4533d42e..000000000
--- a/packages/utils/src/abi_utils.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-import { AbiDefinition, AbiType, ConstructorAbi, ContractAbi, DataItem, MethodAbi } from '@0xproject/types';
-import * as _ from 'lodash';
-
-export const abiUtils = {
- parseFunctionParam(param: DataItem): string {
- if (param.type === 'tuple') {
- // Parse out tuple types into {type_1, type_2, ..., type_N}
- const tupleComponents = param.components;
- const paramString = _.map(tupleComponents, component => this.parseFunctionParam(component));
- const tupleParamString = `{${paramString}}`;
- return tupleParamString;
- }
- return param.type;
- },
- getFunctionSignature(methodAbi: MethodAbi): string {
- const functionName = methodAbi.name;
- const parameterTypeList = _.map(methodAbi.inputs, (param: DataItem) => this.parseFunctionParam(param));
- const functionSignature = `${functionName}(${parameterTypeList})`;
- return functionSignature;
- },
- /**
- * Solidity supports function overloading whereas TypeScript does not.
- * See: https://solidity.readthedocs.io/en/v0.4.21/contracts.html?highlight=overload#function-overloading
- * In order to support overloaded functions, we suffix overloaded function names with an index.
- * This index should be deterministic, regardless of function ordering within the smart contract. To do so,
- * we assign indexes based on the alphabetical order of function signatures.
- *
- * E.g
- * ['f(uint)', 'f(uint,byte32)']
- * Should always be renamed to:
- * ['f1(uint)', 'f2(uint,byte32)']
- * Regardless of the order in which these these overloaded functions are declared within the contract ABI.
- */
- renameOverloadedMethods(inputContractAbi: ContractAbi): ContractAbi {
- const contractAbi = _.cloneDeep(inputContractAbi);
- const methodAbis = contractAbi.filter((abi: AbiDefinition) => abi.type === AbiType.Function) as MethodAbi[];
- // Sort method Abis into alphabetical order, by function signature
- const methodAbisOrdered = _.sortBy(methodAbis, [
- (methodAbi: MethodAbi) => {
- const functionSignature = this.getFunctionSignature(methodAbi);
- return functionSignature;
- },
- ]);
- // Group method Abis by name (overloaded methods will be grouped together, in alphabetical order)
- const methodAbisByName: { [key: string]: MethodAbi[] } = {};
- _.each(methodAbisOrdered, methodAbi => {
- (methodAbisByName[methodAbi.name] || (methodAbisByName[methodAbi.name] = [])).push(methodAbi);
- });
- // Rename overloaded methods to overloadedMethodName1, overloadedMethodName2, ...
- _.each(methodAbisByName, methodAbisWithSameName => {
- _.each(methodAbisWithSameName, (methodAbi, i: number) => {
- if (methodAbisWithSameName.length > 1) {
- const overloadedMethodId = i + 1;
- const sanitizedMethodName = `${methodAbi.name}${overloadedMethodId}`;
- const indexOfExistingAbiWithSanitizedMethodNameIfExists = _.findIndex(
- methodAbis,
- currentMethodAbi => currentMethodAbi.name === sanitizedMethodName,
- );
- if (indexOfExistingAbiWithSanitizedMethodNameIfExists >= 0) {
- const methodName = methodAbi.name;
- throw new Error(
- `Failed to rename overloaded method '${methodName}' to '${sanitizedMethodName}'. A method with this name already exists.`,
- );
- }
- methodAbi.name = sanitizedMethodName;
- }
- });
- });
- return contractAbi;
- },
-};
diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts
index 75c096ee6..6a9c052f8 100644
--- a/packages/utils/src/index.ts
+++ b/packages/utils/src/index.ts
@@ -5,6 +5,4 @@ export { intervalUtils } from './interval_utils';
export { BigNumber } from './configured_bignumber';
export { AbiDecoder } from './abi_decoder';
export { logUtils } from './log_utils';
-export { abiUtils } from './abi_utils';
-
export { NULL_BYTES } from './constants';