aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/utils/src/abi_encoder/abstract_data_types/data_type.ts12
-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.ts2
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/bool.ts2
4 files changed, 9 insertions, 9 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 ab7df6ecc..61d3ac3a9 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
@@ -25,9 +25,9 @@ export abstract class DataType {
}
public encode(value: any, rules?: EncodingRules, selector?: string): string {
- const rules_ = rules ? rules : Constants.DEFAULT_ENCODING_RULES;
+ const rules_ = _.isUndefined(rules) ? Constants.DEFAULT_ENCODING_RULES : rules;
const calldata = new Calldata(rules_);
- if (selector) {
+ if (!_.isUndefined(selector)) {
calldata.setSelector(selector);
}
const block = this.generateCalldataBlock(value);
@@ -37,14 +37,14 @@ export abstract class DataType {
}
public decode(calldata: string, rules?: DecodingRules, selector?: string): any {
- if (selector && !calldata.startsWith(selector)) {
+ if (!_.isUndefined(selector) && !calldata.startsWith(selector)) {
throw new Error(
- `Tried to decode calldata, but it was missing the function selector. Expected '${selector}'.`,
+ `Tried to decode calldata, but it was missing the function selector. Expected prefix '${selector}'. Got '${calldata}'.`,
);
}
- const hasSelector = selector ? true : false;
+ const hasSelector = !_.isUndefined(selector);
const rawCalldata = new RawCalldata(calldata, hasSelector);
- const rules_ = rules ? rules : Constants.DEFAULT_DECODING_RULES;
+ const rules_ = _.isUndefined(rules) ? Constants.DEFAULT_DECODING_RULES : rules;
const value = this.generateValue(rawCalldata, rules_);
return value;
}
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 35ccc0586..965738056 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
@@ -19,7 +19,7 @@ export abstract class Blob extends DataType {
const encodedValue = this.encodeValue(value);
const name = this.getDataItem().name;
const signature = this.getSignature();
- const parentName = parentBlock ? parentBlock.getName() : '';
+ const parentName = _.isUndefined(parentBlock) ? '' : parentBlock.getName();
const block = new CalldataBlocks.Blob(name, signature, parentName, encodedValue);
return block;
}
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 5a188d6fa..637abfb7d 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
@@ -204,7 +204,7 @@ export abstract class Set extends DataType {
const range = _.range(length);
_.each(range, (idx: number) => {
const memberDataItem: DataItem = {
- type: this._arrayElementType ? this._arrayElementType : '',
+ type: _.isUndefined(this._arrayElementType) ? '' : this._arrayElementType,
name: `${dataItem.name}[${idx.toString(Constants.DEC_BASE)}]`,
};
const components = dataItem.components;
diff --git a/packages/utils/src/abi_encoder/evm_data_types/bool.ts b/packages/utils/src/abi_encoder/evm_data_types/bool.ts
index 031acc88a..fa115bb87 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/bool.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/bool.ts
@@ -39,7 +39,7 @@ export class Bool extends AbstractDataTypes.Blob {
throw new Error(`Failed to decode boolean. Expected 0x0 or 0x1, got ${valueHex}`);
}
/* tslint:disable boolean-naming */
- const value: boolean = valueNumber.equals(0) ? false : true;
+ const value: boolean = !valueNumber.equals(0);
/* tslint:enable boolean-naming */
return value;
}