Fix pending recovery and liquidation request handling - #14
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (13)
📝 WalkthroughWalkthroughThis PR enhances vault transaction handling by improving confirmation flow with chain fallback guards, refactoring liquidation execution to support vault history selection and transaction ID normalization, integrating pending transaction reconciliation into the main cycle, and adding UI improvements to the vault input screen. The changes span contexts, services, hooks, and utilities with supporting test coverage and error pattern expansion. ChangesVault Operations & Transaction Handling
Sequence Diagram(s)sequenceDiagram
participant VaultProvider
participant useVaultDataFetch
participant PendingTxStore
participant ChainConfirmation
VaultProvider->>useVaultDataFetch: Destructure vault data, transactions, fetch functions
VaultProvider->>PendingTxStore: Check pending vault transaction
VaultProvider->>VaultProvider: Compute pending tx confirmation key
VaultProvider->>VaultProvider: Derive isInHistory, isApplied from vault data
alt Transaction Applied or In History
VaultProvider->>PendingTxStore: Clear pending transaction immediately
alt Confirmation source is 'chain'
VaultProvider->>useVaultDataFetch: Async refresh vault state
VaultProvider->>useVaultDataFetch: Async refresh vault transactions
end
else No Confirmation Yet
VaultProvider->>ChainConfirmation: Guard check (key differs from ref)
ChainConfirmation->>ChainConfirmation: Query on-chain confirmation
ChainConfirmation->>PendingTxStore: Clear on confirmation
end
flowchart
FetchHistory["Fetch Vault History with vaultId"]
SelectLatest["selectLatestUsableVaultHistoryTransaction"]
ComputePrevout["Compute prevout from selected tx"]
ResolveUnspent["resolveLatestUnspentVaultPrevout"]
BuildProfile["buildVaultProfile with resolved prevout"]
NormalizeRepoRequest["normalizeRepoRequestTxids<br/>(derive liquid_*/vault_* fields)"]
AssertConsistent["assertRepoRequestTxidsConsistent<br/>(validate PSBT-hex-txid)"]
SubmitGuardian["Submit to Guardian"]
FetchHistory --> SelectLatest
SelectLatest --> ComputePrevout
ComputePrevout --> ResolveUnspent
ResolveUnspent --> BuildProfile
BuildProfile --> NormalizeRepoRequest
NormalizeRepoRequest --> AssertConsistent
AssertConsistent --> SubmitGuardian
sequenceDiagram
participant runCycle
participant PendingTxStore
participant ExplorerAPI
participant ConfirmTx
runCycle->>PendingTxStore: Get pending transaction ids
runCycle->>ExplorerAPI: reconcileConfirmedPendingTransactions
loop For each pending txid
ExplorerAPI->>ExplorerAPI: getWithRetry(getTxApiUrl(txid))
alt Explorer confirms: confirmed=true
ExplorerAPI->>ConfirmTx: confirmTransaction(txid)
ExplorerAPI->>ExplorerAPI: Count confirmed++
else Explorer not confirmed or error
ExplorerAPI->>ExplorerAPI: Count pending++ or errors++
end
end
ExplorerAPI-->>runCycle: PendingTransactionReconciliationResult
runCycle->>runCycle: Compute pendingTransactionsChanged
alt pendingTransactionsChanged
runCycle->>runCycle: Queue transaction-history refresh only
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Summary
Validation
git diff --cached --checkpassedSummary by CodeRabbit
Bug Fixes
New Features