aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/utils')
-rw-r--r--packages/utils/src/abi_encoder/abstract_data_types/data_type.ts6
-rw-r--r--packages/utils/src/abi_encoder/abstract_data_types/types/set.ts7
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/array.ts10
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/method.ts8
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/pointer.ts4
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/tuple.ts6
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;
}
}