diff --git a/contracts/libraries/AddressConverters.sol b/contracts/libraries/AddressConverters.sol index 888629e17..01b4b1f75 100644 --- a/contracts/libraries/AddressConverters.sol +++ b/contracts/libraries/AddressConverters.sol @@ -2,8 +2,15 @@ pragma solidity ^0.8.0; library Bytes32ToAddress { + /************************************** + * ERRORS * + **************************************/ + error InvalidBytes32(); + function toAddress(bytes32 _bytes32) internal pure returns (address) { - require(uint256(_bytes32) >> 192 == 0, "Invalid bytes32: highest 12 bytes must be 0"); + if (uint256(_bytes32) >> 192 != 0) { + revert InvalidBytes32(); + } return address(uint160(uint256(_bytes32))); } }