Skip to content

feat(tx): block wrong network and account transactions (#925) - #990

Draft
s6pa1rta3n-lab wants to merge 1 commit into
Creditra:mainfrom
s6pa1rta3n-lab:fix-issue-925
Draft

s6pa1rta3n-lab wants to merge 1 commit into
Creditra:mainfrom
s6pa1rta3n-lab:fix-issue-925

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Summary

Resolves #925 by introducing transaction preflight validation, explicit network switching actions, confirmation summaries, and account authority checks before transaction submission.

Changes

  • Preflight Types & Validation (src/types/transactionPreflight.ts, src/utils/transactionPreflight.ts):
    • Added pure normalization and validation utilities for network names and account public keys.
    • Implemented evaluatePreflight() returning status (ready, wrong_network, wrong_account, not_connected, stale_account), specific error messages, and signing readiness flag.
  • Hook Layer (src/hooks/useTransactionPreflight.ts):
    • Created useTransactionPreflight managing live wallet status, preflight states, explicit network switching, identity drift detection, and safe execution (executeSafeSubmit).
    • Guarantees network switch failures never auto-submit transactions.
  • Accessible UI Components (src/components/TransactionConfirmationSummary.tsx, src/components/TransactionPreflightGuard.tsx, src/components/TransactionPreflightGuard.css):
    • Render confirmation summary with explicit network and account match badges.
    • Render accessible switch network action buttons and error banners.
    • Add identity change warning and explicit acknowledgement actions when wallet changes mid-flow.
  • Modal & Flow Integration:
    • Integrated preflight checks and confirmation summaries into RepayModal.tsx, QuickRepayModal.tsx, RepayPreviewModal.tsx, and AmountConfirm.tsx.
    • Block confirmation buttons when preflight criteria are not met (canSign is false or isSwitching is true).
    • Execute preflight re-evaluation at submission time to eliminate race conditions.

Acceptance Criteria Verification

  • Wrong network blocks signing.
  • Expected account is compared with connected account.
  • Switch failures do not auto-submit.
  • Tests cover disconnect, switch, and stale account state.
  • Unit and integration test suites passing (71 tests across 8 test files).
  • Production build passes with zero errors.

Payout Routing

  • EVM (Base/Arbitrum/Polygon/ETH): 0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89
  • Stellar: GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC

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.

[GrantFox][High] Block wrong network and account transactions

1 participant