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.ts8
-rw-r--r--packages/utils/src/abi_encoder/abstract_data_types/types/blob.ts2
-rw-r--r--packages/utils/src/abi_encoder/abstract_data_types/types/set.ts1
-rw-r--r--packages/utils/src/abi_encoder/evm_data_type_factory.ts14
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/array.ts10
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/int.ts3
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/method.ts1
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/tuple.ts10
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/uint.ts3
-rw-r--r--packages/utils/src/abi_encoder/utils/signatureParser.ts42
-rw-r--r--packages/utils/test/abi_encoder/evm_data_types_test.ts264
-rw-r--r--packages/utils/test/abi_encoder/methods_test.ts6
-rw-r--r--packages/utils/test/abi_encoder/optimizer_test.ts2
13 files changed, 190 insertions, 176 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 dc897d810..d9e854f51 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
@@ -58,9 +58,13 @@ export abstract class DataType {
}
public getSignature(detailed?: boolean): string {
- if (_.isEmpty(this._dataItem.name) || !detailed) return this.getSignatureType();
+ if (_.isEmpty(this._dataItem.name) || !detailed) {
+ return this.getSignatureType();
+ }
const name = this.getDataItem().name;
- const shortName = name.indexOf('.') > 0 ? name.substr(name.lastIndexOf('.') + 1) : 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.getSignatureType()}`;
return detailedSignature;
}
diff --git a/packages/utils/src/abi_encoder/abstract_data_types/types/blob.ts b/packages/utils/src/abi_encoder/abstract_data_types/types/blob.ts
index 4252b782c..a091e55b9 100644
--- a/packages/utils/src/abi_encoder/abstract_data_types/types/blob.ts
+++ b/packages/utils/src/abi_encoder/abstract_data_types/types/blob.ts
@@ -9,8 +9,6 @@ import { DecodingRules } from '../../utils/rules';
import { DataType } from '../data_type';
import { DataTypeFactory } from '../interfaces';
-import * as ethUtil from 'ethereumjs-util';
-
export abstract class AbstractBlobDataType extends DataType {
protected _sizeKnownAtCompileTime: boolean;
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 28d11c4b5..e4be96235 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
@@ -13,7 +13,6 @@ import { DataType } from '../data_type';
import { DataTypeFactory, MemberIndexByName } from '../interfaces';
import { AbstractPointerDataType } from './pointer';
-import { logUtils } from '../../../log_utils';
export abstract class AbstractSetDataType extends DataType {
protected readonly _arrayLength: number | undefined;
diff --git a/packages/utils/src/abi_encoder/evm_data_type_factory.ts b/packages/utils/src/abi_encoder/evm_data_type_factory.ts
index dcfcc9c5a..6d59ec01a 100644
--- a/packages/utils/src/abi_encoder/evm_data_type_factory.ts
+++ b/packages/utils/src/abi_encoder/evm_data_type_factory.ts
@@ -132,15 +132,23 @@ export class EvmDataTypeFactory implements DataTypeFactory {
private constructor() {}
}
-// Convenience function
+/**
+ * Convenience function for creating a DataType from different inputs.
+ * @param input A single or set of DataItem or a DataType signature.
+ * A signature in the form of '<type>' is interpreted as a `DataItem`
+ * For example, 'string' is interpreted as {type: 'string'}
+ * A signature in the form '(<type1>, <type2>, ..., <typen>)' is interpreted as `DataItem[]`
+ * For eaxmple, '(string, uint256)' is interpreted as [{type: 'string'}, {type: 'uint256'}]
+ * @return DataType corresponding to input.
+ */
export function create(input: DataItem | DataItem[] | string): DataType {
// Handle different types of input
const isSignature = typeof input === 'string';
const isTupleSignature = isSignature && (input as string).startsWith('(');
- const parseAsTuple = isTupleSignature || _.isArray(input);
+ const shouldParseAsTuple = isTupleSignature || _.isArray(input);
// Create input `dataItem`
let dataItem: DataItem;
- if (parseAsTuple) {
+ if (shouldParseAsTuple) {
const dataItems = isSignature ? generateDataItemsFromSignature(input as string) : (input as DataItem[]);
dataItem = {
name: '',
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 8b71dc913..449de0568 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/array.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/array.ts
@@ -7,7 +7,6 @@ import { constants } from '../utils/constants';
export class ArrayDataType extends AbstractSetDataType {
private static readonly _MATCHER = RegExp('^(.+)\\[([0-9]*)\\]$');
- private readonly _arraySignature: string;
private readonly _elementType: string;
public static matchType(type: string): boolean {
@@ -35,7 +34,6 @@ export class ArrayDataType extends AbstractSetDataType {
super(dataItem, dataTypeFactory, isArray, arrayLength, arrayElementType);
// Set array properties
this._elementType = arrayElementType;
- this._arraySignature = this._computeSignature();
}
public getSignatureType(): string {
@@ -43,9 +41,13 @@ export class ArrayDataType extends AbstractSetDataType {
}
public getSignature(detailed?: boolean): string {
- if (_.isEmpty(this.getDataItem().name) || !detailed) return this.getSignatureType();
+ if (_.isEmpty(this.getDataItem().name) || !detailed) {
+ return this.getSignatureType();
+ }
const name = this.getDataItem().name;
- const shortName = name.indexOf('.') > 0 ? name.substr(name.lastIndexOf('.') + 1) : 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)}`;
return detailedSignature;
}
diff --git a/packages/utils/src/abi_encoder/evm_data_types/int.ts b/packages/utils/src/abi_encoder/evm_data_types/int.ts
index 144a0eb6a..8d98e195b 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/int.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/int.ts
@@ -50,7 +50,8 @@ export class IntDataType extends AbstractBlobDataType {
public decodeValue(calldata: RawCalldata): BigNumber | number {
const valueBuf = calldata.popWord();
const value = EncoderMath.safeDecodeNumericValue(valueBuf, this._minValue, this._maxValue);
- if (this._width === 8) {
+ const numberOfBytesInUint8 = 8;
+ if (this._width === numberOfBytesInUint8) {
return value.toNumber();
}
return value;
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 44456cd0a..6e3fdcf6d 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/method.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/method.ts
@@ -8,7 +8,6 @@ import { AbstractSetDataType } from '../abstract_data_types/types/set';
import { constants } from '../utils/constants';
import { DecodingRules, EncodingRules } from '../utils/rules';
-import { ArrayDataType } from './array';
import { TupleDataType } from './tuple';
export class MethodDataType extends AbstractSetDataType {
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 54964235c..3d1cb5a92 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/tuple.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/tuple.ts
@@ -5,7 +5,6 @@ import { DataTypeFactory } from '../abstract_data_types/interfaces';
import { AbstractSetDataType } from '../abstract_data_types/types/set';
export class TupleDataType extends AbstractSetDataType {
- //private readonly _signature: string;
public static matchType(type: string): boolean {
return type === SolidityTypes.Tuple;
@@ -16,7 +15,6 @@ export class TupleDataType extends AbstractSetDataType {
if (!TupleDataType.matchType(dataItem.type)) {
throw new Error(`Tried to instantiate Tuple with bad input: ${dataItem}`);
}
- //this._signature =
}
public getSignatureType(): string {
@@ -24,9 +22,13 @@ export class TupleDataType extends AbstractSetDataType {
}
public getSignature(detailed?: boolean): string {
- if (_.isEmpty(this.getDataItem().name) || !detailed) return this.getSignatureType();
+ if (_.isEmpty(this.getDataItem().name) || !detailed) {
+ return this.getSignatureType();
+ }
const name = this.getDataItem().name;
- const shortName = name.indexOf('.') > 0 ? name.substr(name.lastIndexOf('.') + 1) : 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)}`;
return detailedSignature;
}
diff --git a/packages/utils/src/abi_encoder/evm_data_types/uint.ts b/packages/utils/src/abi_encoder/evm_data_types/uint.ts
index 940fda072..8e382e8dc 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/uint.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/uint.ts
@@ -49,7 +49,8 @@ export class UIntDataType extends AbstractBlobDataType {
public decodeValue(calldata: RawCalldata): BigNumber | number {
const valueBuf = calldata.popWord();
const value = EncoderMath.safeDecodeNumericValue(valueBuf, UIntDataType._MIN_VALUE, this._maxValue);
- if (this._width === 8) {
+ const numberOfBytesInUint8 = 8;
+ if (this._width === numberOfBytesInUint8) {
return value.toNumber();
}
return value;
diff --git a/packages/utils/src/abi_encoder/utils/signatureParser.ts b/packages/utils/src/abi_encoder/utils/signatureParser.ts
index c4796e24e..315784cea 100644
--- a/packages/utils/src/abi_encoder/utils/signatureParser.ts
+++ b/packages/utils/src/abi_encoder/utils/signatureParser.ts
@@ -1,21 +1,15 @@
+import { DataItem } from 'ethereum-types';
import * as _ from 'lodash';
-import { DataItem } from 'ethereum-protocol';
-
-/*
-export function generateDataItemFromSignature(signature: string): DataItem {
- const dataItems = generateDataItemsFromSignature(signature);
- if (dataItems.length === 1) {
- return dataItems[0];
- }
- // signature represents a tuple
- return {
- name: '',
- type: 'tuple',
- components: dataItems
- };
-}*/
-
+/**
+ * Returns an array of DataItem's corresponding to the input signature.
+ * A signature can be in two forms: '<DataItem.type>' or '(<DataItem1.type>, <DataItem2.type>, ...)
+ * An example of the first form would be 'address' or 'uint256'
+ * An example of the second form would be '(address, uint256)'
+ * Signatures can also include a name field, for example: 'foo address' or '(foo address, bar uint256)'
+ * @param signature of input DataItems
+ * @return DataItems derived from input signature
+ */
export function generateDataItemsFromSignature(signature: string): DataItem[] {
let trimmedSignature = signature;
if (signature.startsWith('(')) {
@@ -25,7 +19,7 @@ export function generateDataItemsFromSignature(signature: string): DataItem[] {
trimmedSignature = signature.substr(1, signature.length - 2);
}
trimmedSignature += ',';
- let currTokenIsArray = false;
+ let isCurrTokenArray = false;
let currTokenArrayModifier = '';
let isParsingArrayModifier = false;
let currToken = '';
@@ -46,7 +40,7 @@ export function generateDataItemsFromSignature(signature: string): DataItem[] {
case '[':
if (parenCount === 0) {
isParsingArrayModifier = true;
- currTokenIsArray = true;
+ isCurrTokenArray = true;
currTokenArrayModifier += '[';
} else {
currToken += char;
@@ -70,26 +64,24 @@ export function generateDataItemsFromSignature(signature: string): DataItem[] {
break;
case ',':
if (parenCount === 0) {
- //throw new Error(`Generating Data Items`);
+ // Generate new DataItem from token
const components = currToken.startsWith('(') ? generateDataItemsFromSignature(currToken) : [];
const isTuple = !_.isEmpty(components);
- const isArray = currTokenIsArray;
- let dataItem: DataItem = { name: currTokenName, type: '' };
+ const dataItem: DataItem = { name: currTokenName, type: '' };
if (isTuple) {
dataItem.type = 'tuple';
dataItem.components = components;
} else {
dataItem.type = currToken;
}
- if (isArray) {
+ if (isCurrTokenArray) {
dataItem.type += currTokenArrayModifier;
}
-
dataItems.push(dataItem);
-
+ // reset token state
currTokenName = '';
currToken = '';
- currTokenIsArray = false;
+ isCurrTokenArray = false;
currTokenArrayModifier = '';
break;
} else {
diff --git a/packages/utils/test/abi_encoder/evm_data_types_test.ts b/packages/utils/test/abi_encoder/evm_data_types_test.ts
index 3c7bafc0a..54d536a7e 100644
--- a/packages/utils/test/abi_encoder/evm_data_types_test.ts
+++ b/packages/utils/test/abi_encoder/evm_data_types_test.ts
@@ -27,9 +27,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Dynamic size; Static elements', async () => {
// Create DataType object
@@ -46,9 +46,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Fixed size; Dynamic elements', async () => {
// Create DataType object
@@ -65,9 +65,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Dynamic size; Dynamic elements', async () => {
// Create DataType object
@@ -84,9 +84,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Dynamic Size; Multidimensional; Dynamic Elements', async () => {
// Create DataType object
@@ -106,9 +106,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Dynamic Size; Multidimensional; Static Elements', async () => {
// Create DataType object
@@ -128,9 +128,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Static Size; Multidimensional; Static Elements', async () => {
// Create DataType object
@@ -149,9 +149,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Static Size; Multidimensional; Dynamic Elements', async () => {
// Create DataType object
@@ -170,9 +170,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Static size; Too Few Elements', async () => {
// Create DataType object
@@ -230,9 +230,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs, decodingRules);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args, encodingRules);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args, encodingRules);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Dynamic elements only', async () => {
// Create DataType object
@@ -254,9 +254,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs, decodingRules);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Nested Static Array', async () => {
// Create DataType object
@@ -278,9 +278,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs, decodingRules);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Nested Dynamic Array', async () => {
// Create DataType object
@@ -302,9 +302,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs, decodingRules);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Nested Static Multidimensional Array', async () => {
// Create DataType object
@@ -328,9 +328,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs, decodingRules);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Nested Dynamic Multidimensional Array', async () => {
// Create DataType object
@@ -354,9 +354,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs, decodingRules);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Static and dynamic elements mixed', async () => {
// Create DataType object
@@ -388,9 +388,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs, decodingRules);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Missing Key', async () => {
// Create DataType object
@@ -424,9 +424,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Invalid Address - input is not valid hex', async () => {
// Create DataType object
@@ -467,9 +467,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('False', async () => {
// Create DataType object
@@ -485,9 +485,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
});
@@ -513,9 +513,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Int256 - Negative Base Case', async () => {
// Create DataType object
@@ -531,9 +531,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Int256 - Positive Value', async () => {
// Create DataType object
@@ -549,9 +549,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Int256 - Negative Value', async () => {
// Create DataType object
@@ -567,9 +567,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Int256 - Value too large', async () => {
// Create DataType object
@@ -607,9 +607,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Int32 - Negative Base Case', async () => {
// Create DataType object
@@ -625,9 +625,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Int32 - Positive Value', async () => {
// Create DataType object
@@ -643,9 +643,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Int32 - Negative Value', async () => {
// Create DataType object
@@ -661,9 +661,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Int32 - Value too large', async () => {
// Create DataType object
@@ -711,9 +711,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('UInt256 - Positive Value', async () => {
// Create DataType object
@@ -729,9 +729,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('UInt256 - Zero Value', async () => {
// Create DataType object
@@ -747,9 +747,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('UInt256 - Value too large', async () => {
// Create DataType object
@@ -787,9 +787,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('UInt32 - Positive Value', async () => {
// Create DataType object
@@ -805,9 +805,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('UInt32 - Zero Value', async () => {
// Create DataType object
@@ -823,9 +823,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('UInt32 - Value too large', async () => {
// Create DataType object
@@ -866,9 +866,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Single Byte (bytes1)', async () => {
// Create DataType object
@@ -884,9 +884,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('4 Bytes (bytes4)', async () => {
// Create DataType object
@@ -902,9 +902,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('4 Bytes (bytes4); Encoder must pad input', async () => {
// Create DataType object
@@ -922,9 +922,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const paddedArgs = '0x1a180000';
expect(decodedArgs).to.be.deep.equal(paddedArgs);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('32 Bytes (bytes32)', async () => {
// Create DataType object
@@ -940,9 +940,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('32 Bytes (bytes32); Encoder must pad input', async () => {
// Create DataType object
@@ -960,9 +960,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const paddedArgs = '0x1a18bf6100000000000000000000000000000000000000000000000000000000';
expect(decodedArgs).to.be.deep.equal(paddedArgs);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Should throw when pass in too many bytes (bytes4)', async () => {
// Create DataType object
@@ -1031,9 +1031,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Spans multiple EVM words', async () => {
// Create DataType object
@@ -1052,9 +1052,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Input as Buffer', async () => {
// Create DataType object
@@ -1073,9 +1073,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Should throw when pass in bad hex (no 0x prefix)', async () => {
// Create DataType object
@@ -1118,9 +1118,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('Spans multiple EVM words', async () => {
// Create DataType object
@@ -1139,9 +1139,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
it('String that begins with 0x prefix', async () => {
// Create DataType object
@@ -1160,9 +1160,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
const decodedArgs = dataType.decode(encodedArgs);
expect(decodedArgs).to.be.deep.equal(args);
// Validate signature
- const dataTypecreate = AbiEncoder.create(dataType.getSignature(true));
- const encodedArgscreate = dataTypecreate.encode(args);
- expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs);
+ const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true));
+ const argsEncodedFromSignature = dataTypeFromSignature.encode(args);
+ expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs);
});
});
});
diff --git a/packages/utils/test/abi_encoder/methods_test.ts b/packages/utils/test/abi_encoder/methods_test.ts
index 472212e3c..920cb1799 100644
--- a/packages/utils/test/abi_encoder/methods_test.ts
+++ b/packages/utils/test/abi_encoder/methods_test.ts
@@ -199,7 +199,9 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
it('Unfixed Length Array / Static Members ABI', async () => {
// Generate calldata
const method = new AbiEncoder.Method(AbiSamples.dynamicArrayStaticMembersAbi);
+ // tslint:disable custom-no-magic-numbers
const args = [[127, 14, 54]];
+ // tslint:enable custom-no-magic-numbers
const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
@@ -213,7 +215,9 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
it('Fixed Length Array / Static Members ABI', async () => {
// Generate calldata
const method = new AbiEncoder.Method(AbiSamples.staticArrayAbi);
+ // tslint:disable custom-no-magic-numbers
const args = [[127, 14, 54]];
+ // tslint:enable custom-no-magic-numbers
const calldata = method.encode(args, encodingRules);
// Validate calldata
const expectedCalldata =
@@ -310,7 +314,9 @@ describe('ABI Encoder: Method Encoding / Decoding', () => {
it('Large, Nested ABI', async () => {
// Construct Calldata
const method = new AbiEncoder.Method(AbiSamples.largeNestedAbi);
+ // tslint:disable custom-no-magic-numbers
const someStaticArray = [127, 14, 54];
+ // tslint:enable custom-no-magic-numbers
const someStaticArrayWithDynamicMembers = [
'the little piping piper piped a piping pipper papper',
'the kid knows how to write poems, what can I say -- I guess theres a lot I could say to try to fill this line with a lot of text.',
diff --git a/packages/utils/test/abi_encoder/optimizer_test.ts b/packages/utils/test/abi_encoder/optimizer_test.ts
index a7c920678..c0640583d 100644
--- a/packages/utils/test/abi_encoder/optimizer_test.ts
+++ b/packages/utils/test/abi_encoder/optimizer_test.ts
@@ -232,7 +232,9 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => {
it('Array Elements Duplicated as Tuple Fields', async () => {
// Generate calldata
const method = new AbiEncoder.Method(OptimizedAbis.arrayElementsDuplicatedAsTupleFields);
+ // tslint:disable custom-no-magic-numbers
const array = [100, 150, 200, 225];
+ // tslint:enable custom-no-magic-numbers
const tuple = [
[new BigNumber(array[0])],
[new BigNumber(array[1])],