From 97b8cc8b637e573ec7906371f4c69287177660fc Mon Sep 17 00:00:00 2001 From: Daniel Zarifpour Date: Fri, 12 Apr 2024 15:35:56 -0400 Subject: [PATCH] refactor: replace isContract --- script/whitelist/delegationFaucet/DelegationFaucet.sol | 3 +-- src/contracts/libraries/EIP1271SignatureUtils.sol | 3 +-- src/test/DelegationFaucet.t.sol | 4 ++-- src/test/unit/DelayedWithdrawalRouterUnit.t.sol | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/script/whitelist/delegationFaucet/DelegationFaucet.sol b/script/whitelist/delegationFaucet/DelegationFaucet.sol index 327e8e678..1bcf1b99a 100644 --- a/script/whitelist/delegationFaucet/DelegationFaucet.sol +++ b/script/whitelist/delegationFaucet/DelegationFaucet.sol @@ -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"; @@ -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))), diff --git a/src/contracts/libraries/EIP1271SignatureUtils.sol b/src/contracts/libraries/EIP1271SignatureUtils.sol index a4452f91e..9b9848ca7 100644 --- a/src/contracts/libraries/EIP1271SignatureUtils.sol +++ b/src/contracts/libraries/EIP1271SignatureUtils.sol @@ -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"; /** @@ -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" diff --git a/src/test/DelegationFaucet.t.sol b/src/test/DelegationFaucet.t.sol index e3f04fa75..b22d5a30b 100644 --- a/src/test/DelegationFaucet.t.sol +++ b/src/test/DelegationFaucet.t.sol @@ -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(); diff --git a/src/test/unit/DelayedWithdrawalRouterUnit.t.sol b/src/test/unit/DelayedWithdrawalRouterUnit.t.sol index 848d1319e..0a68ddc76 100644 --- a/src/test/unit/DelayedWithdrawalRouterUnit.t.sol +++ b/src/test/unit/DelayedWithdrawalRouterUnit.t.sol @@ -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 @@ -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