Skip to content

refactor: accept transactionRequests[] in TransactionFee and useGas#2237

Closed
janek26 wants to merge 1 commit into03-06-feat_wire_wallet_sendcalls_approvalfrom
03-06-refactor_transaction_requests_array
Closed

refactor: accept transactionRequests[] in TransactionFee and useGas#2237
janek26 wants to merge 1 commit into03-06-feat_wire_wallet_sendcalls_approvalfrom
03-06-refactor_transaction_requests_array

Conversation

@janek26
Copy link
Contributor

@janek26 janek26 commented Mar 16, 2026

Accept transactionRequests[] in TransactionFee and useGas

Mechanical refactor: the TransactionFee component and useTransactionGas hook accepted a single transactionRequest. Batches need to estimate gas across multiple calls, so the interface now accepts an array.

What changed

  • useTransactionGas – Accepts transactionRequests: TransactionRequest[]. For single-element arrays, uses the existing useEstimateGasLimit hook (provider estimateGas). For multi-element arrays, sums gas from the simulation API via estimateTransactionsGasLimit.
  • TransactionFee – Prop renamed, plus new optional feeLabel and feeInfoButton props for batch-specific affordances.
  • All callsites updatedSend, SpeedUpAndCancelSheet, RevokeDelegationPage, and SendTransaction wrap their single request in [tx].

Design choices & review focus

  • Debounce applies to the whole arrayuseDebounce(transactionRequests, 500) ensures rapid param changes don't spam estimation calls.
  • estimateTransactionsGasLimit for batches – This uses the simulation API which is already available. The simulation endpoint accepts multiple transactions and returns aggregated gas, avoiding N separate estimateGas RPC calls.
  • No behavioural change for single-tx callers – Wrapping in [tx] takes the single-element path which calls useEstimateGasLimit exactly as before.

PR-Codex overview

This PR focuses on refactoring the handling of transaction requests throughout various components by changing the transactionRequest prop to transactionRequests, which allows for the passing of an array of requests instead of a single request.

Detailed summary

  • Changed transactionRequest to transactionRequests in multiple components, allowing for an array of transaction requests.
  • Updated the TransactionFee component to accept transactionRequests and modified its internal logic accordingly.
  • Implemented a new function toSimulationTransaction for converting transaction requests.
  • Enhanced gas estimation logic to handle both single and batch transaction requests.

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

@janek26
Copy link
Contributor Author

janek26 commented Mar 16, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@janek26 janek26 marked this pull request as ready for review March 16, 2026 12:38
@janek26 janek26 requested a review from DanielSinclair March 16, 2026 12:39
@janek26 janek26 force-pushed the 03-06-refactor_transaction_requests_array branch from 8c2e0cb to a3fd029 Compare March 16, 2026 12:42
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch 2 times, most recently from 02a197b to a5af766 Compare March 17, 2026 10:42
@janek26 janek26 force-pushed the 03-06-refactor_transaction_requests_array branch from a3fd029 to 6a6b56c Compare March 17, 2026 10:42
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from a5af766 to 9a187e5 Compare March 17, 2026 13:21
@janek26 janek26 force-pushed the 03-06-refactor_transaction_requests_array branch 2 times, most recently from 965fcd9 to 876ac3f Compare March 18, 2026 09:02
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from 11cfb16 to b142359 Compare March 18, 2026 12:42
@janek26 janek26 force-pushed the 03-06-refactor_transaction_requests_array branch 2 times, most recently from 8b637e8 to eebd2fe Compare March 18, 2026 13:00
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from b142359 to edf1043 Compare March 18, 2026 13:00
@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-refactor_transaction_requests_array branch 2 times, most recently from 36350be to ded1927 Compare March 19, 2026 12:59
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from 96572f9 to c0f1c2b Compare March 19, 2026 12:59
@janek26 janek26 force-pushed the 03-06-refactor_transaction_requests_array branch from ded1927 to d642d91 Compare March 19, 2026 13:30
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch 2 times, most recently from 7e52d17 to 921140f Compare March 19, 2026 13:57
@janek26 janek26 force-pushed the 03-06-refactor_transaction_requests_array branch from d642d91 to 367d8f9 Compare March 19, 2026 13:57
@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 3a2bb94 to a19d7b4 Compare March 19, 2026 15:00
@janek26 janek26 force-pushed the 03-06-refactor_transaction_requests_array branch 2 times, most recently from 94da91a to be04e5e Compare March 19, 2026 15:44
@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-refactor_transaction_requests_array branch from be04e5e to 1e8abe4 Compare March 19, 2026 15:48
@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-refactor_transaction_requests_array branch from 1e8abe4 to 4fd1d89 Compare March 19, 2026 15:54
@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from 0aad4b6 to aed41df Compare March 20, 2026 07:11
@janek26 janek26 force-pushed the 03-06-refactor_transaction_requests_array branch from 4fd1d89 to a8c4375 Compare March 20, 2026 07:12
@DanielSinclair DanielSinclair force-pushed the 03-06-refactor_transaction_requests_array branch from a8c4375 to d95fc80 Compare March 20, 2026 07:15
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch 2 times, most recently from ecd42f0 to b576351 Compare March 20, 2026 07:26
@DanielSinclair DanielSinclair force-pushed the 03-06-refactor_transaction_requests_array branch from d95fc80 to b7dd5d6 Compare March 20, 2026 07:26
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from b576351 to c0da740 Compare March 20, 2026 07:31
@DanielSinclair DanielSinclair force-pushed the 03-06-refactor_transaction_requests_array branch from b7dd5d6 to 81f7e84 Compare March 20, 2026 07:31
@DanielSinclair DanielSinclair force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from c0da740 to a79d96d Compare March 20, 2026 07:43
@DanielSinclair DanielSinclair force-pushed the 03-06-refactor_transaction_requests_array branch from 81f7e84 to 44353f6 Compare March 20, 2026 07:43
Copy link
Collaborator

@DanielSinclair DanielSinclair left a comment

Choose a reason for hiding this comment

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

Approving, but I think there is a logical issue with gas here that we may need to address by re-adopting batched simulations and batched simulation gas estimates from backend (or getting that work ticketed out for them at least)

tx: TransactionRequest,
): { from: string; to: string; value: string; data: string } => ({
from: tx.from?.toString() ?? '',
to: tx.to?.toString() ?? '',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fallback values are concerning here because they differ from the transaction submission flow. If missing here, the simulation would fail and the UI handles gracefully, but could still be destructive

Copy link
Collaborator

Choose a reason for hiding this comment

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

We'd want to use the selected address instead here, I think. I assume the stack won't let you send to a null address with '', but maybe from as the default for to as well

estimatedGasLimit,
transactionRequest,
estimatedGasLimit: estimatedGasLimit ?? undefined,
transactionRequest: debouncedRequests?.[0] ?? null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unintended side effects on gas. I think we want to avoid conflating using sequential simulation for display values, vs gas estimates; we really need to estimate the batch as a whole.

useOptimismL1SecurityFee only accounts for the first transaction's calldata on OP-stack
chains, silently underestimating fees for multi-tx batches.

That matters on chains like Optimism and Base because the extra L1 security fee depends on the
calldata size of the full transaction. A batch with 3 calls has more calldata than just the first
call, so using only the first request makes the L1 fee too small. The result is the fee preview and
speed options are underestimated for multi-call batches.

@janek26 janek26 force-pushed the 03-06-feat_wire_wallet_sendcalls_approval branch from a79d96d to 205c521 Compare March 20, 2026 10:42
@janek26 janek26 force-pushed the 03-06-refactor_transaction_requests_array branch from 44353f6 to 06aeae1 Compare March 20, 2026 10:42
@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 force-pushed the 03-06-refactor_transaction_requests_array branch from 06aeae1 to 60fa6f8 Compare March 20, 2026 20:18
@DanielSinclair DanielSinclair marked this pull request as draft March 20, 2026 20:28
@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 force-pushed the 03-06-refactor_transaction_requests_array branch from 60fa6f8 to 5bb953f Compare March 20, 2026 22:36
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