aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils/src/abi_encoder/evm_data_types/uint.ts
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-11-29 05:22:18 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-11-29 08:38:11 +0800
commita172ab158e2eaca8256ef881c3f2d4098987ec8a (patch)
tree4187301296e4f7fb37cb6907c5b857a3aa86fa1b /packages/utils/src/abi_encoder/evm_data_types/uint.ts
parent5c13353fb2512411c0f2c8cba9395235188f5df8 (diff)
downloaddexon-sol-tools-a172ab158e2eaca8256ef881c3f2d4098987ec8a.tar
dexon-sol-tools-a172ab158e2eaca8256ef881c3f2d4098987ec8a.tar.gz
dexon-sol-tools-a172ab158e2eaca8256ef881c3f2d4098987ec8a.tar.bz2
dexon-sol-tools-a172ab158e2eaca8256ef881c3f2d4098987ec8a.tar.lz
dexon-sol-tools-a172ab158e2eaca8256ef881c3f2d4098987ec8a.tar.xz
dexon-sol-tools-a172ab158e2eaca8256ef881c3f2d4098987ec8a.tar.zst
dexon-sol-tools-a172ab158e2eaca8256ef881c3f2d4098987ec8a.zip
Explicit imports for EVM Data Types
Diffstat (limited to 'packages/utils/src/abi_encoder/evm_data_types/uint.ts')
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/uint.ts20
1 files changed, 10 insertions, 10 deletions
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 df7ea38a4..a5989ea11 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/uint.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/uint.ts
@@ -7,47 +7,47 @@ import { RawCalldata } from '../calldata';
import { constants } from '../utils/constants';
import * as EncoderMath from '../utils/math';
-export class UInt extends AbstractDataTypes.Blob {
+export class UIntDataType extends AbstractDataTypes.Blob {
private static readonly _MATCHER = RegExp(
'^uint(8|16|24|32|40|48|56|64|72|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256){0,1}$',
);
private static readonly _SIZE_KNOWN_AT_COMPILE_TIME: boolean = true;
private static readonly _MAX_WIDTH: number = 256;
- private static readonly _DEFAULT_WIDTH: number = UInt._MAX_WIDTH;
+ private static readonly _DEFAULT_WIDTH: number = UIntDataType._MAX_WIDTH;
private static readonly _MIN_VALUE = new BigNumber(0);
private readonly _width: number;
private readonly _maxValue: BigNumber;
public static matchType(type: string): boolean {
- return UInt._MATCHER.test(type);
+ return UIntDataType._MATCHER.test(type);
}
private static _decodeWidthFromType(type: string): number {
- const matches = UInt._MATCHER.exec(type);
+ const matches = UIntDataType._MATCHER.exec(type);
const width =
!_.isNull(matches) && matches.length === 2 && !_.isUndefined(matches[1])
? parseInt(matches[1], constants.DEC_BASE)
- : UInt._DEFAULT_WIDTH;
+ : UIntDataType._DEFAULT_WIDTH;
return width;
}
public constructor(dataItem: DataItem, dataTypeFactory: DataTypeFactory) {
- super(dataItem, dataTypeFactory, UInt._SIZE_KNOWN_AT_COMPILE_TIME);
- if (!UInt.matchType(dataItem.type)) {
+ super(dataItem, dataTypeFactory, UIntDataType._SIZE_KNOWN_AT_COMPILE_TIME);
+ if (!UIntDataType.matchType(dataItem.type)) {
throw new Error(`Tried to instantiate UInt with bad input: ${dataItem}`);
}
- this._width = UInt._decodeWidthFromType(dataItem.type);
+ this._width = UIntDataType._decodeWidthFromType(dataItem.type);
this._maxValue = new BigNumber(2).toPower(this._width).sub(1);
}
public encodeValue(value: BigNumber | string | number): Buffer {
- const encodedValue = EncoderMath.safeEncodeNumericValue(value, UInt._MIN_VALUE, this._maxValue);
+ const encodedValue = EncoderMath.safeEncodeNumericValue(value, UIntDataType._MIN_VALUE, this._maxValue);
return encodedValue;
}
public decodeValue(calldata: RawCalldata): BigNumber {
const valueBuf = calldata.popWord();
- const value = EncoderMath.safeDecodeNumericValue(valueBuf, UInt._MIN_VALUE, this._maxValue);
+ const value = EncoderMath.safeDecodeNumericValue(valueBuf, UIntDataType._MIN_VALUE, this._maxValue);
return value;
}