diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2019-02-05 08:25:00 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2019-02-05 08:32:14 +0800 |
commit | db900d180cf7a5b9affbe7ff486b6e3e1e038e84 (patch) | |
tree | e6280a109ab7f2d874d7e9dfcf8ded74056aef85 /packages/utils/src | |
parent | 74293d5bc844035781d65aa85051ef3bbb7b8b1a (diff) | |
download | dexon-0x-contracts-db900d180cf7a5b9affbe7ff486b6e3e1e038e84.tar.gz dexon-0x-contracts-db900d180cf7a5b9affbe7ff486b6e3e1e038e84.tar.zst dexon-0x-contracts-db900d180cf7a5b9affbe7ff486b6e3e1e038e84.zip |
Decode NULL as false
Diffstat (limited to 'packages/utils/src')
-rw-r--r-- | packages/utils/src/abi_encoder/evm_data_types/bool.ts | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/packages/utils/src/abi_encoder/evm_data_types/bool.ts b/packages/utils/src/abi_encoder/evm_data_types/bool.ts index 23298bc88..ffccd6e53 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/bool.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/bool.ts @@ -36,7 +36,8 @@ export class BoolDataType extends AbstractBlobDataType { public decodeValue(calldata: RawCalldata): boolean { const valueBuf = calldata.popWord(); const valueHex = ethUtil.bufferToHex(valueBuf); - const valueNumber = new BigNumber(valueHex, constants.HEX_BASE); + // Hack @hysz: there are some cases where `false` is encoded as 0x instead of 0x0. + const valueNumber = valueHex === '0x' ? new BigNumber(0) : new BigNumber(valueHex, constants.HEX_BASE); if (!(valueNumber.isEqualTo(0) || valueNumber.isEqualTo(1))) { throw new Error(`Failed to decode boolean. Expected 0x0 or 0x1, got ${valueHex}`); } |