diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-11-28 05:28:17 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-11-29 08:38:11 +0800 |
commit | 3f545da9f86856b54cd226c29174ac1ae085e35b (patch) | |
tree | a75ecb84ec499f2e96fb4bb2d5613e5cb38bc3ba /packages/utils/src/abi_encoder/abstract_data_types | |
parent | f31d4ddffd8dd97f2b2dc226f4f132d1c3192c76 (diff) | |
download | dexon-0x-contracts-3f545da9f86856b54cd226c29174ac1ae085e35b.tar dexon-0x-contracts-3f545da9f86856b54cd226c29174ac1ae085e35b.tar.gz dexon-0x-contracts-3f545da9f86856b54cd226c29174ac1ae085e35b.tar.bz2 dexon-0x-contracts-3f545da9f86856b54cd226c29174ac1ae085e35b.tar.lz dexon-0x-contracts-3f545da9f86856b54cd226c29174ac1ae085e35b.tar.xz dexon-0x-contracts-3f545da9f86856b54cd226c29174ac1ae085e35b.tar.zst dexon-0x-contracts-3f545da9f86856b54cd226c29174ac1ae085e35b.zip |
Switched implicit conversions to explicit lodash calls
Diffstat (limited to 'packages/utils/src/abi_encoder/abstract_data_types')
3 files changed, 8 insertions, 8 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; |