Skip to content

refactor(walletConnectToDapps): resolve the dApp gas limit in the simulation hook - #12748

Merged
kaladinlight merged 1 commit into
developfrom
fix/wc-dapp-gas-limit-estimate
Oct 7, 2026
Merged

kaladinlight merged 1 commit into
developfrom
fix/wc-dapp-gas-limit-estimate

Conversation

@kaladinlight

@kaladinlight kaladinlight commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Description

Second of two PRs restructuring EVM gas handling for the WalletConnect dApp flow. Stacked on #12747, which provides getGasLimit; retarget to develop once that merges.

Follow-up to the #12743 hotfix, which papered over a lost form update. This removes the pattern that caused it.

Hook

  • One Tenderly simulation per transaction instead of two. The second one existed only to read gas used with fee data attached, which fee data doesn't change.
  • Gas prices come from a polled getGasFeeData query and the gas limit from a speed-independent getGasLimit query, so changing speed refetches nothing and speed is no longer in any query key.
  • The hook resolves the effective gas limit: dApp or user value if above zero, else the buffered eth_estimateGas result, else Tenderly gas used as a last resort. The displayed fee is priced on that same gas limit, using legacy gas price to match what the handler signs.

Footer and menu

  • The footer passes the hook's gas limit into onConfirm. The speed menu's effect that wrote the estimate into the form, and the footer gate that read it back, are gone.
  • Confirm shows loading while the estimate it needs is in flight, and stays enabled for a dApp-supplied gas limit without waiting on our estimate.

Advanced parameters

  • The current nonce is the field's placeholder instead of being written into the form, so isUserDefinedNonce goes away and the form only ever holds what the user typed. The handler signs with the form nonce when present, else the built transaction's nonce, same as before.
  • The gas-limit field shows the recommendation as its placeholder.

Cleanup

  • Duplicate ConfirmData type merged into CustomTransactionData; unused gas form field removed.
  • Simulator's feeData input removed, dead since the second simulation went away. transaction.gas is no longer sent as NaN when a dApp omits it.

Known gap, pre-existing

When eth_estimateGas fails and Tenderly returns nothing, Confirm is disabled with no explanation. The Advanced Parameters gas-limit field unblocks it. Worth a ticket for an inline message.

Issue (if applicable)

closes #

Risk

High Risk PRs Require 2 approvals

Medium. WalletConnect dApp transaction confirmation UI and the data passed to signing. The signing handler itself changes only in how it picks the nonce (form value if typed, else built nonce), which matches the previous effective behaviour.

  • Every WalletConnect eth_sendTransaction and eth_signTransaction confirmation.
  • Message signing, session auth, Bitcoin and Cosmos WalletConnect flows are untouched.

Testing

Engineering

  • pnpm vitest run src/plugins/walletConnectToDapps
  • Footer tests cover: waits for a gas limit, dApp-supplied gas limit, estimate-supplied gas limit, loading while estimating, message signing needs no gas limit.
  • Validated live: ShapeShift wallet approve and stake through venice.ai on Base, a dApp that omits gas.

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)
  1. Connect to https://venice.ai via WalletConnect with an account on Base and start a VVV stake. Confirm spins briefly, then enables. Fee estimate shows. Confirm and verify the transaction succeeds.
  2. Change the speed selector between Slow, Average and Fast. The fee updates immediately with no spinner on Confirm.
  3. Open Advanced Parameters. The nonce and gas-limit fields are empty with the current nonce and recommended gas limit shown as placeholders. Type a gas limit and confirm; the transaction should use it.
  4. Connect to a dApp that supplies gas (Uniswap on Ethereum, for example). Confirm is enabled as soon as the simulation finishes.
  5. Sign a message from any dApp. Unchanged.

Screenshots (if applicable)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Transaction confirmations now show a recommended gas limit when available, while allowing a supplied gas limit to take precedence.
    • Gas-limit loading is reflected in the confirmation button’s loading and disabled states.
  • Bug Fixes

    • A custom nonce is now applied to send and sign requests whenever provided; otherwise, the transaction’s existing nonce is used.
    • The current nonce appears as a placeholder instead of being automatically entered into the form.

@kaladinlight
kaladinlight requested a review from a team as a code owner October 7, 2026 18:52
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a1535e0d-2fba-45c3-b3a3-009ab732dffd
📥 Commits

Reviewing files that changed from the base of the PR and between 68c1b00 and 7423a5f.

📒 Files selected for processing (10)
  • src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/GasSelectionMenu.tsx
  • src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/WalletConnectModalSigningFooter.test.tsx
  • src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/WalletConnectModalSigningFooter.tsx
  • src/plugins/walletConnectToDapps/components/modals/EIP155TransactionConfirmation.tsx
  • src/plugins/walletConnectToDapps/components/modals/SendTransactionConfirmation.tsx
  • src/plugins/walletConnectToDapps/components/modals/TransactionAdvancedParameters.tsx
  • src/plugins/walletConnectToDapps/hooks/useSimulateEvmTransaction.ts
  • src/plugins/walletConnectToDapps/types.ts
  • src/plugins/walletConnectToDapps/utils/EIP155RequestHandlerUtil.ts
  • src/plugins/walletConnectToDapps/utils/tenderly/index.ts
💤 Files with no reviewable changes (2)
  • src/plugins/walletConnectToDapps/utils/tenderly/index.ts
  • src/plugins/walletConnectToDapps/types.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

WalletConnect transaction signing now uses separate gas-limit and fee-data queries. The signing UI passes supplied gas limits to the simulation hook, and transaction confirmation uses its effective limit. Advanced parameters display nonce and recommended gas values as placeholders. Request handling uses a truthy custom nonce.

Changes

WalletConnect transaction gas and nonce handling

Layer / File(s) Summary
Simulation and gas data
src/plugins/walletConnectToDapps/hooks/useSimulateEvmTransaction.ts, src/plugins/walletConnectToDapps/utils/tenderly/index.ts
The hook fetches gas-limit estimates and fee data separately, calculates a buffered recommendation, and lets a positive supplied gas limit take precedence. Tenderly requests no longer include fee fields.
Advanced parameters and nonce handling
src/plugins/walletConnectToDapps/components/modals/*, src/plugins/walletConnectToDapps/types.ts, src/plugins/walletConnectToDapps/utils/EIP155RequestHandlerUtil.ts
Confirmation modals pass transaction data to advanced parameters. The nonce and recommended gas limit appear as input placeholders. Send and sign requests use a truthy custom nonce when present.
Gas selection and confirmation
src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/GasSelectionMenu.tsx, src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/WalletConnectModalSigningFooter.tsx, src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/WalletConnectModalSigningFooter.test.tsx
The gas menu passes the watched limit to the hook without setting an estimate in the form. The footer uses the returned limit and loading state, and passes the effective limit to confirmation. Tests use the recommendation and loading values from the hook mock.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant SigningUI as WalletConnect signing UI
  participant SimulationHook as useSimulateEvmTransaction
  participant EVMAdapter as EVM adapter
  participant Tenderly as Tenderly
  SigningUI->>SimulationHook: Pass transaction and optional gas limit
  par Gas data
    SimulationHook->>EVMAdapter: Request gas-limit estimate and fee data
    EVMAdapter-->>SimulationHook: Return estimate and fee data
  and Simulation
    SimulationHook->>Tenderly: Simulate transaction
    Tenderly-->>SimulationHook: Return gas_used
  end
  SimulationHook-->>SigningUI: Return recommended limit, effective limit, and fee
Loading

Suggested reviewers: 0xapotheosis

Merge Risk: ⚪ Minimal · up to 7423a

No identified issue blocks merging: a failed gas estimate can use Tenderly’s gas value, and an entered zero nonce is preserved.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: resolving the dApp gas limit in the WalletConnect simulation hook.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 8…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

I’m a rabbit with a gas-limit chart,
I watch the estimates hop and start.
A nonce rests where placeholders bloom,
A steady fee finds space to zoom.
I thump my paws: the form is neat!

Comment @coderabbitai help to get the list of available commands.

Base automatically changed from refactor/evm-gas-limit-estimate to develop October 7, 2026 19:14
…ulation hook

One Tenderly simulation per transaction instead of two. Gas prices come from
a polled getGasFeeData query and the gas limit from a speed-independent
getGasLimit query, so changing speed refetches nothing.

The hook resolves the effective gas limit (dApp or user value, else the
buffered estimate) and the footer passes it to onConfirm, replacing the
effect that wrote the estimate into the form and the gate that read it back.
Confirm shows loading while the estimate it needs is in flight, and a dApp
gas of 0 no longer counts as a supplied value.

The current nonce is shown as the placeholder instead of being written into
the form, so isUserDefinedNonce goes away and the form only ever holds what
the user typed. The duplicate ConfirmData type, the unused gas form field and
the simulator's dead feeData input are removed, and the displayed fee is
priced on the gas limit that gets signed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@kaladinlight
kaladinlight force-pushed the fix/wc-dapp-gas-limit-estimate branch from 7a682b4 to 7423a5f Compare October 7, 2026 19:15
@kaladinlight
kaladinlight merged commit 660aaa1 into develop Oct 7, 2026
4 checks passed
@kaladinlight
kaladinlight deleted the fix/wc-dapp-gas-limit-estimate branch October 7, 2026 19:33
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.

1 participant