Skip to content

feat(cli): add inspect command for decoded entry values - #299

Merged
AbdulmalikAlayande merged 1 commit into
TegoLabs:mainfrom
Faizehy:feat/cli-inspect-command
Jun 30, 2026
Merged

AbdulmalikAlayande merged 1 commit into
TegoLabs:mainfrom
Faizehy:feat/cli-inspect-command

Conversation

@Faizehy

@Faizehy Faizehy commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

closes #155

@coderabbitai

coderabbitai Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added a clearer inspection output for raw contract data, including a JSON-formatted decoded value when available.
    • Expanded inspection support so more entry formats are accepted, including shorthand and encoded key forms.
    • Improved handling of contract lookup results, including clearer support for non-SAC contracts.
  • Bug Fixes

    • Updated inspection messages to better distinguish inactive keys from missing on-chain data.
    • Simplified missing-contract error text for more consistent guidance.

Walkthrough

Adds DecodedScVal type and decodeScVal/decodeScValRecursive functions to src/core/inspect.ts. Refactors SAC detection to derive isSac from the on-chain executableType, guards balance: entries for non-SAC contracts, and populates a decodedValue field on raw InspectEntryInfo results. Updates CLI output and adds comprehensive tests.

Changes

Inspect ScVal Decoding and Non-SAC Support

Layer / File(s) Summary
DecodedScVal type and decoder
src/core/inspect.ts
Exports DecodedScVal interface (type, value), extends InspectEntryInfo with optional decodedValue, and implements decodeScVal plus decodeScValRecursive covering all ScVal variants with error-shaped fallback.
inspectContract SAC detection and raw entry decoding
src/core/inspect.ts
Derives isSac from instance.executableType instead of a prior assumption; rejects balance: inputs when isSac is false; decodes valXdr into decodedValue for successful raw entries; propagates isSac in early and success returns.
CLI output updates
src/commands/inspect.ts
Revises command description and --entry hint text; replaces TTL-not-found branch with a !item.found error line; adds a pretty-printed JSON "Decoded Value" block for raw entries when decodedValue is present.
Tests
tests/core/inspect.test.ts
Adds decodeScVal suite covering all ScVal primitive and composite types plus invalid XDR; updates contract-not-found error substring; adds three inspectContract cases for raw decoding, inactive key, and empty entries on non-SAC contracts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • AbdulmalikAlayande/sorokeep#265: Shares the same src/core/inspect.ts inspection flow and SAC/balance:<address> CLI wiring that this PR refactors and extends.

Poem

🐇 Hop, hop through the XDR maze,
Each ScVal decoded in a JSON blaze!
Raw entries now whisper their secrets plain,
Non-SAC contracts join the inspect lane.
No more TTL ghosts — just "not on-chain" they say,
This rabbit decoded it all today! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding decoded entry value inspection to the CLI.
Description check ✅ Passed The description is brief but still related to the change by referencing the issue it closes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@Faizehy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/commands/inspect.ts`:
- Around line 62-64: The new inactive-key branch in inspect.ts is too late
because inspectContract already prints the synthetic zeroed balance details for
missing balance: entries, resulting in contradictory CLI output. Update the
inspect flow around the item rendering logic so inactive balance keys are
detected before any balance/authorized/clawback fields are printed, and skip the
synthetic balance output entirely when item.found is false or item.status is
unknown. Use the existing inspectContract result handling in inspect.ts to gate
the balance display and keep the inactive-key error message as the only output
for those cases.

In `@src/core/inspect.ts`:
- Around line 359-364: The default branch in `inspect.ts` can return native
values from `scValToNative(scVal)` that include BigInt, which later breaks
`JSON.stringify` in the inspect command. Normalize the value before returning it
from the decoder path in `inspect.ts` by converting any BigInt result to a
string, or otherwise ensure the returned `decodedValue` is JSON-safe. Use the
`scValToNative` call and the `value` assignment in the default case as the place
to apply the fix so `src/commands/inspect.ts` can render it without errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 021fc32e-2aca-4d55-aa5d-291961934911

📥 Commits

Reviewing files that changed from the base of the PR and between 156d642 and c4d3d38.

📒 Files selected for processing (3)
  • src/commands/inspect.ts
  • src/core/inspect.ts
  • tests/core/inspect.test.ts
📜 Review details
🔇 Additional comments (6)
tests/core/inspect.test.ts (1)

8-8: LGTM!

Also applies to: 103-198, 239-239, 313-425

src/core/inspect.ts (5)

16-20: LGTM!

Also applies to: 35-35


164-171: LGTM!

Also applies to: 181-181


191-197: LGTM!


269-272: LGTM!

Also applies to: 281-294


297-307: LGTM!

Comment thread src/commands/inspect.ts
Comment thread src/core/inspect.ts
@AbdulmalikAlayande
AbdulmalikAlayande merged commit 8acedb1 into TegoLabs:main Jun 30, 2026
3 checks passed
AbdulmalikAlayande pushed a commit that referenced this pull request Aug 2, 2026
Co-authored-by: Abdulazeem-code <olamilekanabdulazeem@gmail.com>
AbdulmalikAlayande pushed a commit that referenced this pull request Aug 2, 2026
Co-authored-by: Abdulazeem-code <olamilekanabdulazeem@gmail.com>
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.

feat(cli): add inspect command for decoded entry values

3 participants