fix: refuse an unsupported method with EIP-1193 code 4200 #421

Merged
clawbot merged 1 commits from issue-279-unsupported-method-4200 into next 2026-10-04 09:24:42 +02:00
Collaborator

Fixes #279

handleRpc() in src/background/index.js answered a method it does not implement with Unsupported method: plus the method name, and no code. It now adds code: 4200, the EIP-1193 code for an unsupported method. A site probing for an optional method can now tell "not implemented" from "the call failed" and fall back. The message is unchanged. The provider in src/content/inpage.js already passes any code through to the page (#274). The only change there adds 4200 to a comment's examples of codes the extension sends; that comment does not list them all.

The new test in tests/inpageErrors.test.js loads the real background, takes its reply for a method it does not implement, and hands that reply to the provider. The other tests in that file give the provider a reply written by hand, so none of them could catch this. The new test fails without the fix.

The other errors in handleRpc() that carry no code (no accounts, a failed proxied call, a failed transaction population, an address that changed mid-preparation) are left alone, as the issue puts them out of scope.

README.md lists no error codes, so it is unchanged.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/AutistMask/issues/279 `handleRpc()` in `src/background/index.js` answered a method it does not implement with `Unsupported method: ` plus the method name, and no code. It now adds `code: 4200`, the EIP-1193 code for an unsupported method. A site probing for an optional method can now tell "not implemented" from "the call failed" and fall back. The message is unchanged. The provider in `src/content/inpage.js` already passes any code through to the page (https://git.eeqj.de/sneak/AutistMask/issues/274). The only change there adds 4200 to a comment's examples of codes the extension sends; that comment does not list them all. The new test in `tests/inpageErrors.test.js` loads the real background, takes its reply for a method it does not implement, and hands that reply to the provider. The other tests in that file give the provider a reply written by hand, so none of them could catch this. The new test fails without the fix. The other errors in `handleRpc()` that carry no code (no accounts, a failed proxied call, a failed transaction population, an address that changed mid-preparation) are left alone, as the issue puts them out of scope. `README.md` lists no error codes, so it is unchanged. Model: opus-5-5
clawbot added the needs-review label 2026-10-04 07:06:36 +02:00
clawbot self-assigned this 2026-10-04 07:06:36 +02:00
Author
Collaborator

FAIL

  1. src/content/inpage.js line 34: this PR edits the comment to say the extension sends codes 4001, 4100, 4200 and 4902. The extension also sends -32002 (a second transaction approval while one is pending), -32603 (an internal error, and an approval window that failed to open) and -32007 (saved data it cannot read), and all three reach the page through this provider. The PR body repeats the claim ("a comment that lists the codes the extension sends"). To fix it, the comment either names every code the extension sends or presents these four as examples, not as the full list.

Model: opus-5-5

FAIL 1. `src/content/inpage.js` line 34: this PR edits the comment to say the extension sends codes 4001, 4100, 4200 and 4902. The extension also sends -32002 (a second transaction approval while one is pending), -32603 (an internal error, and an approval window that failed to open) and -32007 (saved data it cannot read), and all three reach the page through this provider. The PR body repeats the claim ("a comment that lists the codes the extension sends"). To fix it, the comment either names every code the extension sends or presents these four as examples, not as the full list. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-04 07:27:33 +02:00
clawbot force-pushed issue-279-unsupported-method-4200 from bfd370ca5b to 6324e6c22d 2026-10-04 07:45:24 +02:00 Compare
Author
Collaborator
  1. Fixed: the comment now gives 4001, 4100, 4200 and 4902 as examples, and the PR body says the same.

Model: opus-5-5

1. Fixed: the comment now gives 4001, 4100, 4200 and 4902 as examples, and the PR body says the same. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-04 07:45:40 +02:00
Author
Collaborator

FAIL

  1. tests/inpageErrors.test.js lines 52-58: the comment above the code constants says they are "every code the background emits on the RPC path today", and this PR adds 4200 to that list. The background also sends -32002, -32603 and -32007 to the page, so the claim is false. It is the same claim the first review found in src/content/inpage.js; it was fixed there but not here. Acceptable: the comment presents these four as examples, or the list names every code the background sends.

Model: opus-5-5

FAIL 1. `tests/inpageErrors.test.js` lines 52-58: the comment above the code constants says they are "every code the background emits on the RPC path today", and this PR adds 4200 to that list. The background also sends -32002, -32603 and -32007 to the page, so the claim is false. It is the same claim the first review found in `src/content/inpage.js`; it was fixed there but not here. Acceptable: the comment presents these four as examples, or the list names every code the background sends. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-04 08:17:52 +02:00
clawbot added 1 commit 2026-10-04 08:51:29 +02:00
fix: refuse an unsupported method with EIP-1193 code 4200 (closes #279)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run
fc0530cc41
handleRpc() answered a method it does not implement with
"Unsupported method: <method>" and no code, so a site probing for an
optional method could not tell "not implemented" from "the call failed"
and fall back. It now carries code 4200, which EIP-1193 defines for this
case; the message is unchanged. The provider already passes any code
through to the page.

The new test hands the real background's reply to the provider and
checks the page sees 4200.

Model: opus-5-5
clawbot force-pushed issue-279-unsupported-method-4200 from 6324e6c22d to fc0530cc41 2026-10-04 08:51:29 +02:00 Compare
Author
Collaborator
  1. Fixed: the test comment now gives the four codes as examples, and the comment on the pass-through test no longer calls them the full list.

Model: opus-5-5

1. Fixed: the test comment now gives the four codes as examples, and the comment on the pass-through test no longer calls them the full list. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-04 08:51:40 +02:00
Author
Collaborator

PASS

Model: opus-5-5

PASS Model: opus-5-5
clawbot merged commit 4b62e31e80 into next 2026-10-04 09:24:42 +02:00
clawbot deleted branch issue-279-unsupported-method-4200 2026-10-04 09:24:42 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#421