Skip to content

Conversation

@TaprootFreak
Copy link
Collaborator

Summary

  • Add sendCallsWithPaymaster() to metamask.hook.ts for ERC-5792 wallet_sendCalls
  • Add supportsWalletSendCalls() to check wallet capability
  • Update tx-helper.hook.ts to use Paymaster flow when usePaymaster flag is set
  • Update payment-info.tsx to check for Paymaster before legacy EIP-7702 flow

Context

The original EIP-7702 implementation using manual eth_sign is broken because MetaMask disables eth_sign by default. This PR migrates to wallet_sendCalls (ERC-5792) with Paymaster sponsorship.

New Flow

  1. Backend sets usePaymaster=true and paymasterUrl when user has 0 gas
  2. Frontend calls wallet_sendCalls with paymasterService capability
  3. MetaMask handles EIP-7702 internally and requests gas sponsorship from Paymaster
  4. Transaction is sent without user needing any ETH

Dependencies

Test plan

  • Build passes after packages update
  • MetaMask wallet_sendCalls flow works for sell
  • MetaMask wallet_sendCalls flow works for swap
  • Legacy EIP-7702 flow still works as fallback
  • Normal transaction flow still works for users with ETH

Migrate EIP-7702 from manual signing to wallet_sendCalls (ERC-5792) with Paymaster.

Changes:
- Add sendCallsWithPaymaster() to metamask.hook.ts for ERC-5792 wallet_sendCalls
- Add supportsWalletSendCalls() to check wallet capability
- Update tx-helper.hook.ts to use Paymaster flow when usePaymaster flag is set
- Update payment-info.tsx to check for Paymaster before legacy EIP-7702 flow

The new flow:
1. Backend sets usePaymaster=true and paymasterUrl when user has 0 gas
2. Frontend calls wallet_sendCalls with paymasterService capability
3. MetaMask handles EIP-7702 internally and requests gas sponsorship from Paymaster
4. Transaction is sent without user needing any ETH
Includes usePaymaster and paymasterUrl fields in UnsignedTx interface
- supportsWalletSendCalls tests (8 tests):
  - Capability detection for atomicBatch
  - Error handling for unsupported wallets

- sendCallsWithPaymaster tests (14 tests):
  - wallet_sendCalls with paymaster URL
  - Chain ID handling (Ethereum, Arbitrum, Base, Polygon)
  - Multiple calls in single transaction
  - Error scenarios (wrong network, no account)

- Error code handling tests (3 tests)
@TaprootFreak
Copy link
Collaborator Author

Closing: Frontend code is correct but requires working backend paymaster. Current backend implementation needs Pimlico integration.

See analysis: docs/PIMLICO-PAYMASTER-ANALYSIS.md

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