fix(decoder): render array and tuple params element-wise in alerts - #382
Merged
Merged
Conversation
bytes32[] / address[] params fell through to str(), printing Python b'...' reprs and lowercase address tuples. A repr containing a backtick also closed the Telegram Markdown code span early, mangling the alert. Render arrays and tuples per element (bytes as hex, addresses checksummed), decode zero-padded ASCII bytes32 strings, and strip backticks from rendered values. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Route the non-bytes branches of bytes32/bytesN through the untyped renderer so no path skips backtick sanitization, test the tuple length-mismatch fallback, and document why single-character bytes32 values stay hex-only. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In the Infinifi Longtimelock alert (tx
0x86da39a4959d9dcebfdec6f9840db083f5a4474bbc9cbb49a064e1105283635f), thegrantRoles(bytes32[],address[])call showed its parameters as raw Python values:_format_param_valueonly handled single values, so arrays and tuples were printed withstr(). On top of that, one role id'sb'...'form contains a backtick. That closed the Markdown code span early, so Telegram mangled the rest of the line (dropping the[]from the type) and could reject the whole message with a 400 "can't parse entities" error.Now:
(Shortened here; the alert shows the full values.)
T[],T[k]) and tuples ((a,b,…), including nested ones) are formatted element by element using each element's own type: bytes as0xhex, addresses checksummed.bytes32holding a short text string padded with zero bytes is also shown as that text, e.g.0x5553…00 ("USDC"). Hashes such as role ids stay hex only.b'...'form.Test plan
bytes32[](with the real role ids),address[], typed tuple arrays, bytes32 text decoding and the hash case, backtick safety, unknown-type bytesuv run pytest tests/(1388 passed),ruff check,ruff format🤖 Generated with Claude Code