diff options
Diffstat (limited to 'packages/utils/src/abi_encoder')
7 files changed, 12 insertions, 10 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 bd4711baf..db4f02b89 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 @@ -47,7 +47,8 @@ export abstract class DataType { const hasSelector = !_.isUndefined(selector); const rawCalldata = new RawCalldata(calldata, hasSelector); const rules_ = _.isUndefined(rules) ? constants.DEFAULT_DECODING_RULES : rules; - const value = rawCalldata.getSizeInBytes() > 0 ? this.generateValue(rawCalldata, rules_) : this.getDefaultValue(rules_); + const value = + rawCalldata.getSizeInBytes() > 0 ? this.generateValue(rawCalldata, rules_) : this.getDefaultValue(rules_); return value; } 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 54b516bb0..24887c509 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/bool.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/bool.ts @@ -10,7 +10,7 @@ import { constants } from '../utils/constants'; export class BoolDataType extends AbstractBlobDataType { private static readonly _SIZE_KNOWN_AT_COMPILE_TIME: boolean = true; - private static readonly _DEFAULT_VALUE: boolean =false; + private static readonly _DEFAULT_VALUE: boolean = false; public static matchType(type: string): boolean { return type === SolidityTypes.Bool; diff --git a/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts b/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts index 0dd40fed2..7a49a84b4 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts @@ -9,7 +9,7 @@ import { constants } from '../utils/constants'; export class DynamicBytesDataType extends AbstractBlobDataType { private static readonly _SIZE_KNOWN_AT_COMPILE_TIME: boolean = false; - private static readonly _DEFAULT_VALUE = "0x"; + private static readonly _DEFAULT_VALUE = '0x'; public static matchType(type: string): boolean { return type === SolidityTypes.Bytes; 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 c7e4318eb..02278f666 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/int.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/int.ts @@ -51,7 +51,7 @@ 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 === constants.NUMBER_OF_BYTES_IN_UINT8) { + if (this._width === constants.NUMBER_OF_BYTES_IN_INT8) { return value.toNumber(); } return value; @@ -59,7 +59,7 @@ export class IntDataType extends AbstractBlobDataType { public getDefaultValue(): BigNumber | number { const defaultValue = IntDataType._DEFAULT_VALUE; - if (this._width === constants.NUMBER_OF_BYTES_IN_UINT8) { + if (this._width === constants.NUMBER_OF_BYTES_IN_INT8) { return defaultValue.toNumber(); } return defaultValue; diff --git a/packages/utils/src/abi_encoder/evm_data_types/string.ts b/packages/utils/src/abi_encoder/evm_data_types/string.ts index 886f398f9..f54d739b4 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/string.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/string.ts @@ -9,7 +9,7 @@ import { constants } from '../utils/constants'; export class StringDataType extends AbstractBlobDataType { private static readonly _SIZE_KNOWN_AT_COMPILE_TIME: boolean = false; - private static readonly _DEFAULT_VALUE = ""; + private static readonly _DEFAULT_VALUE = ''; public static matchType(type: string): boolean { return type === SolidityTypes.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 9dc141a59..d530606b9 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/uint.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/uint.ts @@ -50,7 +50,7 @@ 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 === constants.NUMBER_OF_BYTES_IN_INT8) { + if (this._width === constants.NUMBER_OF_BYTES_IN_UINT8) { return value.toNumber(); } return value; @@ -58,7 +58,7 @@ export class UIntDataType extends AbstractBlobDataType { public getDefaultValue(): BigNumber | number { const defaultValue = UIntDataType._DEFAULT_VALUE; - if (this._width === constants.NUMBER_OF_BYTES_IN_INT8) { + if (this._width === constants.NUMBER_OF_BYTES_IN_UINT8) { return defaultValue.toNumber(); } return defaultValue; diff --git a/packages/utils/src/abi_encoder/utils/constants.ts b/packages/utils/src/abi_encoder/utils/constants.ts index db190c3a6..b45b5b8e8 100644 --- a/packages/utils/src/abi_encoder/utils/constants.ts +++ b/packages/utils/src/abi_encoder/utils/constants.ts @@ -1,6 +1,7 @@ -import { DecodingRules, EncodingRules } from './rules'; import * as ethUtil from 'ethereumjs-util'; +import { DecodingRules, EncodingRules } from './rules'; + export const constants = { EVM_WORD_WIDTH_IN_BYTES: 32, EVM_WORD_WIDTH_IN_BITS: 256, @@ -19,4 +20,4 @@ export const constants = { EMPTY_EVM_WORD_BUFFER: ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000000'), NUMBER_OF_BYTES_IN_UINT8: 8, NUMBER_OF_BYTES_IN_INT8: 8, -} +}; |