Skip to content

feat(app): refuse a subscription before the investor signs - #166

Open
luchobonatti wants to merge 2 commits into
mainfrom
feat/86-refuse-and-cancel
Open

luchobonatti wants to merge 2 commits into
mainfrom
feat/86-refuse-and-cancel

Conversation

@luchobonatti

Copy link
Copy Markdown
Member

Summary

Refs #86

Subscribing while paused, or with a request already open, failed only after the wallet opened. Both refusals now show before anything is pressed.

Second of three stacked PRs, based on #162. Cancel closes #86 in the third.

Criterion 1 is met differently: the contracts check only their own side, so an open redemption does not block a subscription.

Changes

  • A paused vault replaces the Subscribe form with the reason
  • An open subscription in the batch is named, not refused after signing
  • Blocking subscribe keeps the Redeem tab: a paused vault still takes redemptions

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

Last three: third PR.

Test plan

Automated tests

npm run test — 336 passing, up from 314 on #162. Covers the pause read in all four states, an open subscription, refusal precedence, and the Redeem tab surviving a blocked subscribe.

Manual verification

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

  1. Subscribe as an allowlisted investor
  2. Press Subscribe again: reason shown, no wallet prompt
  3. Pause the vault, reload: form replaced with the pause reason
  4. Switch to Redeem while paused: form is there, chain accepts

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 12:30
@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

The PR description’s “either side” open-request refusal does not match the implemented subscription-only check, and two user-facing blocks reference “subscribe” while blocking both tabs.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

This PR updates the vault action UX so “Subscribe” is blocked before the wallet signing step when the vault is paused or when the investor already has an open subscription in the current epoch, while keeping the “Redeem” tab reachable when only subscribing is blocked.

Changes:

  • Adds a useVaultPaused React Query hook to read the AsyncVault’s paused() state and classify it for UI gating.
  • Introduces subscribe-specific gating in vaultAccess (pause state + open-subscription detection) and threads it into VaultPreview.
  • Extends ActionPanel message-blocking to be scoping-aware (sides: ["subscribe"] | ["redeem"] | both) and expands test coverage across the new states.
File Description
app/​src/​pages/​VaultPreview.tsx Wires pause/open-subscription gating into the panel block resolution.
app/​src/​pages/​VaultPreview.test.tsx Adds integration tests for paused vault behavior and open-subscription pre-sign blocking.
app/​src/​pages/​vaultAccess.ts Adds subscribe gate logic, isSubscriptionOpen, and message-block scoping via sides.
app/​src/​pages/​vaultAccess.test.ts Adds unit coverage for subscribe gate precedence, scoping, and isSubscriptionOpen.
app/​src/​hooks/​useVaultPaused.ts New hook for reading/classifying the vault pause state via paused().
app/​src/​hooks/​useVaultPaused.test.ts Unit tests for pause-state classification behavior.
app/​src/​components/​vault/​ActionPanel.tsx Adds side-scoped message blocking so only the relevant tab is blocked.
app/​src/​components/​vault/​ActionPanel.test.tsx Tests for “both-sides” vs “single-side” message blocking behavior.
app-lib/​contracts.ts Extends AsyncVaultApi typing to include paused: Call<boolean>.

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

Comment on lines +132 to +137
export function isSubscriptionOpen(requests: InvestorRequestsRead): boolean {
if (requests.status !== "loaded") return false
return requests.requests.some(
(request) =>
request.side === "deposit" && request.epochStatus.tag === "Open",
)
Comment on lines 107 to 112
case "checking":
return {
kind: "message",
reason: "Checking whether this address may subscribe.",
sides: ["subscribe", "redeem"],
}
Base automatically changed from feat/86-subscribe-and-cancel to main September 25, 2026 15:04
@hpmaxi
hpmaxi force-pushed the feat/86-refuse-and-cancel branch from 4c664f0 to 9fdff37 Compare September 25, 2026 15:04

This branch was successfully deployed

1 active deployment
Preview — 9483b1f5 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