Remove Address.isContract (#3945)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Co-authored-by: Francisco Giordano <fg@frang.io>
This commit is contained in:
JulissaDantes
2023-01-24 15:59:07 -05:00
committed by GitHub
parent 30c3c6c16e
commit c5d040beb9
15 changed files with 44 additions and 77 deletions

View File

@ -43,7 +43,7 @@ abstract contract ERC1967Upgrade {
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
require(newImplementation.code.length > 0, "ERC1967: new implementation is not a contract");
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
@ -153,9 +153,9 @@ abstract contract ERC1967Upgrade {
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(newBeacon.code.length > 0, "ERC1967: new beacon is not a contract");
require(
Address.isContract(IBeacon(newBeacon).implementation()),
IBeacon(newBeacon).implementation().code.length > 0,
"ERC1967: beacon implementation is not a contract"
);
StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;

View File

@ -1,11 +1,10 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)
pragma solidity ^0.8.0;
pragma solidity ^0.8.1;
import "./IBeacon.sol";
import "../../access/Ownable.sol";
import "../../utils/Address.sol";
/**
* @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their
@ -59,7 +58,7 @@ contract UpgradeableBeacon is IBeacon, Ownable {
* - `newImplementation` must be a contract.
*/
function _setImplementation(address newImplementation) private {
require(Address.isContract(newImplementation), "UpgradeableBeacon: implementation is not a contract");
require(newImplementation.code.length > 0, "UpgradeableBeacon: implementation is not a contract");
_implementation = newImplementation;
}
}

View File

@ -83,7 +83,7 @@ abstract contract Initializable {
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),
(isTopLevelCall && _initialized < 1) || (address(this).code.length == 0 && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;