Skip to content

Harden Soroban debugger, event feed and screen; add tests - #1004

Open
nafiisatu wants to merge 1 commit into
Sorokit:mainfrom
nafiisatu:handsoff/issues-907-908-909-910-63804d
Open

nafiisatu wants to merge 1 commit into
Sorokit:mainfrom
nafiisatu:handsoff/issues-907-908-909-910-63804d

Conversation

@nafiisatu

Copy link
Copy Markdown

Closes #907, closes #908, closes #909, closes #910

#907: ContractInteractionDebugger: dark-mode diff contrast, capped history, replay

What changed

  • Readable diffs in both themes: Each changed field is now tagged Added, Removed or Changed (data-diff-kind). Each kind gets its own text, background and border colours from new --color-diff-* tokens in index.css and styles.css. Each token has a dark and a light value, picked for at least 4.5:1 text contrast.

  • JSON viewer colours: JsonView now gets a style object that keeps the library's default classes and adds sorokit-json-* classes on top. Those classes use new --color-json-* tokens. The library's own palette is meant for light backgrounds only, which is why its keys were unreadable on the dark surface.

  • Storage stays under the quota: The new compactForStorage() shrinks each history entry before it is saved:

    • byte buffers (ArrayBuffer and typed arrays) become a short [bytes: N] placeholder
    • strings are cut to 256 chars and arrays to 32 items
    • deep nesting is collapsed

    History is still limited to 10 entries. If saving still fails with a quota error, the oldest entries are dropped until it fits, so nothing throws. Note: this history lives in sessionStorage, not localStorage as the issue says.

  • Replay: A new onReplay?: (entry) => void prop adds a Replay button to each item under Recent invocations. SorobanPanel handles it by filling the form back in with the entry's contract ID, method and arguments, so the same call can be sent again.

Tests: in ContractInteractionDebugger.test.tsx, covering the diff-kind tagging, the JSON viewer classes, byte-buffer and string truncation, the 10-entry limit, no exception on a quota error, and the replay button (including that it is hidden when there is no handler).

#908: ContractEventFeed: unmount cleanup, readable topics, auto-scroll pause

What changed

  • Cleanup on unmount:
    • The timers that clear the "new event" highlight are now tracked and cleared on unmount.
    • The request counter is bumped on unmount, so a getEvents response that arrives later is ignored.
    • TopicTag's "copied" timer is cleared too.
    • The polling and clock intervals were already cleared; that is unchanged.
  • Readable topics: New src/lib/scval.ts, a small decoder for base64 XDR ScVal values with no new dependency (the package avoids SDK dependencies on purpose).
    • It handles Symbol, String, Bool, Void, U32/I32, U64/I64, Timepoint/Duration, U128/I128, Bytes and Address.
    • Addresses come out as G… or C… strings. For this, utils.ts now exports encodeAccountAddress and encodeContractAddress, built on its existing encoding helpers.
    • Input only counts as decoded if every byte is used. Anything that isn't valid XDR, such as a hex hash, is shown unchanged.
    • Topics show the decoded text and keep the raw XDR as a hover tooltip. The copy button now copies the decoded text.
  • Auto-scroll pause: The event list is now its own scroll area (max-h-[480px]).
    • It stays at the bottom while the user is within 24px of it.
    • When the user scrolls up, new events no longer move the list, and an "Auto-scroll paused · Jump to latest" button appears to resume.

Tests: in ContractEventFeed.test.tsx (topic decoding, copying the decoded value, non-XDR topics shown unchanged, no timers left after unmount, a late response ignored after unmount, following new events, and pausing/resuming auto-scroll). There are also decoder unit tests in src/lib/scval.test.ts.

#909: SorobanScreen: clear contract on network switch, delete icon, end-to-end test

What changed

  • Network switch: Soroban contract IDs are derived from the network passphrase, so a contract from one network can't exist on another. When network.name from useSorokit changes, the active contract is cleared. That also unmounts its event feed and resets the panel, so no cross-network RPC requests are sent. A warning that can be dismissed explains which contract was cleared and why.
    • The first time the network loads (going from null to a value) does not count as a switch, so a contract pre-filled from history is kept.
  • Delete saved contracts: Each saved contract chip now has a trash icon (Delete01Icon) instead of the plain "×". The aria-label is the same and it still removes the contract from storage.

Tests: in SorobanScreen.test.tsx: the contract is cleared with a warning on a network switch, kept on the first network load, no warning appears when no contract is active, and the warning can be dismissed. There is also an end-to-end test: pick a saved contract → load an ABI (method suggestions appear) → enter method and arguments and submit → result shown → open the debugger and see the simulation and gas breakdown.

#910: ContractInteractionBuilder: boundary, bool and Option tests

Only tests changed.

  • Integer boundaries: a test for each type's min and max (u32, i32, u64, i64, u128, i128), including u32::MAX, i64::MIN and u128::MAX. Each one checks that the exact digits show up both in the decoded call preview and in the onParamsReady args, with no rounding to a JS number. It also checks that 32/64-bit types use number inputs and 128-bit types use text inputs.
  • Bool: checks the option list ("", true, false), that Generate stays disabled until a value is picked, and that both values are passed through.
  • Option: checks how the input looks, that an unset value shows as empty and keeps Generate disabled, and that a value is passed through.
  • Timing: I found no setTimeout or other timing-based assertions in this file. Every new test is synchronous and uses no timers.

Testing

Per the task rules, I didn't run the builds, tests or linters. All changes were checked by reading the code only.

Closes #907
Closes #908
Closes #909
Closes #910

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@nafiisatu 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant