Skip to content

feat(app): let the investor cancel a subscription - #168

Open
luchobonatti wants to merge 4 commits into
feat/86-refuse-and-cancelfrom
feat/86-cancel-a-request
Open

luchobonatti wants to merge 4 commits into
feat/86-refuse-and-cancelfrom
feat/86-cancel-a-request

Conversation

@luchobonatti

Copy link
Copy Markdown
Member

Summary

Closes #86

An investor who subscribed had no way back. Cancel returns the deposit in one transaction.

Third of three stacked PRs, based on #166.

Criterion 5 met differently: the app does not replicate !wind_down::is_active(e) && epoch::is_priceable(...) (deposit.rs:143). Cancel is offered on any unfulfilled subscription, and the contract refuses the rest at simulation, before the wallet opens.

Changes

  • Cancel returns the deposit and refreshes the balance and the list
  • Cancel's refusals are its own; they share no error code with subscribing
  • A paused vault still cancels
  • One transaction flow serves both actions

Acceptance criteria

  • The request is refused when the investor is not allowlisted, when requests are paused, and when a request is already open on either side
  • Each refusal is shown before the investor signs, not after
  • The escrowed amount is visible while pending
  • Cancel returns the full amount in one transaction
  • Cancel is offered while pending and gone once priced

Test plan

Automated tests

npm run test — 372 passing, up from 336 on #166. Covers cancel through every state, its error codes, a declined signature, a pre-signature failure, and the refresh on confirmation.

The refactor changed no test: the same 369 passed before and after, untouched.

Cancelling one request while another is in flight starts the second rather than replaying the first: the reattach now matches the submission actually running.

Manual verification

Local network, seeded with npm run deploy -w scripts/harness then npm run test:happy-path:

  1. Subscribe, then cancel from the waiting request: deposit back in the balance, request gone
  2. Attest a price, then cancel: refusal shown, no wallet prompt
  3. Pause the vault, then cancel: goes through

Breaking changes

None.

Checklist

  • Self-reviewed my own diff
  • Tests added or updated
  • Docs updated (if applicable)
  • No unrelated changes bundled in

Screenshots

None.

Copilot AI lite review requested due to automatic review settings September 25, 2026 16:16
@vercel

vercel Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
strata-vault-kit-app Ready Ready Preview Sep 25, 2026 4:43pm UTC

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

ActionPanel.tsx uses messageBlock.reason where messageBlock is typed as possibly undefined, which is likely to break TypeScript type-checking under strict null checks.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Adds an investor-facing cancellation flow for pending subscription (deposit) requests in the app, reusing a shared contract-transaction state machine and updating the UI to gate subscription actions before the wallet opens.

Changes:

  • Add “Cancel” as an action for waiting deposit requests and wire it to a new cancel_deposit transaction flow.
  • Introduce a reusable useContractTransaction hook and update request deposit to use it; unify subscribe/cancel UX under TransactionModal.
  • Add pre-signature subscription gating based on vault pause state and “open subscription in current batch”.
File Description
app/​src/​pages/​vaultRequests.ts Adds optional Cancel action for waiting deposit request entries.
app/​src/​pages/​vaultRequests.test.ts Tests for Cancel action presence and correct handler invocation.
app/​src/​pages/​VaultPreview.tsx Wires cancel flow into UI; uses pause + open-subscription gating; uses TransactionModal.
app/​src/​pages/​VaultPreview.test.tsx Adds/updates integration tests for pause gating, duplicate prevention, and cancel behavior.
app/​src/​pages/​vaultAccess.ts Adds subscribe-side gating (SubscribeGate) and isSubscriptionOpen; enriches message blocks with sides.
app/​src/​pages/​vaultAccess.test.ts Covers new gating behavior and isSubscriptionOpen logic.
app/​src/​hooks/​useVaultPaused.ts New query hook to read vault paused state.
app/​src/​hooks/​useVaultPaused.test.ts Unit tests for pause-state classification.
app/​src/​hooks/​useRequestDeposit.ts Refactors subscribe request hook to use useContractTransaction.
app/​src/​hooks/​useContractTransaction.ts New shared transaction hook handling simulation refusal, submission lifecycle, and cache invalidation.
app/​src/​hooks/​useCancelDeposit.ts New cancel-deposit hook built on useContractTransaction.
app/​src/​hooks/​useCancelDeposit.test.ts Thorough lifecycle and edge-case tests for cancel-deposit transactions.
app/​src/​components/​vault/​TransactionModal.tsx Extends modal to support both subscribe and cancel flows with appropriate copy and error mapping.
app/​src/​components/​vault/​TransactionModal.test.tsx Adds cancel-modal coverage and updates subscribe-modal tests to use TransactionModal.
app/​src/​components/​vault/​TransactionModal.module.css New styles for the unified transaction modal.
app/​src/​components/​vault/​ActionPanel.tsx Adds per-side message blocking via sides and keeps opposite tab reachable when only one side is blocked.
app/​src/​components/​vault/​ActionPanel.test.tsx Tests for both-sides vs single-side message behavior.
app-lib/​contracts.ts Extends AsyncVaultApi with paused: Call<boolean>.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/src/components/vault/ActionPanel.tsx

This branch was successfully deployed

1 active deployment
Preview — 43a8fe78 Deployed Sep 25, 2026 by vercel[bot]
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.

Create and cancel a subscription request

2 participants