feat(rpc): add sign_and_execute_v2 for V2 RPC#348
Conversation
Adds the Bedrock-side plumbing needed to call the new pm_sponsorUserOperation endpoint on temporal-apps (V2) instead of wa_sponsorUserOperation on app-backend-main (V1). New in rpc.rs: - PmSponsorUserOperation RpcMethod variant, routed to /v2/rpc - SendUserOperation also routed to /v2/rpc - PmSponsorUserOperationResponse struct matching the temporal-apps response - From<PmSponsorUserOperationResponse> for SponsorUserOperationResponse to reuse the existing with_paymaster_data() path - pm_sponsor_user_operation() method on RpcClient New in transaction_4337.rs: - sign_and_execute_v2() trait method alongside the existing sign_and_execute() V1 path; callers in mod.rs are untouched so each transaction type can opt in to V2 one at a time in its own PR sign_and_execute() is left unchanged so all existing UniFFI-exported methods continue to use the V1 path until explicitly migrated.
There was a problem hiding this comment.
Pull request overview
Adds Bedrock support for the temporal-apps V2 sponsorship RPC (pm_sponsorUserOperation) and introduces an opt-in V2 execution path for 4337 transactions, while leaving the existing V1 path intact for current UniFFI consumers.
Changes:
- Add
PmSponsorUserOperationRPC method + response type, with conversion into the existingSponsorUserOperationResponseflow. - Route
pm_sponsorUserOperationandeth_sendUserOperationthrough/v2/rpc. - Add
sign_and_execute_v2()alongside the existing V1sign_and_execute()path.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
bedrock/src/transactions/rpc.rs |
Introduces V2 sponsorship RPC method/response and updates method→endpoint version routing. |
bedrock/src/test_utils.rs |
Extends the mocked RPC client to return a V2 pm_sponsorUserOperation-shaped response. |
bedrock/src/smart_account/transaction_4337.rs |
Adds an opt-in sign_and_execute_v2() execution path that uses the V2 sponsorship + send endpoints. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 889cf04c4c
ℹ️ 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".
Adds an Anvil-backed integration test that exercises the full V2 execution path: pm_sponsorUserOperation → gas/paymaster merge → sign → eth_sendUserOperation. Asserts a non-zero userOpHash is returned and that the on-chain ERC-20 balance changes, proving the operation actually executed via EntryPoint. Uses the existing AnvilBackedHttpClient mock, which already handles both pm_sponsorUserOperation and eth_sendUserOperation.
Covers that SendUserOperation, PmSponsorUserOperation, and EthCall
resolve to /v2/rpc/{network}, while SponsorUserOperation,
WaGetUserOperationReceipt, and SupportedEntryPoints stay on /v1.
A third test pins the full URL shape to catch network_name regressions.
Covers JSON deserialization of the pm_sponsorUserOperation response shape (both bundler-sponsored and paymaster-sponsored variants) and verifies the From<PmSponsorUserOperationResponse> for SponsorUserOperationResponse mapping — including that paymaster gas limits are wrapped in Some and provider_name is always RpcProviderName::Any.
Routing eth_sendUserOperation to /v2/ broke the staged migration guarantee: sign_and_execute() callers were silently put on a mixed V1-sponsor/V2-submit path. Fix by reverting SendUserOperation to /v1/ and introducing a separate SendUserOperationV2 variant (same wire name, /v2/ routing) used exclusively by send_user_operation_v2() and sign_and_execute_v2().
Adds the Bedrock-side plumbing needed to call the new pm_sponsorUserOperation endpoint on temporal-apps (V2) instead of wa_sponsorUserOperation on the backend (V1).
New in rpc.rs:
New in transaction_4337.rs:
sign_and_execute() is left unchanged so all existing UniFFI-exported methods continue to use the V1 path until explicitly migrated.