Merged
Conversation
…#2647) * Fix SEP-41 token decimal formatting in Blockaid asset diffs Blockaid returns SEP-41/Soroban token asset diffs with a different shape than classic assets (symbol/address/decimals instead of code/issuer). The previous code only handled NATIVE/ASSET types with hardcoded 7 decimals, causing incorrect amounts for SEP-41 tokens (e.g., displaying 0.00005 instead of 0.5 for a 3-decimal token). Remove the switch statement and extract code/issuer/decimals uniformly from all asset types, falling back to CLASSIC_ASSET_DECIMALS (7) when decimals is not present. * Update extension/src/popup/views/__tests__/SignTransaction.test.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Defensively skip asset diffs when Blockaid payload fields are unexpected types (#2648) * Initial plan * Skip asset diffs with non-string blockaid payload fields Use typeof narrowing instead of incorrect 'as string' casts. Skip entries entirely when code/issuer/address fields are not strings. Native XLM (asset_type=NATIVE) is allowed with empty issuer as expected. Add test for the defensive skipping behavior. Co-authored-by: aristidesstaffieri <6886006+aristidesstaffieri@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: aristidesstaffieri <6886006+aristidesstaffieri@users.noreply.github.com> * skips asset diffs row if asset decimals response if unexpected --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: aristidesstaffieri <6886006+aristidesstaffieri@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Sign Transaction popup to correctly render Blockaid asset diffs for SEP-41 (contract) tokens by using symbol/address/decimals, and adds tests to cover the updated rendering and validation behavior.
Changes:
- Update
AssetDiffsrendering to support SEP-41 asset diff fields and decimals. - Add unit tests for SEP-41 decimal formatting and for skipping malformed Blockaid payload fields.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| extension/src/popup/views/SignTransaction/index.tsx | Adjusts asset diff parsing to support SEP-41 fields and apply per-asset decimals when formatting amounts. |
| extension/src/popup/views/tests/SignTransaction.test.tsx | Adds tests verifying SEP-41 amount formatting and behavior when payload fields have unexpected types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Add Number.isInteger() check to decimals validation guard to reject non-integer values before they reach toFixed(). Fix mock structure in "skips asset diffs when decimals is not a valid number" test to place validation and request_id inside scanResult, matching other tests.
leofelix077
approved these changes
Mar 13, 2026
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.
#2647