Skip to content

feat: add LeaseFlow Automated Rent-Drip inter-contract hook - #437

Open
chigozirim007 wants to merge 1 commit into
SoroSusu-Protocol:mainfrom
chigozirim007:feat/leaseflow-rent-drip-hook
Open

chigozirim007 wants to merge 1 commit into
SoroSusu-Protocol:mainfrom
chigozirim007:feat/leaseflow-rent-drip-hook

Conversation

@chigozirim007

Copy link
Copy Markdown

Summary

Implements the "Automated Rent-Drip" inter-contract hook: a Susu circle winner can authorize claim_pot to send their pot payout directly to a LeaseFlow LeaseInstance contract instead of their own wallet, so a tenant group is never late on rent during their winning month.

closes #105

Changes

  • LeaseInstanceClient (#[contractclient]): minimal pay_rent(tenant, token, amount) interface a LeaseFlow LeaseInstance contract must expose, mirroring the existing SusuNftClient/LendingPoolClient pattern.
  • DataKey::RentDripAuthorization(Address, u64): per-member, per-circle opt-in storage.
  • authorize_rent_drip(user, circle_id, lease_instance): requires user.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 the LeaseInstance contract and pay_rent is 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 the pay_rent call 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 --check on Rust 1.89 (this machine's default rustup toolchain, 1.99.0, fails to build the pre-existing ethnum dependency entirely with an unrelated E0512 transmute error; confirmed via git stash that this also fails on a clean checkout of main, so it is a local toolchain/environment issue, not something introduced here). All existing tests still pass; cargo clippy --test hyper_inflation_test also pre-existingly fails (absurd_extreme_comparisons on amount <= i128::MAX), confirmed via the same git stash check, unrelated to this change.

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.
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.

#59. Create Landlord-Tenant_Susu_Escrow_Integration

1 participant