The ERC-20 calldata decoder lives in the TxApproval view, not in a module under src/shared/ #759

Closed
opened 2026-11-10 20:54:18 +01:00 by clawbot · 1 comment
Collaborator

decodeCalldata(), the decoder for ERC-20 approve and transfer calldata that also hands Uniswap calldata to src/shared/uniswap.js, lives in the TxApproval view, src/popup/views/approval.js. TransactionDetail (src/popup/views/transactionDetail.js) and four test files import it from that view.

The rule: RULES.md Transaction Decoding, "Decoders are self-contained modules in src/shared/". sneak's README.md text: "The decoders live in self-contained modules under src/shared/ (e.g. uniswap.js) so they can be added for common contracts without polluting wallet-specific code."

Found in the RULES.md read on #672 (comment).

Fix

  • New module src/shared/calldataDecoder.js holds decodeCalldata() and the helpers only it uses. approval.js, transactionDetail.js and the tests import it from there.
  • The module imports nothing from src/popup/, as uniswap.js does not: it returns data, and the views turn addresses into HTML. Where the decoder builds address HTML today (approvalAddressHtml()), move that rendering to the views.
  • A helper the rest of approval.js also uses (tokenAmountText()) lives in one place and is imported by the other; nothing is copied.
  • What the approval and TransactionDetail screens show does not change.
  • README.md: the module list and the transaction decoding section name the new file.

Definition of done

  • decodeCalldata is defined only in src/shared/calldataDecoder.js, and nothing under src/shared/ requires a file under src/popup/.
  • Existing decoder and approval tests pass unchanged apart from their import path.
  • make check green. Gate runs: flock -w 3600 /srv/code/tmp/.autistmask-gate.lock script/cibuild.

Model: opus-5-5

`decodeCalldata()`, the decoder for ERC-20 `approve` and `transfer` calldata that also hands Uniswap calldata to `src/shared/uniswap.js`, lives in the TxApproval view, `src/popup/views/approval.js`. TransactionDetail (`src/popup/views/transactionDetail.js`) and four test files import it from that view. The rule: `RULES.md` Transaction Decoding, "Decoders are self-contained modules in `src/shared/`". sneak's `README.md` text: "The decoders live in self-contained modules under `src/shared/` (e.g. `uniswap.js`) so they can be added for common contracts without polluting wallet-specific code." Found in the `RULES.md` read on https://git.eeqj.de/sneak/AutistMask/issues/672#issuecomment-160312. ## Fix - New module `src/shared/calldataDecoder.js` holds `decodeCalldata()` and the helpers only it uses. `approval.js`, `transactionDetail.js` and the tests import it from there. - The module imports nothing from `src/popup/`, as `uniswap.js` does not: it returns data, and the views turn addresses into HTML. Where the decoder builds address HTML today (`approvalAddressHtml()`), move that rendering to the views. - A helper the rest of `approval.js` also uses (`tokenAmountText()`) lives in one place and is imported by the other; nothing is copied. - What the approval and TransactionDetail screens show does not change. - `README.md`: the module list and the transaction decoding section name the new file. ## Definition of done - `decodeCalldata` is defined only in `src/shared/calldataDecoder.js`, and nothing under `src/shared/` requires a file under `src/popup/`. - Existing decoder and approval tests pass unchanged apart from their import path. - `make check` green. Gate runs: `flock -w 3600 /srv/code/tmp/.autistmask-gate.lock script/cibuild`. Model: opus-5-5
clawbot self-assigned this 2026-11-10 20:54:18 +01:00
clawbot added this to the 1.0.0 milestone 2026-11-10 20:54:24 +01:00
Author
Collaborator

Built in #765.

  • decodeCalldata() and tokenAmountText() are now in src/shared/calldataDecoder.js.
  • tokenSourcesByChainId() moved from the popup view helpers to src/shared/state.js, so the decoder requires nothing under src/popup/.
  • The issue says the decoder renders addresses through approvalAddressHtml(). It never did: that function was already in the view and stays there.

Model: opus-5-5

Built in https://git.eeqj.de/sneak/AutistMask/pulls/765. - `decodeCalldata()` and `tokenAmountText()` are now in `src/shared/calldataDecoder.js`. - `tokenSourcesByChainId()` moved from the popup view helpers to `src/shared/state.js`, so the decoder requires nothing under `src/popup/`. - The issue says the decoder renders addresses through `approvalAddressHtml()`. It never did: that function was already in the view and stays there. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#759