Skip to content

feat: wire wallet_sendCalls approval flow end-to-end#2236

Closed
janek26 wants to merge 1 commit intographite-base/2236from
03-06-feat_wire_wallet_sendcalls_approval
Closed

feat: wire wallet_sendCalls approval flow end-to-end#2236
janek26 wants to merge 1 commit intographite-base/2236from
03-06-feat_wire_wallet_sendcalls_approval

Conversation

@janek26
Copy link
Contributor

@janek26 janek26 commented Mar 16, 2026

Wire wallet_sendCalls approval flow end-to-end

After this PR, a dapp can call wallet_sendCalls and the user sees the existing SendTransaction approval screen with batch-aware UI. Approving executes the batch via delegation, stores the batch record, and returns the batch ID to the dapp.

What's included

  • oRPC contract + handlerexecuteSendCallsBatch procedure callable from the popup via popupClient.wallet.executeSendCallsBatch.
  • Provider callbackssetBatch and getBatchByKey wired into handleProviderRequest with boundary validation. The provider can now store and retrieve batch records.
  • Approval routingwallet_sendCalls is added as a case in ApproveAppRequest, reusing the SendTransaction screen.
  • Batch branch in onAcceptRequest – Detects batch requests via isWalletSendCallsRequest, calls the oRPC handler, and returns the batch ID on success.
  • Batch-aware title – The approval header shows "Batch request: N calls on [chain]" instead of "Transaction Request" when reviewing a batch.
  • i18n stringsbatch_request_title, batch_call_label, batch_of_calls, batch_fee_note, batch_request_chain_unknown.

Design choices & review focus

  • Reuses SendTransaction – Rather than a separate approval screen, batches go through the same flow. This keeps the UX consistent and avoids duplicating signing/gas/rejection logic.
  • Gas estimation uses single-tx path for now – The TransactionFee component still receives a single transaction request at this point. Proper multi-call gas estimation is added in a later PR. This is good enough as a first pass since the delegation SDK handles gas internally.
  • txRequest cast removed – The unsafe request?.params?.[0] as TransactionRequest cast is replaced with getTransactionRequestFromRequest(request) which handles both request types safely.

PR-Codex overview

This PR introduces support for batch processing of wallet send calls in the application. It adds new schemas, handlers, and UI components to accommodate the functionality, enhancing the transaction approval process.

Detailed summary

  • Added case for wallet_sendCalls in ApproveAppRequest.tsx.
  • Introduced executeSendCallsBatchHandler and executeSendCallsBatchContract.
  • Created schemas for send calls in executeSendCallsBatch.ts.
  • Updated handleProviderRequest to manage batch requests.
  • Enhanced SendTransaction and SendTransactionInfo to handle batch requests and display appropriate UI elements.
  • Updated localization files for new batch request messages.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@janek26
Copy link
Contributor Author

janek26 commented Mar 16, 2026

@janek26 janek26 marked this pull request as ready for review March 16, 2026 12:37
@janek26 janek26 requested a review from DanielSinclair March 16, 2026 12:39
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from 0a7e588 to 02a197b Compare March 16, 2026 12:42
@janek26 janek26 force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from 105269e to b357450 Compare March 17, 2026 10:42
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from 02a197b to a5af766 Compare March 17, 2026 10:42
@janek26 janek26 force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from b357450 to f4d3ec4 Compare March 17, 2026 13:21
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch 2 times, most recently from 9a187e5 to 11cfb16 Compare March 18, 2026 09:02
@janek26 janek26 force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from f4d3ec4 to 0362aa5 Compare March 18, 2026 09:02
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch 2 times, most recently from b142359 to edf1043 Compare March 18, 2026 13:00
@janek26 janek26 force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from 1b7bafe to 7648d8d Compare March 18, 2026 13:00
@janek26 janek26 force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from 7648d8d to d437e46 Compare March 19, 2026 12:38
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from edf1043 to 96572f9 Compare March 19, 2026 12:38
@janek26 janek26 force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from d437e46 to b03d66d Compare March 19, 2026 12:59
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch 2 times, most recently from c0f1c2b to 7e52d17 Compare March 19, 2026 13:30
@janek26 janek26 force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch 2 times, most recently from 68f2cad to 7adfc78 Compare March 19, 2026 13:57
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from 7e52d17 to 921140f Compare March 19, 2026 13:57
@janek26 janek26 force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from 7adfc78 to 1160ca8 Compare March 19, 2026 14:26
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from 921140f to 5c7007f Compare March 19, 2026 14:26
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from a19d7b4 to 09da1dc Compare March 19, 2026 15:44
@janek26 janek26 force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from 8307322 to 6a782f5 Compare March 19, 2026 15:47
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from 09da1dc to 4f93fd5 Compare March 19, 2026 15:47
@janek26 janek26 force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from 6a782f5 to 801b74e Compare March 19, 2026 15:54
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from 4f93fd5 to 0aad4b6 Compare March 19, 2026 15:54
@janek26 janek26 force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from 801b74e to a1a841f Compare March 20, 2026 07:11
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from 0aad4b6 to aed41df Compare March 20, 2026 07:11
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from aed41df to ecd42f0 Compare March 20, 2026 07:15
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch 2 times, most recently from 717ec49 to fa47824 Compare March 20, 2026 07:26
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from ecd42f0 to b576351 Compare March 20, 2026 07:26
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from fa47824 to eb4f795 Compare March 20, 2026 07:31
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch 2 times, most recently from c0da740 to a79d96d Compare March 20, 2026 07:43
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from eb4f795 to 61971a1 Compare March 20, 2026 07:43
}}
chainId={activeSession?.chainId || ChainId.mainnet}
address={activeSession?.address}
transactionRequest={request?.params?.[0] as TransactionRequest}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a SendCallsParams; was getTransactionRequestFromRequest missed here?

  • [P1] Estimate wallet_sendCalls fees from the batch, not params[0] — /Users/daniel/Documents/GitHub/
    browser-extension/src/entries/popup/pages/messages/SendTransaction/index.tsx:301-303
    When this page is opened for wallet_sendCalls, request.params[0] is a SendCallsParams object, not a
    TransactionRequest. Passing it straight into TransactionFee means useEstimateGasLimit sees no to/
    data/value fields and falls back to the default transfer estimate, so every batch approval shows a
    misleading fee; for cross-chain batches it also reads gas data from activeSession?.chainId instead of
    the requested batch chain. Because executeSendCallsBatch later reuses
    selectedGas.transactionGasParams, this can also break execution when the batch targets a different
    network than the current session.
    • [P2] Use the batch chain when rendering and gating sendCalls approvals — /Users/daniel/Documents/
      GitHub/browser-extension/src/entries/popup/pages/messages/SendTransaction/
      SendTransactionsInfo.tsx:751-753
      Routing wallet_sendCalls through TransactionInfo here still leaves the approval sheet tied to
      activeSession.chainId: TransactionInfo simulates the request on the session chain, and the same file
      uses useHasEnoughGas(activeSession) to decide whether to block approval for insufficient gas. Since
      the provider accepts an explicit sendParams.chainId that can differ from the connected network,
      cross-chain batches will show the wrong network/simulation and can be incorrectly blocked or allowed
      based on another chain's native balance.

@janek26 janek26 force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from 61971a1 to ddacaad Compare March 20, 2026 10:42
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from a79d96d to 205c521 Compare March 20, 2026 10:42
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch from ddacaad to 77f88d3 Compare March 20, 2026 20:17
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from 205c521 to c6a9063 Compare March 20, 2026 20:17
@DanielSinclair DanielSinclair marked this pull request as draft March 20, 2026 20:28
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_sendcalls_execution_and_normalization branch 2 times, most recently from 9ed0fb5 to c6402cf Compare March 20, 2026 22:36
fix: accept readonly calls array in sendCalls contract schema

`SendCallsParams.calls` is now `readonly` (from viem's `WalletSendCallsParameters`). Add `.readonly()` to the Zod schema so the contract accepts readonly arrays without requiring a spread copy at the call site.
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from c6a9063 to 3fa9cc0 Compare March 20, 2026 22:36
@DanielSinclair DanielSinclair changed the base branch from 03-06-feat_sendcalls_execution_and_normalization to graphite-base/2236 March 20, 2026 22:49
DanielSinclair pushed a commit that referenced this pull request Mar 20, 2026
…ound execution (#2254)

This PR aims to replace these 3 from the stack  
#2236  
#2237  
#2238  
  
All of them had one common issue pointed out by Daniel in the review, I tried to generalise the sendTransaction interface into working with transaction request arrays, and transform normal sendTransaction requests into a transaction request array of length one.

This resulted in multiple issues:

1. transaction requests through sendTransaction and sendCalls with calls length of one would simulate the same
2. If not delegated yet, the delegation would not be simulated, and results would not be verified
3. Serial gas estimation does not represent actual gas costs 
    1. `est(call1)+est(call2)+est(call3) !== est(call1+call2+call3)`

This PR aims to use what's in place instead of forcing everything into a new array format. Instead we're reusing the existing format of having a single transaction request. That"s possible by wrapping calls with `prepareBatchedTransaction` from the delegation sdk.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces support for the `wallet_sendCalls` method, enhancing batch transaction capabilities. It includes new schemas, hooks, and UI components for better handling of batch requests and transactions, improving error handling and user feedback.

### Detailed summary
- Added support for `wallet_sendCalls` in `ApproveAppRequest.tsx`.
- Introduced `executeSendCallsBatch` handler and contract.
- Created schemas for batch call parameters and execution.
- Updated gas estimation logic to accommodate batch transactions.
- Enhanced UI components to display batch transaction details and simulation results.
- Improved error handling and user notifications for batch requests.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
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