datahaven/contracts/test/mocks/PermissionControllerMock.sol
Steve Degosserie 387c056912
fix: Resolve Foundry build errors and apply code formatting (#241)
## Summary

Fixes the CI build failure in the `task-ts-build` workflow caused by
Foundry v1.4.2's Solar linter not being able to resolve Snowbridge's
context-specific import remappings.

## Problem

The Snowbridge submodule uses context-specific remappings (prefixed with
`:`) for its dependencies:
- `lib/snowbridge/contracts/:openzeppelin/` → OpenZeppelin contracts
- `lib/snowbridge/contracts/:prb/math/` → PRB Math library

Foundry v1.4.2's Solar linter doesn't understand these context-specific
remappings and fails with errors like:
```
error: file openzeppelin/utils/cryptography/MerkleProof.sol not found
error: file prb/math/src/UD60x18.sol not found
```

## Solution

Added global remappings that the linter can understand:
```toml
"openzeppelin/=lib/snowbridge/contracts/lib/openzeppelin-contracts/contracts/",
"prb/math/=lib/snowbridge/contracts/lib/prb-math/",
```

### Why This Works
- The linter can now resolve `openzeppelin/` and `prb/math/` imports
globally
- These global remappings take **lower precedence** than
context-specific ones during compilation
- The compiler still uses the context-specific remappings (with `:`)
when compiling Snowbridge contracts
- The linter uses the global remappings when checking all files

## Changes

### Commit 1: Add global remappings
- `contracts/foundry.toml`: Added 2 global remapping entries

### Commit 2: Apply forge fmt
- Applied automatic formatting via `forge fmt` to ensure code style
consistency
- Multi-line formatting for long import statements and function
signatures
- No functional changes - purely formatting updates

## Testing

 Local build succeeds with `forge build`
 No Snowbridge import resolution errors
 `forge fmt --check` passes with no formatting issues
 Only linting notes/warnings remain (not errors)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-20 11:20:59 +03:00

105 lines
2.6 KiB
Solidity

// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.27;
import {
IPermissionController
} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol";
contract PermissionControllerIntermediate is IPermissionController {
function addPendingAdmin(
address account,
address admin
) external virtual {}
function removePendingAdmin(
address account,
address admin
) external virtual {}
function acceptAdmin(
address account
) external virtual {}
function removeAdmin(
address account,
address admin
) external virtual {}
function setAppointee(
address account,
address appointee,
address target,
bytes4 selector
) external virtual {}
function removeAppointee(
address account,
address appointee,
address target,
bytes4 selector
) external virtual {}
function isAdmin(
address account,
address caller
) external view virtual returns (bool) {}
function isPendingAdmin(
address account,
address pendingAdmin
) external view virtual returns (bool) {}
function getAdmins(
address account
) external view virtual returns (address[] memory) {}
function getPendingAdmins(
address account
) external view virtual returns (address[] memory) {}
function canCall(
address account,
address caller,
address target,
bytes4 selector
) external virtual returns (bool) {}
function getAppointeePermissions(
address account,
address appointee
) external virtual returns (address[] memory, bytes4[] memory) {}
function getAppointees(
address account,
address target,
bytes4 selector
) external virtual returns (address[] memory) {}
function version() external pure override returns (string memory) {
return "mock";
}
}
contract PermissionControllerMock is PermissionControllerIntermediate {
mapping(address => mapping(address => mapping(address => mapping(bytes4 => bool)))) internal
_canCall;
function setCanCall(
address account,
address caller,
address target,
bytes4 selector
) external {
_canCall[account][caller][target][selector] = true;
}
function canCall(
address account,
address caller,
address target,
bytes4 selector
) external view override returns (bool) {
if (account == caller) return true;
return _canCall[account][caller][target][selector];
}
}