datahaven/contracts/script/utils/ELScriptStorage.s.sol
Ahmad Kaouk 4a16de1061
fix: resolve forge build warnings (#398)
## Summary

### Configuration
- Remove deprecated `deny_warnings` config key from foundry.toml
- Add global `[lint]` config to suppress naming convention warnings for
AVS/EL/ERC patterns (`mixed-case-function`, `mixed-case-variable`)

### DataHavenServiceManager Refactoring
- Rename immutable variables to SCREAMING_SNAKE_CASE
(`_allocationManager` → `_ALLOCATION_MANAGER`, `_rewardsCoordinator` →
`_REWARDS_COORDINATOR`)
- Wrap modifier logic in internal functions (`_checkRewardsInitiator`,
`_checkValidator`, `_checkAllocationManager`) to reduce contract size
- Add `_toAddress` helper with assembly for safe bytes-to-address
conversion

### Safe Typecasting
- Replace direct typecasts with OpenZeppelin's SafeCast library in
deploy scripts and test utilities
- Use `.toUint32()`, `.toUint64()`, `.toUint160()` for
overflow-protected conversions
- Replace `bytes32("wrong origin")` string cast with hex literal in test
deployer

### Code Cleanup
- Remove 25+ unused imports across script and test files
- Convert plain imports to named imports for better clarity
- Use `SafeERC20.safeTransfer()` for token transfers in tests
- Change `view` to `pure` where appropriate

## Test plan

- [x] `forge build` completes with no warnings
- [x] `forge test` passes all 10 tests
2026-01-22 09:48:27 -03:00

93 lines
4.1 KiB
Solidity

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.27;
// Testing imports
import {Script} from "forge-std/Script.sol";
// EigenLayer imports
import {RewardsCoordinator} from "eigenlayer-contracts/src/contracts/core/RewardsCoordinator.sol";
import {
PermissionController
} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol";
import {AllocationManager} from "eigenlayer-contracts/src/contracts/core/AllocationManager.sol";
import {DelegationManager} from "eigenlayer-contracts/src/contracts/core/DelegationManager.sol";
import {StrategyManager} from "eigenlayer-contracts/src/contracts/core/StrategyManager.sol";
import {EigenPodManager} from "eigenlayer-contracts/src/contracts/pods/EigenPodManager.sol";
import {EigenPod} from "eigenlayer-contracts/src/contracts/pods/EigenPod.sol";
import {
StrategyBaseTVLLimits
} from "eigenlayer-contracts/src/contracts/strategies/StrategyBaseTVLLimits.sol";
import {IETHPOSDeposit} from "eigenlayer-contracts/src/contracts/interfaces/IETHPOSDeposit.sol";
// Struct used in the deployment JSON file to store detailed strategy information
struct DeployedStrategyJson {
address strategyAddress;
address strategyUnderlyingToken;
address strategyTokenCreator;
}
// Struct used here to store strategy information
struct DeployedStrategyInfo {
StrategyBaseTVLLimits strategy;
address strategyTokenCreator;
}
/**
* @title ELScriptStorage
* @notice This contract is a utility for scripts that need to interact with EigenLayer contracts.
*/
contract ELScriptStorage is Script {
// EigenLayer Contract declarations
RewardsCoordinator public rewardsCoordinator;
PermissionController public permissionController;
AllocationManager public allocationManager;
DelegationManager public delegation;
StrategyManager public strategyManager;
EigenPodManager public eigenPodManager;
EigenPod public eigenPodBeacon;
StrategyBaseTVLLimits public baseStrategy;
DeployedStrategyInfo[] public deployedStrategies;
IETHPOSDeposit public ethPOSDeposit;
// EigenLayer required semver
string public constant SEMVER = "v1.0.0";
/**
* @notice Loads the EigenLayer contracts from the deployment file.
*/
function _loadELContracts(
string memory network
) internal {
// Load the deployment file
string memory deploymentFile =
vm.readFile(string.concat("./deployments/", network, ".json"));
// Store the contract addresses
rewardsCoordinator =
RewardsCoordinator(vm.parseJsonAddress(deploymentFile, ".RewardsCoordinator"));
permissionController =
PermissionController(vm.parseJsonAddress(deploymentFile, ".PermissionController"));
allocationManager =
AllocationManager(vm.parseJsonAddress(deploymentFile, ".AllocationManager"));
delegation = DelegationManager(vm.parseJsonAddress(deploymentFile, ".DelegationManager"));
strategyManager = StrategyManager(vm.parseJsonAddress(deploymentFile, ".StrategyManager"));
eigenPodManager = EigenPodManager(vm.parseJsonAddress(deploymentFile, ".EigenPodManager"));
eigenPodBeacon = EigenPod(payable(vm.parseJsonAddress(deploymentFile, ".EigenPodBeacon")));
baseStrategy = StrategyBaseTVLLimits(
vm.parseJsonAddress(deploymentFile, ".BaseStrategyImplementation")
);
ethPOSDeposit = IETHPOSDeposit(vm.parseJsonAddress(deploymentFile, ".ETHPOSDeposit"));
bytes memory deployedStrategiesArrayData =
vm.parseJson(deploymentFile, ".DeployedStrategies");
DeployedStrategyJson[] memory strategies =
abi.decode(deployedStrategiesArrayData, (DeployedStrategyJson[]));
for (uint256 i = 0; i < strategies.length; i++) {
address strategyAddress = strategies[i].strategyAddress;
address strategyTokenCreator = strategies[i].strategyTokenCreator;
DeployedStrategyInfo memory strategyInfo;
strategyInfo.strategy = StrategyBaseTVLLimits(strategyAddress);
strategyInfo.strategyTokenCreator = strategyTokenCreator;
deployedStrategies.push(strategyInfo);
}
}
}