Skip to content

refactor: extract shared admin and TTL utilities into a new mergefi-c… - #62

Merged
chonilius merged 1 commit into
MergeFi:mainfrom
ABEEGOLD:tracked-extraction
Aug 17, 2026
Merged

refactor: extract shared admin and TTL utilities into a new mergefi-c…#62
chonilius merged 1 commit into
MergeFi:mainfrom
ABEEGOLD:tracked-extraction

Conversation

@ABEEGOLD

Copy link
Copy Markdown
Contributor

Closes #60

Extract extend_ttl and require_admin into mergefi-common crate (#60)

Overview

This PR resolves #60 by addressing the structural triplication of extend_ttl and require_admin across the mergefi-escrow, mergefi-milestones, and mergefi-maintenance-pool contracts.

By extracting these heavily duplicated, identical components into a shared mergefi-common dependency, this PR sets up the critical structural prerequisite for applying the TTL extension bounds and admin-rotation fixes securely, exactly once, across all contracts rather than risking incomplete application via copy-pasting.

Changes Made

  • Created mergefi-common: Added a new shared Rust crate to the workspace specifically for cross-contract logic.
  • Abstracted Common Helpers: Moved extend_ttl and require_admin into the common crate.
  • AdminKey Trait Parameterization: Designed a minimal mergefi_common::AdminKey trait and implemented it for each contract's distinct DataKey enum, mapping their respective Admin variants seamlessly.
  • Refactored Contract Implementations: Updated the lib.rs for escrow, milestones, and maintenance-pool to use the parameterized mergefi-common implementations. The original wrapper functions are kept as transparent pass-throughs to minimize diff noise and cleanly integrate without breaking local error mapping.
  • Cargo Updates: Registered mergefi-common in the workspace root and injected it as a dependency for all three contracts.

Verification

As mandated by the "proof of behavioral equivalence" requirements:

  • Zero Behavioral Drift: All 35 existing unit tests across the three contracts pass unmodified (cargo test --workspace).
  • API Equivalence: No contract-facing functions or invocation paths were altered. The extraction works natively with existing contract state.

Note on Sequencing

This PR provides the groundwork for the upcoming batch of security fixes (instance-storage-TTL, admin/treasury-rotation, and #11's fixed-threshold). Please merge this extraction first, so the subsequent fixes only have to be written against the shared mergefi-common implementations rather than duplicated three times.

@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

@ABEEGOLD is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

@chonilius

Copy link
Copy Markdown
Contributor

Good one

@chonilius
chonilius merged commit 8cd83c9 into MergeFi:main Aug 17, 2026
2 of 3 checks passed
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.

All three contracts: extend_ttl/require_admin are triplicated (byte-identical), unlike compute_split's already-tracked #16 extraction

2 participants