Skip to content

fix(client): wire FundCampaignModal to real useFundCampaign - #218

Closed
shinzoxD wants to merge 1 commit into
Cylo-Traders:masterfrom
shinzoxD:fix/139-fund-campaign-real-mutation
Closed

fix(client): wire FundCampaignModal to real useFundCampaign#218
shinzoxD wants to merge 1 commit into
Cylo-Traders:masterfrom
shinzoxD:fix/139-fund-campaign-real-mutation

Conversation

@shinzoxD

Copy link
Copy Markdown

Summary

FundCampaignModal submitted through mocked campaignService.fundCampaign (setTimeout + Math.random hash) instead of the real escrow mutation. A user could see "Contribution Successful!" with a fake transaction hash without moving any tokens.

This PR:

  • Wires the modal to useFundCampaign() in hooks/contract/useEscrowMutations.ts
  • Uses useWallet().publicKey as the investor (drops the hardcoded GDF4...M9XZ default)
  • Prompts to connect when no wallet is connected and disables submit until then
  • Keeps client-side validateContribution (zero / negative / exceeds remaining target)
  • Parses amounts as whole-number bigint contract units (i128), matching create-campaign / admin forms
  • Removes the mock fundCampaign helper so it cannot be re-wired by a page
  • Leaves campaignService.ts in place for validation and ownership-share helpers still used by the modal

Success no longer invents a fake 0x transaction hash. Mutation toasts still come from useFundCampaign; inline errors use toUserFacingError.

Distinct from:

Closes #139

Test plan

  • Submit path mocks useFundCampaign and asserts { campaignId, investor, amount: 500n }
  • Invalid / over-target amounts never call the mutation
  • Disconnected wallet shows a connect prompt and disables submit
  • Success path does not render a fake 0x tx hash
  • Contract rejection surfaces a user-facing error
  • Existing FundCampaignModal accessibility tests still pass
  • campaignService validation tests converted to vitest (no fake hash assertions)
cd client
npx vitest run src/components/campaign/__tests__/FundCampaignModal.test.tsx src/__tests__/campaignService.test.ts src/__tests__/accessibility.test.tsx

20 passed.

GrantFox claim already posted. Wallet: GBVHELLD2JE235Y2NGTDT3MWI3T65ON6SY4N6FBHYVDAQ5FZC2CP5QXH

Replace mocked campaignService.fundCampaign (setTimeout + Math.random hash) with the ProductionEscrow fund_campaign mutation. Keep client-side validation, require a connected wallet, and parse amounts as bigint contract units. Success no longer invents a fake transaction hash.

Closes Cylo-Traders#139
Copilot AI lite review requested due to automatic review settings August 24, 2026 17:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@shinzoxD

Copy link
Copy Markdown
Author

Closing this PR. GrantFox assigned #139 to @Mosas2000 after I opened it — I won't compete with the assigned contributor.

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.

FundCampaignModal submits through a mocked service instead of the real useFundCampaign contract mutation

3 participants