Use bytes32 explicitly for Create2.computeAddress() (#2088)

* Use bytes32 explicitly for Create2.computeAddress(), to force users cache hash of the bytecode

* Remove only from test :)
This commit is contained in:
Anton Bukov
2020-03-09 19:02:14 +03:00
committed by GitHub
parent ca19cea05e
commit e2813df879
3 changed files with 8 additions and 30 deletions

View File

@ -28,19 +28,11 @@ library Create2 {
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the `bytecode`
* @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the `bytecodeHash`
* or `salt` will result in a new destination address.
*/
function computeAddress(bytes32 salt, bytes memory bytecode) internal view returns (address) {
return computeAddress(salt, bytecode, address(this));
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
* `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
*/
function computeAddress(bytes32 salt, bytes memory bytecode, address deployer) internal pure returns (address) {
return computeAddress(salt, keccak256(bytecode), deployer);
function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
return computeAddress(salt, bytecodeHash, address(this));
}
/**