Forráskód Böngészése

Use bytes.concat in MessageHashUtils (#4504)

Francisco 2 éve
szülő
commit
d39df78f6c

+ 3 - 1
.changeset/flat-bottles-wonder.md

@@ -2,4 +2,6 @@
 'openzeppelin-solidity': minor
 ---
 
-Replace some uses of `abi.encodePacked` with clearer alternatives (e.g. `bytes.concat`, `string.concat`).
+Replace some uses of `abi.encodePacked` with clearer alternatives (e.g. `bytes.concat`, `string.concat`). (#4504)[https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4504]
+
+pr: #4296

+ 2 - 1
contracts/utils/cryptography/MessageHashUtils.sol

@@ -46,7 +46,8 @@ library MessageHashUtils {
      * See {ECDSA-recover}.
      */
     function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32 digest) {
-        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(message.length), message));
+        return
+            keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
     }
 
     /**