## Changes ### Configuration - Added .solhint.json with recommended rules + custom config - 160 char line length (warn) - Double quotes enforcement (error) - Explicit visibility required (error) - Console statements allowed (scripts/tests need them) - Gas optimization warnings enabled - Ignores test/helpers/, lib/, out/, cache/, broadcast/ - Added foundry.toml [fmt] section - 160 char line length - 4-space tabs - Double quotes - Thousands separators for numbers - Sort imports enabled - Added .lintstagedrc.json for pre-commit auto-fix - Runs solhint --fix on .sol files - Runs forge fmt on .sol files - Added husky pre-commit hook via lint-staged ### NPM Scripts - lint:sol - run solhint - lint:sol:fix - auto-fix solhint issues - format:sol - format with forge fmt - format:sol:check - check formatting - lint / lint:fix - combined commands ### Code Changes - Added explicit visibility modifiers (internal) to constants in scripts and tests - Fixed quote style in DeployLocal.sol - All Solidity files formatted with forge fmt ## Verification - ✅ forge fmt --check passes - ✅ No solhint errors (warnings only) - ✅ forge build succeeds - ✅ forge test passes (107/107) resolves #44 Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/51
46 lines
1.3 KiB
Solidity
46 lines
1.3 KiB
Solidity
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
pragma solidity ^0.8.19;
|
|
|
|
/**
|
|
* @title MockStake
|
|
* @notice Mock implementation of Stake contract for testing Optimizer
|
|
* @dev Allows setting percentageStaked and averageTaxRate for testing different scenarios
|
|
*/
|
|
contract MockStake {
|
|
uint256 private _percentageStaked;
|
|
uint256 private _averageTaxRate;
|
|
|
|
/**
|
|
* @notice Set the percentage staked for testing
|
|
* @param percentage Value between 0 and 1e18
|
|
*/
|
|
function setPercentageStaked(uint256 percentage) external {
|
|
require(percentage <= 1e18, "Percentage too high");
|
|
_percentageStaked = percentage;
|
|
}
|
|
|
|
/**
|
|
* @notice Set the average tax rate for testing
|
|
* @param rate Value between 0 and 1e18
|
|
*/
|
|
function setAverageTaxRate(uint256 rate) external {
|
|
require(rate <= 1e18, "Rate too high");
|
|
_averageTaxRate = rate;
|
|
}
|
|
|
|
/**
|
|
* @notice Returns the mocked percentage staked
|
|
* @return percentageStaked A number between 0 and 1e18
|
|
*/
|
|
function getPercentageStaked() external view returns (uint256) {
|
|
return _percentageStaked;
|
|
}
|
|
|
|
/**
|
|
* @notice Returns the mocked average tax rate
|
|
* @return averageTaxRate A number between 0 and 1e18
|
|
*/
|
|
function getAverageTaxRate() external view returns (uint256) {
|
|
return _averageTaxRate;
|
|
}
|
|
}
|