diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-11-20 05:01:26 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-11-29 08:38:10 +0800 |
commit | 5b187935dc6bf194555e1652dbf53d1c637d4add (patch) | |
tree | 76b483bf416a2cb8fbac8283191ae34651e02625 /packages/utils/src | |
parent | d70d07366fcc9ed2a750a5427af9d210c486f344 (diff) | |
download | dexon-sol-tools-5b187935dc6bf194555e1652dbf53d1c637d4add.tar dexon-sol-tools-5b187935dc6bf194555e1652dbf53d1c637d4add.tar.gz dexon-sol-tools-5b187935dc6bf194555e1652dbf53d1c637d4add.tar.bz2 dexon-sol-tools-5b187935dc6bf194555e1652dbf53d1c637d4add.tar.lz dexon-sol-tools-5b187935dc6bf194555e1652dbf53d1c637d4add.tar.xz dexon-sol-tools-5b187935dc6bf194555e1652dbf53d1c637d4add.tar.zst dexon-sol-tools-5b187935dc6bf194555e1652dbf53d1c637d4add.zip |
tests for String
Diffstat (limited to 'packages/utils/src')
-rw-r--r-- | packages/utils/src/abi_encoder/evm_data_types.ts | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/packages/utils/src/abi_encoder/evm_data_types.ts b/packages/utils/src/abi_encoder/evm_data_types.ts index ff1bc594d..b6a62a5d4 100644 --- a/packages/utils/src/abi_encoder/evm_data_types.ts +++ b/packages/utils/src/abi_encoder/evm_data_types.ts @@ -318,7 +318,7 @@ export class Bytes extends PayloadDataType { public encodeValue(value: string | Buffer): Buffer { if (typeof value === 'string' && !value.startsWith('0x')) { - throw new Error(`Input value must be hex (prefixed with 0x). Actual value is '${value}'`); + throw new Error(`Tried to encode non-hex value. Value must inlcude '0x' prefix. Got '${value}'`); } const valueBuf = ethUtil.toBuffer(value); if (value.length % 2 !== 0) { @@ -365,7 +365,7 @@ export class SolString extends PayloadDataType { public encodeValue(value: string): Buffer { const wordsForValue = Math.ceil(value.length / 32); const paddedBytesForValue = wordsForValue * 32; - const valueBuf = ethUtil.setLengthRight(ethUtil.toBuffer(value), paddedBytesForValue); + const valueBuf = ethUtil.setLengthRight(new Buffer(value), paddedBytesForValue); const lengthBuf = ethUtil.setLengthLeft(ethUtil.toBuffer(value.length), 32); const encodedValueBuf = Buffer.concat([lengthBuf, valueBuf]); return encodedValueBuf; |