Skip to content

Harden contract, add ERC-20 recovery, and improve tooling#1

Merged
SP1R4 merged 2 commits into
mainfrom
improve/contract-hardening-tooling
May 21, 2026
Merged

Harden contract, add ERC-20 recovery, and improve tooling#1
SP1R4 merged 2 commits into
mainfrom
improve/contract-hardening-tooling

Conversation

@SP1R4
Copy link
Copy Markdown
Owner

@SP1R4 SP1R4 commented May 21, 2026

Summary

Improvements across the FundForwarder contract, build config, and tooling. All 54 tests pass with 100% line & function coverage; Solidity lints clean.

Contract

  • Custom errors — migrated all 15 require-strings to 11 typed custom errors for lower deploy/revert gas (modern OZ-v5 idiom).
  • FundsRecovered eventrecoverFunds() now emits a dedicated event instead of misusing Forwarded, so indexers can distinguish a recovery from a normal forward.
  • recoverERC20(address token) — sweeps ERC-20 tokens accidentally sent to the contract (previously stuck forever). Owner-only, SafeERC20, reentrancy-guarded; emits ERC20Recovered.

Config

  • Optimizer enabled in hardhat.config.js (runs: 200) — smaller bytecode, lower runtime gas.
  • License fixpackage.json and README now say MIT, matching LICENSE and all SPDX headers (previously ISC).
  • Filled in package.json metadata (name, author, keywords, repository, description).

Tooling

  • Added .solhint.json / .solhintignore (solhint:recommended, gas-custom-errors enforced) and an npm run lint script.
  • CI now runs Solidity linting and Slither static analysis (fail-on: high) as a separate job.

Tests

  • Added MockERC20 helper plus ERC-20 recovery and FundsRecovered test cases (49 → 54 tests).
  • Updated assertions to revertedWithCustomError.

🤖 Generated with Claude Code

SP1R4 and others added 2 commits May 21, 2026 21:27
Contract:
- Migrate all require-strings to typed custom errors (lower deploy/revert gas)
- Add dedicated FundsRecovered event instead of reusing Forwarded
- Add recoverERC20() to sweep tokens accidentally sent to the contract

Config:
- Enable the Solidity optimizer (runs: 200)
- Fix license inconsistency: package.json/README now MIT to match SPDX headers
- Fill in package.json metadata (name, author, keywords, repository)

Tooling:
- Add solhint config and `npm run lint` script
- Add Solidity linting and Slither static analysis to CI

Tests:
- Add MockERC20 helper and ERC-20 recovery / FundsRecovered test cases
- Update assertions to revertedWithCustomError (49 -> 54 tests, all passing)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add slither.config.json: exclude test helpers (contracts/test/) and
  node_modules from analysis, plus informational/optimization noise.
  This drops the `suicidal` finding on the ForceFeeder test helper.
- Annotate forwardFunds() with slither-disable-next-line arbitrary-send-eth:
  targetWallet is an owner-managed, validated, time-locked destination,
  not user-supplied — the High-severity finding is a false positive here.
- Wire slither.config.json into the CI Slither step.

Keeps `fail-on: high` intact so genuine high-severity findings still block.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@SP1R4 SP1R4 merged commit 3fe910e into main May 21, 2026
2 checks passed
@SP1R4 SP1R4 deleted the improve/contract-hardening-tooling branch May 21, 2026 18:39
SP1R4 added a commit that referenced this pull request May 22, 2026
* Harden contract, add ERC-20 recovery, and improve tooling

Contract:
- Migrate all require-strings to typed custom errors (lower deploy/revert gas)
- Add dedicated FundsRecovered event instead of reusing Forwarded
- Add recoverERC20() to sweep tokens accidentally sent to the contract

Config:
- Enable the Solidity optimizer (runs: 200)
- Fix license inconsistency: package.json/README now MIT to match SPDX headers
- Fill in package.json metadata (name, author, keywords, repository)

Tooling:
- Add solhint config and `npm run lint` script
- Add Solidity linting and Slither static analysis to CI

Tests:
- Add MockERC20 helper and ERC-20 recovery / FundsRecovered test cases
- Update assertions to revertedWithCustomError (49 -> 54 tests, all passing)


* Triage Slither false positives so static-analysis passes

- Add slither.config.json: exclude test helpers (contracts/test/) and
  node_modules from analysis, plus informational/optimization noise.
  This drops the `suicidal` finding on the ForceFeeder test helper.
- Annotate forwardFunds() with slither-disable-next-line arbitrary-send-eth:
  targetWallet is an owner-managed, validated, time-locked destination,
  not user-supplied — the High-severity finding is a false positive here.
- Wire slither.config.json into the CI Slither step.

Keeps `fail-on: high` intact so genuine high-severity findings still block.


---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant