refactor: accept transactionRequests[] in TransactionFee and useGas#2237
refactor: accept transactionRequests[] in TransactionFee and useGas#2237janek26 wants to merge 1 commit into03-06-feat_wire_wallet_sendcalls_approvalfrom
Conversation
8c2e0cb to
a3fd029
Compare
02a197b to
a5af766
Compare
a3fd029 to
6a6b56c
Compare
a5af766 to
9a187e5
Compare
965fcd9 to
876ac3f
Compare
11cfb16 to
b142359
Compare
8b637e8 to
eebd2fe
Compare
b142359 to
edf1043
Compare
edf1043 to
96572f9
Compare
36350be to
ded1927
Compare
96572f9 to
c0f1c2b
Compare
ded1927 to
d642d91
Compare
7e52d17 to
921140f
Compare
d642d91 to
367d8f9
Compare
921140f to
5c7007f
Compare
3a2bb94 to
a19d7b4
Compare
94da91a to
be04e5e
Compare
09da1dc to
4f93fd5
Compare
be04e5e to
1e8abe4
Compare
4f93fd5 to
0aad4b6
Compare
1e8abe4 to
4fd1d89
Compare
0aad4b6 to
aed41df
Compare
4fd1d89 to
a8c4375
Compare
a8c4375 to
d95fc80
Compare
ecd42f0 to
b576351
Compare
d95fc80 to
b7dd5d6
Compare
b576351 to
c0da740
Compare
b7dd5d6 to
81f7e84
Compare
c0da740 to
a79d96d
Compare
81f7e84 to
44353f6
Compare
DanielSinclair
left a comment
There was a problem hiding this comment.
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() ?? '', |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
a79d96d to
205c521
Compare
44353f6 to
06aeae1
Compare
205c521 to
c6a9063
Compare
06aeae1 to
60fa6f8
Compare
c6a9063 to
3fa9cc0
Compare
60fa6f8 to
5bb953f
Compare
…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 -->

Accept transactionRequests[] in TransactionFee and useGas
Mechanical refactor: the
TransactionFeecomponent anduseTransactionGashook accepted a singletransactionRequest. Batches need to estimate gas across multiple calls, so the interface now accepts an array.What changed
useTransactionGas– AcceptstransactionRequests: TransactionRequest[]. For single-element arrays, uses the existinguseEstimateGasLimithook (providerestimateGas). For multi-element arrays, sums gas from the simulation API viaestimateTransactionsGasLimit.TransactionFee– Prop renamed, plus new optionalfeeLabelandfeeInfoButtonprops for batch-specific affordances.Send,SpeedUpAndCancelSheet,RevokeDelegationPage, andSendTransactionwrap their single request in[tx].Design choices & review focus
useDebounce(transactionRequests, 500)ensures rapid param changes don't spam estimation calls.estimateTransactionsGasLimitfor batches – This uses the simulation API which is already available. The simulation endpoint accepts multiple transactions and returns aggregated gas, avoiding N separateestimateGasRPC calls.[tx]takes the single-element path which callsuseEstimateGasLimitexactly as before.PR-Codex overview
This PR focuses on refactoring the handling of transaction requests throughout various components by changing the
transactionRequestprop totransactionRequests, which allows for the passing of an array of requests instead of a single request.Detailed summary
transactionRequesttotransactionRequestsin multiple components, allowing for an array of transaction requests.TransactionFeecomponent to accepttransactionRequestsand modified its internal logic accordingly.toSimulationTransactionfor converting transaction requests.