feat: Adding tx hash in response if required#91
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe PR introduces an optional Changes
Sequence DiagramsequenceDiagram
participant Caller
participant Handler
participant Validation
participant Submit
participant Blockchain
Caller->>Handler: Request {returnTxHash: true}
Handler->>Validation: validateAndParseRequest
Validation-->>Handler: ChannelAccountsRequest {returnTxHash: true}
Handler->>Submit: submitWithFeeBumpAndWait {returnTxHash: true}
alt On-Chain Failure
Submit->>Blockchain: Submit transaction
Blockchain-->>Submit: Failure response
Submit-->>Handler: {status: 'failed', hash, error: {reason, resultCode, labUrl}}
else Timeout
Submit->>Blockchain: Submit & await response
Blockchain-->>Submit: Timeout
Submit-->>Handler: {status: 'pending', hash, transactionId}
else Success
Submit->>Blockchain: Submit & await confirmation
Blockchain-->>Submit: Confirmed
Submit-->>Handler: {status: 'confirmed', hash, transactionId}
end
Handler-->>Caller: ChannelsTransactionResponse with result/error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/plugin/handler.ts (1)
204-210: Consider clarifying the log message.The log message says "Extending lock for WAIT_TIMEOUT error" but this code path handles a successful pending response (not an error/exception). Consider updating the message to reflect that this is the non-throwing pending path.
📝 Suggested log message fix
if (ctx.returnTxHash && result.status === 'pending' && poolLock) { - console.log(`[channels] Extending lock for WAIT_TIMEOUT error`); + console.log(`[channels] Extending lock for pending transaction (returnTxHash enabled)`); await ctx.pool.extendLock(poolLock); poolLock = undefined; // skip release in finally }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/plugin/handler.ts` around lines 204 - 210, The current console.log message "[channels] Extending lock for WAIT_TIMEOUT error" is misleading because this branch handles a non-throwing pending response; update the log in the block that checks ctx.returnTxHash && result.status === 'pending' && poolLock to clearly state it's extending the lock for the converted pending (non-error) path — e.g., mention "pending response" or "converted WAIT_TIMEOUT to pending" — so anyone reading logs knows this is the non-exception flow before calling ctx.pool.extendLock(poolLock) and setting poolLock = undefined.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/plugin/handler.ts`:
- Around line 204-210: The current console.log message "[channels] Extending
lock for WAIT_TIMEOUT error" is misleading because this branch handles a
non-throwing pending response; update the log in the block that checks
ctx.returnTxHash && result.status === 'pending' && poolLock to clearly state
it's extending the lock for the converted pending (non-error) path — e.g.,
mention "pending response" or "converted WAIT_TIMEOUT to pending" — so anyone
reading logs knows this is the non-exception flow before calling
ctx.pool.extendLock(poolLock) and setting poolLock = undefined.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/client/types.tssrc/plugin/handler.tssrc/plugin/submit.tssrc/plugin/types.tssrc/plugin/validation.tstest/handler.sequence-cache.test.tstest/validation.test.ts
Summary by CodeRabbit
returnTxHashparameter to request transaction hashes be returned with API responses.