Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace Address.isContract #511

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions script/whitelist/delegationFaucet/DelegationFaucet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import "script/whitelist/delegationFaucet/DelegationFaucetStaker.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Create2.sol";
import "@openzeppelin/contracts/utils/Address.sol";

import "../ERC20PresetMinterPauser.sol";

Expand Down Expand Up @@ -64,7 +63,7 @@ contract DelegationFaucet is IDelegationFaucet, Ownable {
}

// Deploy staker address if not already deployed, staker constructor will approve the StrategyManager to spend the stakeToken
if (!Address.isContract(staker)) {
if (staker.code.length == 0) {
Create2.deploy(
0,
bytes32(uint256(uint160(_operator))),
Expand Down
3 changes: 1 addition & 2 deletions src/contracts/libraries/EIP1271SignatureUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.12;

import "@openzeppelin/contracts/interfaces/IERC1271.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

/**
Expand All @@ -26,7 +25,7 @@ library EIP1271SignatureUtils {
* indicating their intention for this action
* 2) if `signer` is a contract, then `signature` must will be checked according to EIP-1271
*/
if (Address.isContract(signer)) {
if (signer.code.length > 0) {
require(
IERC1271(signer).isValidSignature(digestHash, signature) == EIP1271_MAGICVALUE,
"EIP1271SignatureUtils.checkSignature_EIP1271: ERC1271 signature verification failed"
Expand Down
4 changes: 2 additions & 2 deletions src/test/DelegationFaucet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ contract DelegationFaucetTests is EigenLayerTestHelper {
uint256 supplyBefore = stakeToken.totalSupply();
uint256 stratBalanceBefore = stakeToken.balanceOf(address(stakeTokenStrat));
assertTrue(
!Address.isContract(stakerContract),
stakerContract.code.length == 0,
"test_mintDepositAndDelegate_CheckBalancesAndDeploys: staker contract shouldn't be deployed"
);
IDelegationManager.SignatureWithExpiry memory signatureWithExpiry;
delegationFaucet.mintDepositAndDelegate(operator, signatureWithExpiry, bytes32(0), _depositAmount);
assertTrue(
Address.isContract(stakerContract),
stakerContract.code.length > 0,
"test_mintDepositAndDelegate_CheckBalancesAndDeploys: staker contract not deployed"
);
uint256 supplyAfter = stakeToken.totalSupply();
Expand Down
4 changes: 2 additions & 2 deletions src/test/unit/DelayedWithdrawalRouterUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ contract DelayedWithdrawalRouterUnitTests is Test {
public filterFuzzedAddressInputs(recipient)
{
// filter contracts out of fuzzed recipient input, since most don't implement a payable fallback function
cheats.assume(!Address.isContract(recipient));
cheats.assume(recipient.code.length == 0);
// filter out precompile addresses (they won't accept delayedWithdrawal either)
cheats.assume(uint160(recipient) > 256);
// filter fuzzed inputs to avoid running out of gas & excessive test run-time
Expand Down Expand Up @@ -236,7 +236,7 @@ contract DelayedWithdrawalRouterUnitTests is Test {
cheats.assume(delayedWithdrawalAmount != 0);
cheats.assume(delayedWithdrawalsToCreate > 5);
// filter contracts out of fuzzed recipient input, since most don't implement a payable fallback function
cheats.assume(!Address.isContract(recipient));
cheats.assume(recipient.code.length == 0);
// filter out precompile addresses (they won't accept delayedWithdrawal either)
cheats.assume(uint160(recipient) > 256);
// filter fuzzed inputs to avoid running out of gas & excessive test run-time
Expand Down