Repository navigation
refactor(app): split the transaction modal's copy and map errors by name - #427
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
The change introduces new cross-workspace test dependencies by importing helpers from app/src into app-lib tests, which increases coupling and undermines app-lib test isolation, so the helper logic should be inlined or moved into an app-lib-local test utility.
2 open issues
What changed in this PR
This pull request refactors the vault TransactionModal by moving action/status copy into dedicated modules and changing contract error handling from hard-coded numeric codes to generated error names resolved from client specs, with corresponding updates across hooks and tests.
Changes:
- Extracts modal copy into
app/src/components/vault/transactionCopy/*and centralizes status rendering via a singledescribeStatus. - Resolves and propagates contract failures as
{ code, name }, derivingnameat runtime from generated client specs (spec.errorCases()), and updates app-lib plumbing accordingly. - Splits/updates tests to validate copy and refusals using name-derived errors (with shared render/error helpers), while preserving existing exports and behavior (with noted copy fixes in the PR description).
| File | Summary |
|---|---|
| app/src/test/renderTransactionModal.tsx | Adds shared render helpers for TransactionModal-related test suites. |
| app/src/test/contractErrorCode.ts | Adds a test helper to derive numeric error codes from generated error tables by name. |
| app/src/pages/vaultRequests.ts | Updates imports/usage to align with extracted transaction copy. |
| app/src/pages/vaultRequests.test.ts | Updates tests to align with extracted transaction copy/constants. |
| app/src/pages/VaultPreview.test.tsx | Updates tests to construct/verify contract errors using name-derived codes. |
| app/src/hooks/useVaultPaused.test.ts | Updates contract-error fixtures/types to include optional error name. |
| app/src/hooks/useTokenSymbols.test.ts | Updates contract-error fixtures/types to include optional error name. |
| app/src/hooks/useSignPending.ts | Propagates {code, name} for refused simulations into signing pending state. |
| app/src/hooks/useSignPending.test.ts | Updates refused-simulation tests to expect {code, name} and derive codes by name. |
| app/src/hooks/useSharePosition.test.ts | Updates contract-error fixtures/types to include optional error name. |
| app/src/hooks/useRequestRedeem.test.ts | Updates refusal simulation strings/assertions to use name-derived codes and {code, name}. |
| app/src/hooks/useRequestDeposit.test.ts | Updates refusal simulation strings/assertions to use name-derived codes and {code, name}. |
| app/src/hooks/useOracleState.test.ts | Updates contract-error fixtures/types to include optional error name. |
| app/src/hooks/useNavPrice.ts | Switches “NoRecord”/error handling to key off error name rather than numeric code. |
| app/src/hooks/useNavPrice.test.ts | Updates NAV tests to derive “NoRecord” (and other) codes by error name. |
| app/src/hooks/useIsAllowed.test.ts | Updates contract-error fixtures/types to include optional error name. |
| app/src/hooks/useFund.test.ts | Updates refusal simulation strings/assertions to include {code, name} and name-derived codes. |
| app/src/hooks/useFulfillEpoch.test.ts | Updates refusal simulation strings/assertions to include {code, name} and name-derived codes. |
| app/src/hooks/useFinalizeWindDownRound.test.ts | Updates refusal simulation strings/assertions to include {code, name} and name-derived codes. |
| app/src/hooks/useDepositBalance.test.ts | Updates contract-error fixtures/types to include optional error name. |
| app/src/hooks/useDeployToCustodian.test.ts | Updates refusal simulation strings/assertions to include {code, name} and name-derived codes. |
| app/src/hooks/useCycleState.ts | Switches “NoRecord”/error handling to key off error name rather than numeric code. |
| app/src/hooks/useCycleState.test.ts | Updates oracle/cycle tests to derive codes by error name and include {code, name}. |
| app/src/hooks/useContractTransaction.ts | Refactors transaction failure parsing/typing to carry {code, name} for contract errors. |
| app/src/hooks/useContractTransaction.test.ts | Updates transaction failure tests to use name-derived codes and {code, name}. |
| app/src/hooks/useComplianceState.test.ts | Updates refusal simulation strings/assertions to use name-derived codes and {code, name}. |
| app/src/hooks/useCloseEpoch.test.ts | Updates refusal simulation strings/assertions to include {code, name} and name-derived codes. |
| app/src/hooks/useClaimWindDown.test.ts | Updates refusal simulation strings/assertions to include {code, name} and name-derived codes. |
| app/src/hooks/useClaimRedeem.test.ts | Updates refusal simulation strings/assertions to include {code, name} and name-derived codes. |
| app/src/hooks/useClaimDeposit.test.ts | Updates refusal simulation strings/assertions to include {code, name} and name-derived codes. |
| app/src/hooks/useCancelRedeem.test.ts | Updates refusal simulation strings/assertions to include {code, name} and name-derived codes. |
| app/src/hooks/useCancelDeposit.test.ts | Updates refusal simulation strings/assertions to include {code, name} and name-derived codes. |
| app/src/hooks/useAttest.test.ts | Updates refusal simulation strings/assertions to include {code, name} and name-derived codes. |
| app/src/hooks/useAdminTransaction.test.ts | Updates admin refusal scenarios to carry {code, name} and use name-derived codes. |
| app/src/hooks/useActivateWindDown.test.ts | Updates refusal simulation strings/assertions to include {code, name} and name-derived codes. |
| app/src/components/vault/transactionCopy/types.ts | Introduces shared types/models for transaction copy, statuses, and refusal mapping. |
| app/src/components/vault/transactionCopy/investorOutcomes.test.tsx | Adds/updates investor outcome copy tests under the new copy structure. |
| app/src/components/vault/transactionCopy/investor.ts | Adds investor action copy + refusal reasons keyed by error name. |
| app/src/components/vault/transactionCopy/investor.test.tsx | Adds/updates investor transaction copy and refusal mapping tests. |
| app/src/components/vault/transactionCopy/index.ts | Adds a dispatcher/entry point to describe transactions using the new copy modules. |
| app/src/components/vault/transactionCopy/governance.test.tsx | Adds/updates governance transaction copy and refusal mapping tests. |
| app/src/components/vault/transactionCopy/emergency.test.tsx | Adds/updates emergency transaction copy and refusal mapping tests. |
| app/src/components/vault/transactionCopy/describe.ts | Implements shared describeStatus and contract-failure description logic. |
| app/src/components/vault/transactionCopy/cycle.ts | Adds cycle/operator action copy + refusal reasons keyed by error name. |
| app/src/components/vault/transactionCopy/cycle.test.tsx | Adds/updates cycle transaction copy and refusal mapping tests. |
| app/src/components/vault/transactionCopy/configuration.test.tsx | Adds/updates configuration transaction copy and refusal mapping tests. |
| app/src/components/vault/transactionCopy/compliance.test.tsx | Adds/updates compliance transaction copy and refusal mapping tests. |
| app/src/components/vault/transactionCopy/admin.ts | Adds admin action copy + refusal reasons keyed by error name. |
| app-lib/readContract.ts | Updates contract-read error parsing to return {code, name} and resolve names from specs. |
| app-lib/readContract.test.ts | Updates readContract tests to reflect {code, name} error shapes and name-based behavior. |
| app-lib/multisig.ts | Updates multisig refusal plumbing/types to carry {code, name}. |
| app-lib/multisig.test.ts | Updates multisig tests to use name-derived codes and {code, name}. |
| app-lib/contracts.ts | Adds helper(s) for accessing generated specs used for error-name resolution. |
| app-lib/contractErrors.ts | Implements runtime error code→name resolution by aggregating generated client error cases. |
| app-lib/contractErrors.test.ts | Adds tests covering error-case aggregation and name resolution behavior. |
Review effort: Balanced
| import { | ||
| contractErrorCode, | ||
| simulationError, | ||
| } from "../app/src/test/contractErrorCode" |
| import { | ||
| contractErrorCode, | ||
| simulationError, | ||
| } from "../app/src/test/contractErrorCode" |
Contract errors are resolved at runtime from the error cases the generated clients carry, so failures expose the error's name next to its code. Tests derive codes from each client's error table by name. Refs #415
Per-action copy moves to transactionCopy/ as data read by one describeStatus, and contract errors match by name. The modal tests are split by section. Fixes AdminTransferPending for the vault and oracle, and pause errors no longer show on oracle actions. Closes #415
9bc2c4d to
080b1a3
Compare

Summary
Closes #415
TransactionModal.tsxheld every action's copy as hand-writtenswitches over raw contract error numbers. Copy is now data, and contract errors match by the name the generated clients carry. Stacked on #421: it needs the real clients in tests.Changes
spec.errorCases(); no code→name table in the app.describeStatusturns a status into heading and body for every action; per-action copy is data, split by investor, cycle and admin.TransactionModal.tsxgoes from 2,158 to 239 lines.AdminTransferPendingnow shows its hand-over message for the vault and oracle too; "already paused" andExpectedPausecopy no longer show on oracle actions.Acceptance criteria
describeStatushandles the sixTransactionStatuscases for every action.TransactionModal.tsx, split by investor, cycle and admin actions.TransactionModal.tsxis under 300 lines.AdminTransferPendingand oracle pause fixes above.ADMIN_VERBS,ShareLinkand the exported modal types keep their exports.Test plan
Automated tests
stellar contract build && npm run build:clients, thennpm run typecheck,npm run lint,npm run format:check,npx vitest run: all pass (2,291 tests).it, 27it.each, 413expectbefore and after the split; no asserted string changed.Manual verification
/sign).Breaking changes
None.
Checklist
Screenshots
None.