Explorar o código

Replace excodesize assembly with address.code.length (https://github.com/ethereum/solidity/releases/tag/v0.8.1) (#3025)

Anton Bukov %!s(int64=3) %!d(string=hai) anos
pai
achega
d95cdaae8e
Modificáronse 1 ficheiros con 4 adicións e 8 borrados
  1. 4 8
      contracts/utils/Address.sol

+ 4 - 8
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;
     }
 
     /**