diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-11-09 02:49:19 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-11-29 08:38:10 +0800 |
commit | e95aa617b6eb0e4b6bace7fbcf66de2658e314aa (patch) | |
tree | 1091843c21550a312cfb7ec4be4044b501e2141d /packages/order-utils/test/abi_encoder.ts | |
parent | 637ab1076a4071505ea3d4797767826070a65e16 (diff) | |
download | dexon-0x-contracts-e95aa617b6eb0e4b6bace7fbcf66de2658e314aa.tar.gz dexon-0x-contracts-e95aa617b6eb0e4b6bace7fbcf66de2658e314aa.tar.zst dexon-0x-contracts-e95aa617b6eb0e4b6bace7fbcf66de2658e314aa.zip |
All existing ABI tests passing
Diffstat (limited to 'packages/order-utils/test/abi_encoder.ts')
-rw-r--r-- | packages/order-utils/test/abi_encoder.ts | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/packages/order-utils/test/abi_encoder.ts b/packages/order-utils/test/abi_encoder.ts index 55b63b701..77cb89056 100644 --- a/packages/order-utils/test/abi_encoder.ts +++ b/packages/order-utils/test/abi_encoder.ts @@ -74,6 +74,7 @@ class Memblock { } public get(): string { + console.log(`Unstripped = '${this.dataType.getHexValue()}' and Stripped = '${ethUtil.stripHexPrefix(this.dataType.getHexValue())}'`); return ethUtil.stripHexPrefix(this.dataType.getHexValue()); } @@ -472,6 +473,7 @@ export class Byte extends StaticDataType { const evmWordWidth = 32; const paddedValue = ethUtil.setLengthRight(valueBuf, evmWordWidth); const hexValue = ethUtil.bufferToHex(paddedValue); + this.assignHexValue(hexValue); } @@ -538,7 +540,9 @@ export class Bytes extends DynamicDataType { } public getBodySize(): BigNumber { - return new BigNumber(this.getHexValue().length); + const valueBuf = ethUtil.toBuffer(this.getHexValue()); + const size = new BigNumber(valueBuf.byteLength); + return size; } public static matchGrammar(type: string): boolean { @@ -576,7 +580,9 @@ export class SolString extends DynamicDataType { } public getBodySize(): BigNumber { - return new BigNumber(this.getHexValue().length); + const valueBuf = ethUtil.toBuffer(this.getHexValue()); + const size = new BigNumber(valueBuf.byteLength); + return size; } public static matchGrammar(type: string): boolean { @@ -1032,12 +1038,14 @@ export class Method extends DataType { } public getHexValue(): string { - let value = ""; + let paramBufs: Buffer[] = []; _.each(this.params, (param: DataType) => { - value += param.getHexValue(); + paramBufs.push(ethUtil.toBuffer(param.getHexValue())); }); - return value; + const value = Buffer.concat(paramBufs); + const hexValue = ethUtil.bufferToHex(value); + return hexValue; } public encode(args: any[]): string { |