fix(query cctx): show when a CCTX was aborted unsuccessfully#431
Conversation
📝 WalkthroughWalkthroughAdds Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/commands/src/query/cctx.ts (1)
255-268: Handle Aborted tri‑state explicitly (success/failed/unknown).When isAbortRefunded is undefined, statusMessage stays “Unknown” but statusIcon is ✅, which is misleading.
Apply:
- const isAborted = status === "Aborted" && isAbortRefunded === true; - const isAbortFailed = status === "Aborted" && isAbortRefunded === false; + const hasAbort = status === "Aborted"; + const isAborted = hasAbort && isAbortRefunded === true; + const isAbortFailed = hasAbort && isAbortRefunded === false; + const isAbortUnknown = hasAbort && isAbortRefunded == null; - - const statusIcon = isPendingRevert ? "🔄" : "✅"; + const statusIcon = isPendingRevert ? "🔄" : (isAbortFailed ? "❌" : (isAborted ? "✅" : (isAbortUnknown ? "❓" : "✅"))); @@ - } else if (isAbortFailed) { + } else if (isAbortFailed) { statusMessage = "Abort failed"; + } else if (isAbortUnknown) { + statusMessage = "Abort status unknown"; }
🧹 Nitpick comments (5)
types/trackCCTX.types.ts (1)
58-68: Align abort fields and document intent.You’ve added abort_message but the CLI prints error_message_abort and never surfaces abort_message. This can confuse readers/operators.
- Add a brief doc on how abort_message differs from error_message_abort.
- Either render abort_message in the CLI (preferred) or remove it to avoid duplication.
packages/commands/src/query/cctx.ts (4)
181-188: Default abort/revert error fields and include abort_message.Prevent “undefined” in output and surface the new field.
Apply:
- const { - status, - status_message, - isAbortRefunded, - error_message = "", - error_message_abort, - error_message_revert, - } = cctx_status; + const { + status, + status_message, + isAbortRefunded, + error_message = "", + error_message_abort = "-", + error_message_revert = "-", + abort_message = "-", + } = cctx_status;
275-278: Improve revert message decoding (UTF‑8 first, hex fallback).Hex is less readable for typical Error(string) reverts. Try UTF‑8, fallback to hex.
Apply within the same scope:
- const revertMessage = revert_message - ? Buffer.from(revert_message, "base64").toString("hex") - : "-"; + const revertMessage = (() => { + if (!revert_message) return "-"; + const buf = Buffer.from(revert_message, "base64"); + const utf8 = buf.toString("utf8"); + // Heuristic: if UTF‑8 has many replacement chars or non‑printables, show hex + const printable = /[\x20-\x7E\s]/.test(utf8); + return printable ? utf8 : `0x${buf.toString("hex")}`; + })();Optionally extract a helper if reused later.
283-286: Use distinct icon for Abort success vs unknown.For unknown, prefer “❓” to avoid implying success.
Apply:
- } else if (isAbortFailed) { - chainDetails = `${receiver_chainId} ❌ ${statusMessage}`; + } else if (isAbortFailed) { + chainDetails = `${receiver_chainId} ❌ ${statusMessage}`; + } else if (isAbortUnknown) { + chainDetails = `${receiver_chainId} ❓ ${statusMessage}`; }
290-297: Render the new abort_message alongside reasons.Expose abort_message to operators.
Apply:
let revertOrAbortTx = ` ${chainDetails} Reason for revert: ${error_message_revert} Reason for abort: ${error_message_abort} +Abort Message: ${abort_message} Revert Address: ${revertAddress} Call on Revert: ${call_on_revert} Abort Address: ${abort_address} Revert Message: ${revertMessage} Revert Gas Limit: ${revert_gas_limit} `;
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/commands/src/query/cctx.ts(4 hunks)types/trackCCTX.types.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: fadeev
PR: zeta-chain/toolkit#346
File: packages/commands/src/ton/depositAndCall.ts:0-0
Timestamp: 2025-06-13T15:33:54.781Z
Learning: fadeev prefers responses in English.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/commands/src/query/cctx.ts (1)
180-186: Guard outbound_params[0] to avoid runtime crash.formatCCTX destructures outbound_params[0] unconditionally. If empty, this throws.
- Is outbound_params guaranteed to have index 0 for all statuses?
- If not, add a guard:
- const { receiver_chainId, receiver } = outbound_params[0]; + const firstOutbound = outbound_params[0]; + const receiver_chainId = firstOutbound?.receiver_chainId ?? "-"; + const receiver = firstOutbound?.receiver ?? "-";
Summary by CodeRabbit
Release Notes
New Features
Improvements