aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils/src
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-12-24 11:49:08 +0800
committerGreg Hysen <greg.hysen@gmail.com>2019-01-15 02:49:44 +0800
commit0b6c9c84688b565a9000b2c4e889c682ccaa7e51 (patch)
treeae299ab0db6f182ed2ceafd729a63b3f713697e2 /packages/utils/src
parentd1fd4421be0a7639b99b374bf04e57fac4e8a486 (diff)
downloaddexon-sol-tools-0b6c9c84688b565a9000b2c4e889c682ccaa7e51.tar
dexon-sol-tools-0b6c9c84688b565a9000b2c4e889c682ccaa7e51.tar.gz
dexon-sol-tools-0b6c9c84688b565a9000b2c4e889c682ccaa7e51.tar.bz2
dexon-sol-tools-0b6c9c84688b565a9000b2c4e889c682ccaa7e51.tar.lz
dexon-sol-tools-0b6c9c84688b565a9000b2c4e889c682ccaa7e51.tar.xz
dexon-sol-tools-0b6c9c84688b565a9000b2c4e889c682ccaa7e51.tar.zst
dexon-sol-tools-0b6c9c84688b565a9000b2c4e889c682ccaa7e51.zip
Ran prettier
Diffstat (limited to 'packages/utils/src')
-rw-r--r--packages/utils/src/abi_encoder/abstract_data_types/types/set.ts4
-rw-r--r--packages/utils/src/abi_encoder/evm_data_type_factory.ts10
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/int.ts2
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/tuple.ts2
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/uint.ts2
-rw-r--r--packages/utils/src/abi_encoder/utils/signatureParser.ts18
6 files changed, 19 insertions, 19 deletions
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 5eb29c47b..28d11c4b5 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
@@ -141,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 { [key: string]: any })[memberName];
const memberBlock = this._members[memberIndex].generateCalldataBlock(memberValue, block);
memberCalldataBlocks.push(memberBlock);
});
@@ -188,7 +188,7 @@ export abstract class AbstractSetDataType extends DataType {
memberNames.push(memberName);
const childDataItem: DataItem = {
type: memberItem.type,
- name: `${dataItem.name}.${memberName}`
+ name: `${dataItem.name}.${memberName}`,
};
const components = memberItem.components;
if (!_.isUndefined(components)) {
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 fdd4f0fde..dcfcc9c5a 100644
--- a/packages/utils/src/abi_encoder/evm_data_type_factory.ts
+++ b/packages/utils/src/abi_encoder/evm_data_type_factory.ts
@@ -135,20 +135,20 @@ export class EvmDataTypeFactory implements DataTypeFactory {
// Convenience function
export function create(input: DataItem | DataItem[] | string): DataType {
// Handle different types of input
- const isSignature = typeof(input) === 'string';
+ const isSignature = typeof input === 'string';
const isTupleSignature = isSignature && (input as string).startsWith('(');
const parseAsTuple = isTupleSignature || _.isArray(input);
// Create input `dataItem`
let dataItem: DataItem;
- if(parseAsTuple) {
- const dataItems = isSignature ? generateDataItemsFromSignature(input as string) : input as DataItem[];
+ if (parseAsTuple) {
+ const dataItems = isSignature ? generateDataItemsFromSignature(input as string) : (input as DataItem[]);
dataItem = {
name: '',
type: 'tuple',
- components: dataItems
+ components: dataItems,
};
} else {
- dataItem = isSignature ? generateDataItemsFromSignature(input as string)[0] : input as DataItem;
+ dataItem = isSignature ? generateDataItemsFromSignature(input as string)[0] : (input as DataItem);
}
// Create data type
const dataType = EvmDataTypeFactory.getInstance().create(dataItem);
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 865a76545..144a0eb6a 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/int.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/int.ts
@@ -47,7 +47,7 @@ export class IntDataType extends AbstractBlobDataType {
return encodedValue;
}
- public decodeValue(calldata: RawCalldata): BigNumber|number {
+ public decodeValue(calldata: RawCalldata): BigNumber | number {
const valueBuf = calldata.popWord();
const value = EncoderMath.safeDecodeNumericValue(valueBuf, this._minValue, this._maxValue);
if (this._width === 8) {
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 587653f49..54964235c 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/tuple.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/tuple.ts
@@ -16,7 +16,7 @@ export class TupleDataType extends AbstractSetDataType {
if (!TupleDataType.matchType(dataItem.type)) {
throw new Error(`Tried to instantiate Tuple with bad input: ${dataItem}`);
}
- //this._signature =
+ //this._signature =
}
public getSignatureType(): string {
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 86d2705f0..940fda072 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/uint.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/uint.ts
@@ -46,7 +46,7 @@ export class UIntDataType extends AbstractBlobDataType {
return encodedValue;
}
- public decodeValue(calldata: RawCalldata): BigNumber|number {
+ public decodeValue(calldata: RawCalldata): BigNumber | number {
const valueBuf = calldata.popWord();
const value = EncoderMath.safeDecodeNumericValue(valueBuf, UIntDataType._MIN_VALUE, this._maxValue);
if (this._width === 8) {
diff --git a/packages/utils/src/abi_encoder/utils/signatureParser.ts b/packages/utils/src/abi_encoder/utils/signatureParser.ts
index 9c1a59c82..c4796e24e 100644
--- a/packages/utils/src/abi_encoder/utils/signatureParser.ts
+++ b/packages/utils/src/abi_encoder/utils/signatureParser.ts
@@ -19,20 +19,20 @@ export function generateDataItemFromSignature(signature: string): DataItem {
export function generateDataItemsFromSignature(signature: string): DataItem[] {
let trimmedSignature = signature;
if (signature.startsWith('(')) {
- if(!signature.endsWith(')')) {
+ if (!signature.endsWith(')')) {
throw new Error(`Failed to generate data item. Must end with ')'`);
}
trimmedSignature = signature.substr(1, signature.length - 2);
}
trimmedSignature += ',';
let currTokenIsArray = false;
- let currTokenArrayModifier = "";
+ let currTokenArrayModifier = '';
let isParsingArrayModifier = false;
let currToken = '';
let parenCount = 0;
let currTokenName = '';
const dataItems: DataItem[] = [];
- for(const char of trimmedSignature) {
+ for (const char of trimmedSignature) {
// Tokenize the type string while keeping track of parentheses.
switch (char) {
case '(':
@@ -47,7 +47,7 @@ export function generateDataItemsFromSignature(signature: string): DataItem[] {
if (parenCount === 0) {
isParsingArrayModifier = true;
currTokenIsArray = true;
- currTokenArrayModifier += "[";
+ currTokenArrayModifier += '[';
} else {
currToken += char;
}
@@ -63,7 +63,7 @@ export function generateDataItemsFromSignature(signature: string): DataItem[] {
case ' ':
if (parenCount === 0) {
currTokenName = currToken;
- currToken = "";
+ currToken = '';
} else {
currToken += char;
}
@@ -74,7 +74,7 @@ export function generateDataItemsFromSignature(signature: string): DataItem[] {
const components = currToken.startsWith('(') ? generateDataItemsFromSignature(currToken) : [];
const isTuple = !_.isEmpty(components);
const isArray = currTokenIsArray;
- let dataItem: DataItem = {name: currTokenName, type: ''};
+ let dataItem: DataItem = { name: currTokenName, type: '' };
if (isTuple) {
dataItem.type = 'tuple';
dataItem.components = components;
@@ -84,13 +84,13 @@ export function generateDataItemsFromSignature(signature: string): DataItem[] {
if (isArray) {
dataItem.type += currTokenArrayModifier;
}
-
+
dataItems.push(dataItem);
currTokenName = '';
currToken = '';
currTokenIsArray = false;
- currTokenArrayModifier = "";
+ currTokenArrayModifier = '';
break;
} else {
currToken += char;
@@ -106,4 +106,4 @@ export function generateDataItemsFromSignature(signature: string): DataItem[] {
}
}
return dataItems;
-} \ No newline at end of file
+}