diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-11-20 02:34:04 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-11-29 08:38:10 +0800 |
commit | 880540f4b8fd8dd7a7f1a93cf7fbcdc17e1fbb13 (patch) | |
tree | 908bdc1b8b71704899ec88da9849bf67b12730a7 /packages/utils/src/abi_encoder/evm_data_types.ts | |
parent | 8a8b904a292063d1adb3df0a84023610a3985f7f (diff) | |
download | dexon-sol-tools-880540f4b8fd8dd7a7f1a93cf7fbcdc17e1fbb13.tar dexon-sol-tools-880540f4b8fd8dd7a7f1a93cf7fbcdc17e1fbb13.tar.gz dexon-sol-tools-880540f4b8fd8dd7a7f1a93cf7fbcdc17e1fbb13.tar.bz2 dexon-sol-tools-880540f4b8fd8dd7a7f1a93cf7fbcdc17e1fbb13.tar.lz dexon-sol-tools-880540f4b8fd8dd7a7f1a93cf7fbcdc17e1fbb13.tar.xz dexon-sol-tools-880540f4b8fd8dd7a7f1a93cf7fbcdc17e1fbb13.tar.zst dexon-sol-tools-880540f4b8fd8dd7a7f1a93cf7fbcdc17e1fbb13.zip |
Fixed issue with decoding negative ints with width < 256
Diffstat (limited to 'packages/utils/src/abi_encoder/evm_data_types.ts')
-rw-r--r-- | packages/utils/src/abi_encoder/evm_data_types.ts | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/packages/utils/src/abi_encoder/evm_data_types.ts b/packages/utils/src/abi_encoder/evm_data_types.ts index d024a9bfa..bfb2808da 100644 --- a/packages/utils/src/abi_encoder/evm_data_types.ts +++ b/packages/utils/src/abi_encoder/evm_data_types.ts @@ -154,9 +154,8 @@ abstract class Number extends PayloadDataType { if (this instanceof Int) { // Check if we're negative const binBase = 2; - const paddedValueBin = value.toString(binBase); - const valueBin = paddedValueBin.slice(paddedValueBin.length - this.width); - if (valueBin[0].startsWith('1')) { + const valueBin = value.toString(2); + if (valueBin.length === 256 && valueBin[0].startsWith('1')) { // Negative // Step 1/3: Invert binary value let invertedValueBin = ''; |