Skip to content

feat(relay): error + requireFunds capabilities#212

Merged
jxom merged 2 commits intomainfrom
jxom/relay-feats
Apr 15, 2026
Merged

feat(relay): error + requireFunds capabilities#212
jxom merged 2 commits intomainfrom
jxom/relay-feats

Conversation

@jxom
Copy link
Copy Markdown
Member

@jxom jxom commented Apr 15, 2026

Changes

Opt-in feature gating

Relay features are now opt-in via the features option on Handler.relay. By default, only fee payer sponsorship is active.

Set features: 'all' to enable everything:

const handler = Handler.relay({
  features: 'all',
  feePayer: {
    account: privateKeyToAccount('0x...'),
  },
})

This enables:

  • Fee token resolution — picks the best fee token by balance
  • Auto-swap — AMM swaps on insufficient fee token balance
  • Simulation — balance diffs + fee breakdown in capabilities

Individual overrides still work alongside features: 'all':

  • autoSwap: false disables auto-swap
  • autoSwap: { slippage: 0.02 } customizes slippage
  • resolveTokens enables fee token resolution independently

ExecutionError parser

New ExecutionError module that parses Tempo revert errors into structured, human-readable error reasons.

requireFunds capability

When eth_fillTransaction fails with InsufficientBalance, the relay returns a requireFunds capability with the deficit amount, token, and metadata.

Other

  • Updated relay tests to enable features where exercised.
  • Dependency bumps.

Added `mode: 'wallet' | undefined` to `Handler.relay` options.
- `mode: 'wallet'`: enables fee token resolution, auto-swap, and
  simulation (balance diffs + fee breakdown).
- Default (undefined): only fee payer sponsorship.

Features are derived into an internal `features` object and gated
at each step in `eth_fillTransaction`.

Amp-Thread-ID: https://ampcode.com/threads/T-019d8f1f-593e-72a9-83ab-36136df98e2e
@jxom jxom changed the title feat(relay): add mode option to control feature enablement feat(relay): humanized error reasons, requireFunds capabilities, and mode-based feature gating Apr 15, 2026
@jxom jxom changed the title feat(relay): humanized error reasons, requireFunds capabilities, and mode-based feature gating feat(relay): humanized error reasons, requireFunds capabilities, and opt-in feature gating Apr 15, 2026
@jxom jxom changed the title feat(relay): humanized error reasons, requireFunds capabilities, and opt-in feature gating feat(relay): error + requireFunds capabilities Apr 15, 2026
@jxom jxom merged commit bcd4ec3 into main Apr 15, 2026
2 of 9 checks passed
@jxom jxom deleted the jxom/relay-feats branch April 15, 2026 05:30
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