Repository navigation
feat: add LeaseFlow Automated Rent-Drip inter-contract hook - #437
Open
chigozirim007 wants to merge 1 commit into
Open
chigozirim007 wants to merge 1 commit into
chigozirim007 wants to merge 1 commit into
Conversation
Lets a circle winner authorize claim_pot to send their pot payout straight to a LeaseFlow LeaseInstance contract instead of their own wallet, via authorize_rent_drip/revoke_rent_drip. Mirrors the existing SusuNftClient/LendingPoolClient contractclient pattern.
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.
Summary
Implements the "Automated Rent-Drip" inter-contract hook: a Susu circle winner can authorize
claim_potto send their pot payout directly to a LeaseFlowLeaseInstancecontract instead of their own wallet, so a tenant group is never late on rent during their winning month.closes #105
Changes
LeaseInstanceClient(#[contractclient]): minimalpay_rent(tenant, token, amount)interface a LeaseFlowLeaseInstancecontract must expose, mirroring the existingSusuNftClient/LendingPoolClientpattern.DataKey::RentDripAuthorization(Address, u64): per-member, per-circle opt-in storage.authorize_rent_drip(user, circle_id, lease_instance): requiresuser.require_auth()and that the caller is an existing member of that circle.revoke_rent_drip(user, circle_id): clears the authorization.claim_pot: if the winner has an active authorization for the circle, the pot is transferred to theLeaseInstancecontract andpay_rentis invoked on it, instead of transferring to the winner's own address. Unauthorized winners keep the existing direct-payout behavior unchanged.Test plan
New
tests/rent_drip_test.rs(5 tests, all passing):claim_pot_pays_the_winner_directly_without_authorization: baseline, unauthorized behavior unchanged.authorize_rent_drip_routes_the_payout_to_the_lease_instance: pot lands on the LeaseInstance contract, not the winner's wallet, and the mock LeaseInstance records thepay_rentcall with the right tenant/amount.revoke_rent_drip_restores_direct_payout_to_the_winner: revoking returns to direct payout.authorize_rent_drip_rejects_a_non_member/authorize_rent_drip_rejects_an_unknown_circle: auth guard failure modes.Ran with
cargo test/cargo clippy --all-targets/cargo fmt --checkon Rust 1.89 (this machine's defaultrustuptoolchain, 1.99.0, fails to build the pre-existingethnumdependency entirely with an unrelatedE0512transmute error; confirmed viagit stashthat this also fails on a clean checkout ofmain, so it is a local toolchain/environment issue, not something introduced here). All existing tests still pass;cargo clippy --test hyper_inflation_testalso pre-existingly fails (absurd_extreme_comparisonsonamount <= i128::MAX), confirmed via the samegit stashcheck, unrelated to this change.