diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2019-01-10 03:18:56 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2019-01-15 02:49:44 +0800 |
commit | 82a44559f6a3d795a6a8b0baa9486633bc884475 (patch) | |
tree | cbc45b36b74dc17f1d06e356d823c0c200041ec8 /packages/utils | |
parent | 892be49b98acae61d1892ea89ef3c0b42168d8eb (diff) | |
download | dexon-sol-tools-82a44559f6a3d795a6a8b0baa9486633bc884475.tar dexon-sol-tools-82a44559f6a3d795a6a8b0baa9486633bc884475.tar.gz dexon-sol-tools-82a44559f6a3d795a6a8b0baa9486633bc884475.tar.bz2 dexon-sol-tools-82a44559f6a3d795a6a8b0baa9486633bc884475.tar.lz dexon-sol-tools-82a44559f6a3d795a6a8b0baa9486633bc884475.tar.xz dexon-sol-tools-82a44559f6a3d795a6a8b0baa9486633bc884475.tar.zst dexon-sol-tools-82a44559f6a3d795a6a8b0baa9486633bc884475.zip |
Style cleanup for Compressed Calldata in Contract Wrappers PR
Diffstat (limited to 'packages/utils')
6 files changed, 21 insertions, 20 deletions
diff --git a/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts b/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts index d9e854f51..f23324721 100644 --- a/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts +++ b/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts @@ -51,14 +51,14 @@ export abstract class DataType { return value; } - public decodeAsArray(returndata: string, rules?: DecodingRules): any { + public decodeAsArray(returndata: string, rules?: DecodingRules): any[] { const value = this.decode(returndata, rules); const valuesAsArray = _.isObject(value) ? _.values(value) : [value]; return valuesAsArray; } - public getSignature(detailed?: boolean): string { - if (_.isEmpty(this._dataItem.name) || !detailed) { + public getSignature(isDetailed?: boolean): string { + if (_.isEmpty(this._dataItem.name) || !isDetailed) { return this.getSignatureType(); } const name = this.getDataItem().name; diff --git a/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts b/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts index e4be96235..2c6c4b0f6 100644 --- a/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts +++ b/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts @@ -1,3 +1,4 @@ +import { ObjectMap } from '@0x/types'; import { DataItem } from 'ethereum-types'; import * as ethUtil from 'ethereumjs-util'; import * as _ from 'lodash'; @@ -140,7 +141,7 @@ export abstract class AbstractSetDataType extends DataType { `Could not assign tuple to object: missing key '${memberName}' in object ${JSON.stringify(obj)}`, ); } - const memberValue: any = (obj as { [key: string]: any })[memberName]; + const memberValue: any = (obj as ObjectMap<any>)[memberName]; const memberBlock = this._members[memberIndex].generateCalldataBlock(memberValue, block); memberCalldataBlocks.push(memberBlock); }); @@ -149,11 +150,11 @@ export abstract class AbstractSetDataType extends DataType { return block; } - protected _computeSignatureOfMembers(detailed?: boolean): string { + protected _computeSignatureOfMembers(isDetailed?: boolean): string { // Compute signature of members let signature = `(`; _.each(this._members, (member: DataType, i: number) => { - signature += member.getSignature(detailed); + signature += member.getSignature(isDetailed); if (i < this._members.length - 1) { signature += ','; } diff --git a/packages/utils/src/abi_encoder/evm_data_types/array.ts b/packages/utils/src/abi_encoder/evm_data_types/array.ts index 449de0568..d9607f47e 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/array.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/array.ts @@ -40,19 +40,19 @@ export class ArrayDataType extends AbstractSetDataType { return this._computeSignature(false); } - public getSignature(detailed?: boolean): string { - if (_.isEmpty(this.getDataItem().name) || !detailed) { + public getSignature(isDetailed?: boolean): string { + if (_.isEmpty(this.getDataItem().name) || !isDetailed) { return this.getSignatureType(); } const name = this.getDataItem().name; const lastIndexOfScopeDelimiter = name.lastIndexOf('.'); const isScopedName = !_.isUndefined(lastIndexOfScopeDelimiter) && lastIndexOfScopeDelimiter > 0; const shortName = isScopedName ? name.substr((lastIndexOfScopeDelimiter as number) + 1) : name; - const detailedSignature = `${shortName} ${this._computeSignature(detailed)}`; + const detailedSignature = `${shortName} ${this._computeSignature(isDetailed)}`; return detailedSignature; } - private _computeSignature(detailed?: boolean): string { + private _computeSignature(isDetailed?: boolean): string { // Compute signature for a single array element const elementDataItem: DataItem = { type: this._elementType, @@ -63,7 +63,7 @@ export class ArrayDataType extends AbstractSetDataType { elementDataItem.components = elementComponents; } const elementDataType = this.getFactory().create(elementDataItem); - const elementSignature = elementDataType.getSignature(detailed); + const elementSignature = elementDataType.getSignature(isDetailed); // Construct signature for array of type `element` if (_.isUndefined(this._arrayLength)) { return `${elementSignature}[]`; diff --git a/packages/utils/src/abi_encoder/evm_data_types/method.ts b/packages/utils/src/abi_encoder/evm_data_types/method.ts index 6e3fdcf6d..c0cf80c74 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/method.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/method.ts @@ -44,14 +44,14 @@ export class MethodDataType extends AbstractSetDataType { return returnValues; } - public decodeReturnValuesAsArray(returndata: string, rules?: DecodingRules): any { - const returnValues = this.decodeReturnValues(returndata, rules); + public decodeReturnValuesAsArray(returnData: string, rules?: DecodingRules): any[] { + const returnValues = this.decodeReturnValues(returnData, rules); const returnValuesAsArray = _.isObject(returnValues) ? _.values(returnValues) : [returnValues]; return returnValuesAsArray; } - public decodeReturnValuesAsArrayOrNull(returndata: string, rules?: DecodingRules): any { - const returnValuesAsArray = this.decodeReturnValuesAsArray(returndata, rules); + public decodeReturnValuesAsArrayOrNull(returnData: string, rules?: DecodingRules): any { + const returnValuesAsArray = this.decodeReturnValuesAsArray(returnData, rules); const returnValue = _.isEmpty(returnValuesAsArray) ? [] : returnValuesAsArray; return returnValue; } diff --git a/packages/utils/src/abi_encoder/evm_data_types/pointer.ts b/packages/utils/src/abi_encoder/evm_data_types/pointer.ts index 8c3afe0c3..250db7c64 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/pointer.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/pointer.ts @@ -15,7 +15,7 @@ export class PointerDataType extends AbstractPointerDataType { return this._destination.getSignature(false); } - public getSignature(detailed?: boolean): string { - return this._destination.getSignature(detailed); + public getSignature(isDetailed?: boolean): string { + return this._destination.getSignature(isDetailed); } } diff --git a/packages/utils/src/abi_encoder/evm_data_types/tuple.ts b/packages/utils/src/abi_encoder/evm_data_types/tuple.ts index 2370ecdef..5000c85e8 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/tuple.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/tuple.ts @@ -20,15 +20,15 @@ export class TupleDataType extends AbstractSetDataType { return this._computeSignatureOfMembers(false); } - public getSignature(detailed?: boolean): string { - if (_.isEmpty(this.getDataItem().name) || !detailed) { + public getSignature(isDetailed?: boolean): string { + if (_.isEmpty(this.getDataItem().name) || !isDetailed) { return this.getSignatureType(); } const name = this.getDataItem().name; const lastIndexOfScopeDelimiter = name.lastIndexOf('.'); const isScopedName = !_.isUndefined(lastIndexOfScopeDelimiter) && lastIndexOfScopeDelimiter > 0; const shortName = isScopedName ? name.substr((lastIndexOfScopeDelimiter as number) + 1) : name; - const detailedSignature = `${shortName} ${this._computeSignatureOfMembers(detailed)}`; + const detailedSignature = `${shortName} ${this._computeSignatureOfMembers(isDetailed)}`; return detailedSignature; } } |