refactor: extract compute_split into shared crate - #235
Open
KunmiWrites-bit wants to merge 16 commits into
Open
Conversation
|
@KunmiWrites-bit is attempting to deploy a commit to the chonilius' projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@KunmiWrites-bit Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR extracts the duplicated
compute_splitpayout/fee-math logic fromcontracts/escrow/src/lib.rsandcontracts/milestones/src/lib.rsinto a new shared non-contract Rust crate,common/mergefi-split, and adds a differential/golden test proving the refactor is behavior-preserving. Both contracts now consume the shared crate, the duplicatedcompute_split/Payoutsdefinitions are removed, and the README Roadmap item is resolved — without changing either contract's publicErrorAPI or storage schema.Related Issue
Closes the issue: Extract
compute_splitinto a shared crate with proof of behavioral equivalenceChanges
📦 Shared Split/Fee-Math Crate
[ADD]
common/mergefi-split/— new#![no_std]workspace crate with no#[contract]attributecompute_split/ payout-split / fee math extracted fromcontracts/escrow/src/lib.rs:211-254andcontracts/milestones/src/lib.rs:234-275.SplitErrorenum plusFromconversions into each contract's ownErrorenum, soescrowandmilestoneskeep their distinct#[contracterror]APIs.DataKey, avoiding a forced common storage abstraction.[MODIFY]
contracts/escrow/src/lib.rs,contracts/milestones/src/lib.rscompute_splitandPayoutsdefinitions; both contracts now callmergefi_split::compute_split.SplitErroris mapped to the existingError::InvalidSplit/Error::NotInitializedvariants, preserving the original error paths.[MODIFY] Root
Cargo.toml,contracts/escrow/Cargo.toml,contracts/milestones/Cargo.tomlcommon/mergefi-splitto[workspace] membersand as a dependency of both contract crates.[ADD] Differential/golden test in
common/mergefi-splitcompute_splitimplementations across a large randomized input set (fee-bps permutations, payee counts, duplicate addresses, dust/overflow edge cases).[MODIFY]
README.mdVerification Results
#![no_std], no#[contract]attributecommon/mergefi-splitis#![no_std]with no#[contract]— not a deployable contractescrowandmilestonesconsume the shared crate; duplicated code removedcompute_split/Payoutsdeleted from both contracts; both callmergefi_split::compute_splitcargo test --workspaceandmake build(wasm) green for all three contractsCloses #16