Skip to content

feat: implement member contribution modal (Closes #12) - #15

Open
danielalanbates wants to merge 1 commit into
coopfinance:mainfrom
danielalanbates:fix/issue-12
Open

feat: implement member contribution modal (Closes #12)#15
danielalanbates wants to merge 1 commit into
coopfinance:mainfrom
danielalanbates:fix/issue-12

Conversation

@danielalanbates

Copy link
Copy Markdown

Closes #12

Adds src/components/groups/contribute-modal.tsx — the full member contribution flow against TreasuryContract.contribute(member, amount, period).

What

  • Amount input validated against group.rules.minContribution
  • Period selector auto-populated with current cycle (derived from createdAt + contributionPeriodDays), editable
  • Wallet USDC balance shown before submit (SAC balance(Address) simulation; configurable via NEXT_PUBLIC_USDC_CONTRACT_ID or usdcContractId prop)
  • Real Soroban tx: TransactionBuilderserver.prepareTransaction (auth/footprint) → useWallet().signTransactionserver.sendTransaction → poll server.getTransaction until SUCCESS/FAILED/timeout
  • All states handled: idle / signing / pending / success / error with spinners and inline errors
  • Success view: tx hash + Stellar Expert link (network-aware)
  • Invalidates ["groups"], ["group", id], ["contributions", id] React Query keys so balances & history refresh

Notes

  • Uses existing useWallet, server, networkPassphrase, parseAmount, formatAmount, simulateContractCall helpers — no new infra.
  • Strict TS, no any.

This PR was created with the assistance of Claude Sonnet 4.5 by Anthropic. Happy to make any adjustments!

Adds src/components/groups/contribute-modal.tsx implementing the full
member contribution flow against TreasuryContract.contribute():

- Amount input validated against group.rules.minContribution
- Period selector auto-populated from current cycle, editable
- Wallet USDC balance displayed before submission (via SAC balance sim)
- Builds a real Soroban transaction, prepares (sim + auth footprint),
  signs via useWallet().signTransaction, submits with
  SorobanRpc.Server.sendTransaction, then polls getTransaction
- Handles all states: idle / signing / pending / success / error
- Shows tx hash with Stellar Expert explorer link on success
- Invalidates groups / group / contributions React Query keys on success

Closes coopfinance#12
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.

[Frontend] Implement member contribution form on the group detail page

1 participant