From 029b8d59507df25aa9c7d1b096c8d873eb6ae4da Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Tue, 27 Nov 2018 17:11:15 -0800 Subject: Changed constants to an exported enum; this is 0x convention --- packages/utils/src/abi_encoder/evm_data_types/string.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'packages/utils/src/abi_encoder/evm_data_types/string.ts') 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 e5b2d5f33..ac62ea264 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/string.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/string.ts @@ -4,7 +4,7 @@ import * as _ from 'lodash'; import { AbstractDataTypes, DataTypeFactory } from '../abstract_data_types'; import { RawCalldata } from '../calldata'; -import * as Constants from '../utils/constants'; +import { constants } from '../utils/constants'; export class String extends AbstractDataTypes.Blob { private static readonly _SIZE_KNOWN_AT_COMPILE_TIME: boolean = false; @@ -25,10 +25,10 @@ export class String extends AbstractDataTypes.Blob { public encodeValue(value: string): Buffer { // Encoded value is of the form: , with each field padded to be word-aligned. // 1/3 Construct the length - const wordsToStoreValuePadded = Math.ceil(value.length / Constants.EVM_WORD_WIDTH_IN_BYTES); - const bytesToStoreValuePadded = wordsToStoreValuePadded * Constants.EVM_WORD_WIDTH_IN_BYTES; + const wordsToStoreValuePadded = Math.ceil(value.length / constants.EVM_WORD_WIDTH_IN_BYTES); + const bytesToStoreValuePadded = wordsToStoreValuePadded * constants.EVM_WORD_WIDTH_IN_BYTES; const lengthBuf = ethUtil.toBuffer(value.length); - const lengthBufPadded = ethUtil.setLengthLeft(lengthBuf, Constants.EVM_WORD_WIDTH_IN_BYTES); + const lengthBufPadded = ethUtil.setLengthLeft(lengthBuf, constants.EVM_WORD_WIDTH_IN_BYTES); // 2/3 Construct the value const valueBuf = new Buffer(value); const valueBufPadded = ethUtil.setLengthRight(valueBuf, bytesToStoreValuePadded); @@ -42,9 +42,9 @@ export class String extends AbstractDataTypes.Blob { // 1/2 Decode length const lengthBufPadded = calldata.popWord(); const lengthHexPadded = ethUtil.bufferToHex(lengthBufPadded); - const length = parseInt(lengthHexPadded, Constants.HEX_BASE); + const length = parseInt(lengthHexPadded, constants.HEX_BASE); // 2/2 Decode value - const wordsToStoreValuePadded = Math.ceil(length / Constants.EVM_WORD_WIDTH_IN_BYTES); + const wordsToStoreValuePadded = Math.ceil(length / constants.EVM_WORD_WIDTH_IN_BYTES); const valueBufPadded = calldata.popWords(wordsToStoreValuePadded); const valueBuf = valueBufPadded.slice(0, length); const value = valueBuf.toString('ascii'); -- cgit v1.2.3