aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils/src/abi_encoder/evm_data_types/string.ts
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-11-28 09:11:15 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-11-29 08:38:11 +0800
commit029b8d59507df25aa9c7d1b096c8d873eb6ae4da (patch)
treee95e60341f55da870fee30e1fb9aa98d201125c4 /packages/utils/src/abi_encoder/evm_data_types/string.ts
parent14c094d050e7b2d0a4b31d02dbe58a54153be7bb (diff)
downloaddexon-sol-tools-029b8d59507df25aa9c7d1b096c8d873eb6ae4da.tar
dexon-sol-tools-029b8d59507df25aa9c7d1b096c8d873eb6ae4da.tar.gz
dexon-sol-tools-029b8d59507df25aa9c7d1b096c8d873eb6ae4da.tar.bz2
dexon-sol-tools-029b8d59507df25aa9c7d1b096c8d873eb6ae4da.tar.lz
dexon-sol-tools-029b8d59507df25aa9c7d1b096c8d873eb6ae4da.tar.xz
dexon-sol-tools-029b8d59507df25aa9c7d1b096c8d873eb6ae4da.tar.zst
dexon-sol-tools-029b8d59507df25aa9c7d1b096c8d873eb6ae4da.zip
Changed constants to an exported enum; this is 0x convention
Diffstat (limited to 'packages/utils/src/abi_encoder/evm_data_types/string.ts')
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/string.ts12
1 files changed, 6 insertions, 6 deletions
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: <length><value>, 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');