Skip to content

[Feature] Add self-service "leave pool" function for non-admin members #140

Description

@grantfox-oss

Getting Started

  1. Fork the repository: https://github.com/JointSave-org/Joint_Save
  2. Clone your fork:
   git clone https://github.com/<your-username>/Joint_Save.git
   cd Joint_Save
  1. Create a new branch:
   git checkout -b feat/self-service-leave-pool

Overview

Checked all three pool contracts and confirmed remove_member exists everywhere, but always requires admin.require_auth() — there's no equivalent function a regular member can call themselves to leave a pool. Right now, the only way to exit a pool is to ask the admin to remove you, which is awkward and puts unnecessary friction (and unnecessary trust) on a basic, expected action.

Requirements

Smart Contract Changes (all three pool types)

  • Add a leave_pool(env: Env, member: Address) function, requiring member.require_auth() (the member authorizes themselves, no admin involved)
  • For Rotational: should follow the same round-shifting logic already used by remove_member (don't duplicate the math — consider extracting a shared internal helper both functions call)
  • For Target: should only be allowed before the pool is unlocked, consistent with the existing remove_member restriction
  • For Flexible: should refund the member's balance, same as remove_member
  • Consider whether the current beneficiary in a Rotational pool should be allowed to leave mid-round, or whether that needs a restriction (discuss in the PR if you think a guard is needed)

Frontend Changes

  • Add a "Leave Pool" button in group-actions.tsx, visible only to non-admin members (i.e. hidden for the pool's own creator/admin, who should use a different flow if they want to step back)
  • Confirmation dialog before leaving, warning about any consequences (e.g. losing your spot in a rotational pool's order)

Acceptance Criteria

  • A non-admin member can call leave_pool and successfully exit without any admin involvement
  • Rotational round-shifting logic stays correct after a self-initiated leave (reuse/extract shared logic with remove_member rather than re-implementing it)
  • Flexible pool members are correctly refunded on leave
  • Frontend button only shows for non-admins
  • Unit tests covering the leave flow for all three pool types

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSOfficial CampaignCampaign: Official CampaignfeatureNew functionality to addhigh-complexityLarge scope, multiple systems/files. Needs planning

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions