laconicd-deprecated/tests/solidity/suites/staking/contracts/lib/os/IsContract.sol
Federico Kunze 96cad7de9c
tests: reorganize packages (#7)
* tests: reorganize testing packages

* gitignore and minor changes
2021-05-11 07:54:55 -04:00

25 lines
785 B
Solidity

// Brought from https://github.com/aragon/aragonOS/blob/v4.3.0/contracts/common/IsContract.sol
// Adapted to use pragma ^0.5.8 and satisfy our linter rules
pragma solidity ^0.5.8;
contract IsContract {
/*
* NOTE: this should NEVER be used for authentication
* (see pitfalls: https://github.com/fergarrui/ethereum-security/tree/master/contracts/extcodesize).
*
* This is only intended to be used as a sanity check that an address is actually a contract,
* RATHER THAN an address not being a contract.
*/
function isContract(address _target) internal view returns (bool) {
if (_target == address(0)) {
return false;
}
uint256 size;
assembly { size := extcodesize(_target) }
return size > 0;
}
}