From d95cdaae8e26b3e479ca2ad70cc7c5a303444392 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Wed, 15 Dec 2021 18:54:10 +0100 Subject: [PATCH] Replace excodesize assembly with address.code.length (https://github.com/ethereum/solidity/releases/tag/v0.8.1) (#3025) --- contracts/utils/Address.sol | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/contracts/utils/Address.sol b/contracts/utils/Address.sol index 5d428702aeb..698d271458e 100644 --- a/contracts/utils/Address.sol +++ b/contracts/utils/Address.sol @@ -34,15 +34,11 @@ library Address { * ==== */ function isContract(address account) internal view returns (bool) { - // This method relies on extcodesize, which returns 0 for contracts in - // construction, since the code is only stored at the end of the - // constructor execution. + // This method relies on extcodesize/address.code.length, which returns 0 + // for contracts in construction, since the code is only stored at the end + // of the constructor execution. - uint256 size; - assembly { - size := extcodesize(account) - } - return size > 0; + return account.code.length > 0; } /**