datahaven/contracts/script/utils/Logging.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

81 lines
2.1 KiB
Solidity

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.27;
import {console} from "forge-std/console.sol";
library Logging {
// Logging helper constants
string private constant HEADER1 =
"============================================================";
string private constant HEADER2 =
" ";
string private constant FOOTER = "============================================================";
string private constant SEPARATOR =
"------------------------------------------------------------";
function logHeader(
string memory title
) internal pure {
console.log("");
console.log(HEADER1);
console.log("| %s |", title);
console.log(SEPARATOR);
}
function logSection(
string memory title
) internal pure {
console.log("");
console.log("| %s:", title);
console.log(SEPARATOR);
}
function logContractDeployed(
string memory name,
address contractAddress
) internal pure {
console.log("| [+] %s: %s", name, contractAddress);
}
function logAgentOrigin(
string memory name,
string memory agentOrigin
) internal pure {
console.log("| [+] %s: %s", name, agentOrigin);
}
function logFunctionSelector(
string memory name,
string memory selector
) internal pure {
console.log("| [+] %s: %s", name, selector);
}
function logStep(
string memory message
) internal pure {
console.log("| >>> %s", message);
}
function logInfo(
string memory message
) internal pure {
console.log("| [i] %s", message);
}
function logFooter() internal pure {
console.log(FOOTER);
console.log("");
}
function logProgress(
uint16 step,
uint16 totalSteps
) internal pure {
console.log("");
console.log(
"Progress: Step %d/%d completed (%d%%)", step, totalSteps, (step * 100) / totalSteps
);
console.log("");
}
}