Skip to content

feat: Add support for ERC-8132: Gas Limit Override Capability#238

Open
ajhodges wants to merge 7 commits intobase:masterfrom
ajhodges:erc-8132
Open

feat: Add support for ERC-8132: Gas Limit Override Capability#238
ajhodges wants to merge 7 commits intobase:masterfrom
ajhodges:erc-8132

Conversation

@ajhodges
Copy link
Collaborator

@ajhodges ajhodges commented Jan 26, 2026

Summary

Implements ERC-8132 Gas Limit Override capability, allowing apps to specify per-call gas limits in wallet_sendCalls.
Resolves BA-3860
Changes:

  • Capability advertisementwallet_getCapabilities now returns gasLimitOverride: { supported: true } under the 0x0 wildcard key (all chains)
  • Type definitions — New GasLimitOverrideCallCapability, CallCapabilities, and WalletSendCallsCall types in wallet_sendCalls.ts; PrepareCallsCall updated to include per-call capabilities
  • Client-side validationvalidateGasLimitOverrides() in the sub-account signer validates each call's gasLimitOverride.value is valid hex and non-zero, returning -32602 on failure
  • Sub-account forwarding — Per-call capabilities are preserved through wallet_sendCallswallet_prepareCalls → bundler RPC
  • Global account routing — When calls are routed through the global account via executeBatch, per-call gas limit overrides are aggregated (with eth_estimateGas for calls without an override) and set on the batch call sent to the popup. Batch overhead uses backend-aligned buffer params (500 gas/call safety buffer + 2 gas/byte input data cost)

How did you test your changes?

  • 8 new unit tests for wallet_getCapabilities gasLimitOverride advertisement in Signer.test.ts
  • 4 new unit tests for gas limit validation in createSubAccountSigner.test.ts
  • 5 new unit tests for gas limit aggregation in routeThroughGlobalAccount.test.ts
  • All 976 tests pass, clean tsc --noEmit type-check

@cb-heimdall
Copy link
Collaborator

cb-heimdall commented Jan 26, 2026

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements ERC-8132-style per-call gasLimitOverride support for wallet_sendCalls, including capability advertisement, validation, and forwarding/aggregation when routing calls through the global account.

Changes:

  • Advertises gasLimitOverride: { supported: true } under the 0x0 (all chains) key in wallet_getCapabilities.
  • Adds RPC/types for per-call capabilities (gasLimitOverride) and threads them through wallet_sendCallswallet_prepareCalls.
  • Validates per-call gasLimitOverride.value in the sub-account signer and aggregates per-call gas overrides onto the routed executeBatch call.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/account-sdk/src/sign/base-account/utils/routeThroughGlobalAccount.ts Aggregates per-call gas limit overrides onto the routed executeBatch call when using the global account.
packages/account-sdk/src/sign/base-account/utils/routeThroughGlobalAccount.test.ts Adds unit tests for aggregation/estimation behavior and propagation of aggregated override.
packages/account-sdk/src/sign/base-account/utils/createSubAccountSigner.ts Adds client-side validation for gasLimitOverride.value (hex + non-zero) and forwards per-call capabilities.
packages/account-sdk/src/sign/base-account/utils/createSubAccountSigner.test.ts Adds unit tests for gas limit override validation/pass-through.
packages/account-sdk/src/sign/base-account/utils.ts Updates request helper typing to allow per-call capabilities.
packages/account-sdk/src/sign/base-account/Signer.ts Always includes 0x0.gasLimitOverride in wallet_getCapabilities and ensures it survives filtering.
packages/account-sdk/src/sign/base-account/Signer.test.ts Updates/adds tests to cover 0x0 wildcard capability behavior.
packages/account-sdk/src/core/rpc/wallet_sendCalls.ts Introduces CallCapabilities and gasLimitOverride types for wallet_sendCalls.
packages/account-sdk/src/core/rpc/wallet_prepareCalls.ts Extends PrepareCallsCall to include per-call capabilities.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ajhodges ajhodges marked this pull request as ready for review March 4, 2026 21:12
// Filter capabilities
const filteredCapabilities = Object.fromEntries(
Object.entries(capabilities).filter(([capabilityKey]) => {
if (capabilityKey === '0x0') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

would prefer a named const for 0x0 to highlight significance

} from '../utils.js';
import { createSmartAccount } from './createSmartAccount.js';

function validateGasLimitOverrides(calls: { capabilities?: CallCapabilities }[]): void {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we only run this validation for sub account sendCalls requests?

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.

4 participants