aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils/src/abi_encoder
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-11-20 04:43:16 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-11-29 08:38:10 +0800
commitd70d07366fcc9ed2a750a5427af9d210c486f344 (patch)
tree92092cdec3062619a7f0ae6b3b4bf72fe058854b /packages/utils/src/abi_encoder
parent9a0bd05c4ca98dd24d71cdbd53175bfdd5250107 (diff)
downloaddexon-0x-contracts-d70d07366fcc9ed2a750a5427af9d210c486f344.tar.gz
dexon-0x-contracts-d70d07366fcc9ed2a750a5427af9d210c486f344.tar.zst
dexon-0x-contracts-d70d07366fcc9ed2a750a5427af9d210c486f344.zip
Tests for Static Bytes
Diffstat (limited to 'packages/utils/src/abi_encoder')
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/packages/utils/src/abi_encoder/evm_data_types.ts b/packages/utils/src/abi_encoder/evm_data_types.ts
index 38878f63e..ff1bc594d 100644
--- a/packages/utils/src/abi_encoder/evm_data_types.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types.ts
@@ -270,6 +270,10 @@ export class Byte extends PayloadDataType {
}
public encodeValue(value: string | Buffer): Buffer {
+ // Sanity check if string
+ if (typeof value === 'string' && value.startsWith('0x') === false) {
+ throw new Error(`Tried to encode non-hex value. Value must inlcude '0x' prefix.`);
+ }
// Convert value into a buffer and do bounds checking
const valueBuf = ethUtil.toBuffer(value);
if (valueBuf.byteLength > this.width) {