fix(soroban): render signed SCMap entry on the signing screens - #3017
Draft
aristidesstaffieri wants to merge 1 commit into
Draft
aristidesstaffieri wants to merge 1 commit into
aristidesstaffieri wants to merge 1 commit into
Conversation
…oNative scValToNative decodes SCMaps through Object.fromEntries, which coerces every key via ToPropertyKey and applies last-write-wins, so a map with N signed entries could render as one on the approval screen — with no glyph and no warning. Render maps and vecs from the signed entry list instead, as a value literal where quoting carries the key type. Decode SCString/SCSymbol-backed fields (arguments, function names, CAP-85 executable tags) strictly rather than leniently, so invalid UTF-8 renders as labelled hex instead of collapsing distinct payloads onto one U+FFFD string. Carry auth-tree args through as ScVal rather than round tripping them through nativeToScVal, which silently re-typed map keys.
Contributor
|
PR Preview build is ready: https://github.com/stellar/freighter/releases/tag/untagged-28a85236081970aaaca9 |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Some distinct signed values remain ambiguous or incomplete in the approval UI.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 5
Open (6)
Prevent valid and invalid byte display collisions · New Distinguish null maps from empty maps · New Preserve SCVal types in rendered map keys · New Distinguish null vectors from empty vectors · New Render complete SCContractInstance payloads · New Preserve parameter indentation in the signing UI · New
What changed in this PR
Improves Soroban signing-screen rendering while preserving signed XDR value types.
Changes:
- Adds byte-safe rendering for Soroban strings, symbols, and tags.
- Renders maps and vectors without lossy native conversion.
- Adds helper and UI regression tests.
| File | Description |
|---|---|
| extension/src/popup/helpers/soroban.ts | Adds type-aware Soroban value rendering. |
| extension/src/popup/helpers/__tests__/soroban.test.js | Tests invocation fidelity and binary names. |
| extension/src/popup/helpers/__tests__/scValByType.test.js | Tests container and binary-value rendering. |
| extension/src/popup/components/signTransaction/Operations/KeyVal/index.tsx | Passes original SCVals to the renderer. |
| extension/src/popup/components/signTransaction/Operations/index.tsx | Uses safer function-name rendering. |
| extension/src/popup/components/signTransaction/Operations/__tests__/index.test.tsx | Tests rendered contract-call parameters. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+643
to
+646
| const decoded = value.asStringOrBytes(); | ||
| return typeof decoded === "string" | ||
| ? decoded | ||
| : `${kind}(0x${xdr.encodeBytes(decoded, "hex")})`; |
Comment on lines
+696
to
+699
| const entries = scVal.map || []; | ||
| if (!entries.length) { | ||
| return "{}"; | ||
| } |
Comment on lines
+700
to
+704
| const lines = entries.map( | ||
| (entry) => | ||
| `${scValToDisplayValue(entry.key, { | ||
| compact: true, | ||
| })}: ${scValToDisplayValue(entry.val, { |
Comment on lines
+715
to
+718
| const values = scVal.vec || []; | ||
| if (!values.length) { | ||
| return "[]"; | ||
| } |
Comment on lines
+755
to
+759
| case "scvContractInstance": { | ||
| const executable = scVal.instance.executable; | ||
| return executable.type === "contractExecutableWasm" | ||
| ? `contractInstance(0x${xdr.encodeBytes(executable.wasmHash.toBytes(), "hex")})` | ||
| : `contractInstance(${executable.type})`; |
Comment on lines
+709
to
+711
| return compact | ||
| ? `{ ${lines.join(", ")} }` | ||
| : `{\n${innerPad}${lines.join(`,\n${innerPad}`)}\n${pad}}`; |
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
Renders Soroban contract-call arguments on the signing screens from the signed
SCValrather than from a decoded native value, so the screen matches what is being signed. Three defects are fixed:SCMapwith N signed entries could render as one line — with no glyph and no warning. Maps now render from the signed entry list, so entry count is preserved by construction.u64(1)andstring("1"), orsymbol("a")andstring("a"), previously rendered as identical keys. Quoting now carries the type: strings quoted, symbols and numbers bare, structured keys inline.SCString,SCSymbol, function names and CAP-85 executable tags are decoded strictly instead of leniently, so two distinct non-UTF-8 payloads can no longer collapse onto the sameU+FFFDstring.All three hold at every nesting depth. Only a top-level argument was handled before: one level down a map collapsed, a non-UTF-8 string rendered as
{"0":97,"1":108,…}, and bytes as{"type":"Buffer","data":[…]}.Auth-entry invocation trees now carry
xdr.ScValargs through to the renderer instead of decoding to natives and re-encoding, a round trip that silently re-typed map keys.Affected surfaces:
SignTransaction(Parameters and Auth Entries),SignAuthEntry, and theReviewTransactionauth block.Display format change — map and vector parameters render as a value literal rather than JSON:
Test plan
yarn test:ci— 1929 passing, including 24 new cases: entry-count preservation for structured and mixed-type map keys, address- andu32-keyed controls, nested containers, and strict decoding of non-UTF-8 strings, symbols, executable tags and function namesyarn build:extension