Skip to content

feat(transactions): prepare ERC-20 transfers before signing - #439

Merged
crystalt merged 14 commits into
mainfrom
crystalbilly/crypto-70-prepared-erc20-lifecycle
Sep 11, 2026
Merged

feat(transactions): prepare ERC-20 transfers before signing#439
crystalt merged 14 commits into
mainfrom
crystalbilly/crypto-70-prepared-erc20-lifecycle

Conversation

@crystalt

@crystalt crystalt commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Adds the first client-side ERC-20 transaction lifecycle in Bedrock.

prepare_transaction_transfer constructs the exact unsigned UserOperation, requests sponsorship from pm_sponsorUserOperation (V2), and returns an opaque prepared transaction. submit_prepared_transaction signs and submits that same operation through /v2/rpc/worldchain.

This intentionally covers the sponsored happy path only. WLD self-sponsorship and its cost advisory remain follow-up work.

Stacked on #435, which provides the typed pm_sponsorUserOperation response.


Note

Medium Risk
Changes the public ERC-20 transfer API and submission path (V2 sponsor + send); sponsorship decline is a hard error with no fallback yet.

Overview
Splits World Chain ERC-20 transfers into a prepare → submit flow so clients can review an unsigned operation (with sponsorship applied) before signing.

prepare_transaction_transfer builds the preflight UserOperation, calls pm_sponsorUserOperation with protocol sponsorship context, merges approved paymaster/gas fields via new UserOperation::with_pm_sponsorship_approval, and returns a PreparedTransaction (UniFFI object). Declined sponsorship currently errors out (self-sponsor left as TODO).

submit_prepared_transaction checks the prepared sender matches the account, signs the operation, and submits through send_user_operation_v2. Structured logging was added for both stages.

Supporting changes: test HTTP mock handles pm_sponsorUserOperation; PmSponsorshipDeclineReason gets Display + EnumIter and a serde round-trip test; the Anvil integration test now asserts balances are unchanged until submit.

Reviewed by Cursor Bugbot for commit b4e1d30. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-10T19:28:27.106311Z b4e1d30 New commits
ℹ️ 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.

Base automatically changed from crystalbilly/crypto-68-typed-sponsorship-decline to main September 8, 2026 17:20

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6351fc0344

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bedrock/src/transactions/rpc/wire.rs
Comment thread bedrock/src/primitives/contracts.rs
Comment thread bedrock/src/transactions/mod.rs
Comment thread bedrock/src/transactions/mod.rs
Comment thread bedrock/src/test_utils.rs
@crystalt
crystalt merged commit 1e317ab into main Sep 11, 2026
20 checks passed
@crystalt
crystalt deleted the crystalbilly/crypto-70-prepared-erc20-lifecycle branch September 11, 2026 19:23
This was referenced Sep 10, 2026
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.

2 participants