Skip to content

fix: keep the EIP-7702 initCode marker in UserOperation.toPacked - #593

Merged
jxom merged 2 commits into
mainfrom
jxom/user-operation-7702-init-code
Nov 8, 2026
Merged

jxom merged 2 commits into
mainfrom
jxom/user-operation-7702-init-code

Conversation

@jxom

@jxom jxom commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Supersedes #574 (thanks @erkancamli; your commit is kept as-is), with small review follow-ups.

UserOperation.toInitCode replaced a 0x7702 factory with the authorization's delegate address, and toPacked used it for the packed user operation sent to the EntryPoint. EntryPoint 0.8 and 0.9 only treat an operation as EIP-7702 when the first 20 bytes of initCode are the padded 0x7702 marker; the delegate is substituted only when hashing (_getEip7702InitCodeHashOverride). With the delegate in initCode, 0.8 reverts with AA10 sender already constructed and 0.9 emits IgnoredInitCode and skips factoryData.

toInitCode now takes forHash (as viem's getInitCode does): by default it returns the padded marker followed by factoryData, and with forHash the delegate form. toPacked passes its forHash through, so hash and toTypedData are unchanged.

Behavior change: the default output of toInitCode for EIP-7702 operations is now the marker form; callers hashing it themselves need { forHash: true }.

Follow-ups on top of #574: one-sentence changeset, options: forHash test names, and whole-object inline snapshots for the packed operation.

Validation:

  • Against the eth-infinitism v0.8.0 and v0.9.0 EntryPoint and Simple7702Account in forge: the marker initCode runs factoryData on both; the delegate form reverts AA10 on 0.8 and is ignored on 0.9. getUserOpHash equals UserOperation.hash before and after this change.
  • pnpm test --project core src/erc4337 (67 passed; the new default-form tests fail on main), pnpm check:types, vp check.

Backport to 0.x: #594.

erkancamli and others added 2 commits November 8, 2026 19:48
`toInitCode` always replaced the `0x7702` factory with the
authorization's delegate address, and `toPacked` used it for the
packed user operation sent to the EntryPoint. EntryPoint 0.8 and 0.9
only treat an operation as EIP-7702 when the first 20 bytes of
`initCode` are the `0x7702` marker; the delegate address belongs only
in the hashed form (`_getEip7702InitCodeHashOverride`). With the
delegate in place, 0.8 reverts with "AA10 sender already constructed"
and 0.9 ignores the initCode, skipping `factoryData`.

`toInitCode` now takes a `forHash` option, as viem's `getInitCode`
does: without it the init code is the padded marker followed by
`factoryData`, with it the delegate form used for hashing. `toPacked`
passes its own `forHash` on, so `hash` is unchanged.

Co-authored-by: jxom <jake@tempo.xyz>
@vercel

vercel Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ox Error Error Nov 8, 2026 7:54pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T19:53:22.272001Z 8dd14de PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Published ox@0.0.0-pr-593-8dd14de under the pr-593 dist-tag, which follows this pull request until it closes.

pnpm add ox@pr-593
pnpm add ox@0.0.0-pr-593-8dd14de

@jxom
jxom merged commit c370946 into main Nov 8, 2026
15 of 16 checks passed
@jxom
jxom deleted the jxom/user-operation-7702-init-code branch November 8, 2026 20:00
@github-actions github-actions Bot mentioned this pull request Nov 8, 2026

This branch had an error being deployed

1 failed deployment
Preview — 8dd14ded Deployed Nov 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants