feat: wallet mode — DeFi testing with MetaMask + Anvil fork#15
Merged
feat: wallet mode — DeFi testing with MetaMask + Anvil fork#15
Conversation
Automated wallet/DeFi flow testing against MetaMask + Anvil mainnet fork: - setup-extension.mjs: download MetaMask from GitHub releases - setup-onboarding.mjs: automate MetaMask 13.x SRP import (CDP for LavaMoat bypass) - setup-anvil.mjs: start Anvil fork, seed 100 ETH + 10 WETH + 10k USDC - run-wallet-validation.mjs: orchestrate wallet case runs via CLI - DeFi cases: connect/swap/supply against Uniswap, Aave, 1inch, SushiSwap - Tangle cases: connect, stake, bridge flows - CLAUDE.md: document wallet patterns and setup commands
DApps use their own RPC endpoints (Infura, QuikNode, Tenderly, or
self-hosted on their own domain) for balance/contract reads. This adds
a Playwright context.route('**/*') interceptor that detects JSON-RPC
POST requests (eth_*/net_*/web3_* methods) and proxies them to the
configured wallet chain RPC URL (e.g. local Anvil fork).
Also adds configure-network.mjs to set MetaMask's default RPC endpoint
to Anvil via direct LevelDB modification, and the wallet:configure
npm script.
DeFi validation: 5/7 pass (all 5 connect cases, Uniswap swap).
…alog bypass - Inject DeFi-specific brain context on first turn when wallet mode is active (transaction flows, persistent widgets, token selection, cookie banners) - Make wallet address configurable via wallet.address config instead of hardcoded Anvil default — enables custom mnemonics and HD paths - Hybrid RPC interception: only forward user-specific calls (eth_getBalance, eth_call, eth_estimateGas with wallet addr) to Anvil; pool/protocol data goes to real endpoints - JSON-RPC normalization for non-standard dApp requests (Aave omits jsonrpc/id fields) - Persistent dialog bypass in recovery: skip generic modal recovery after 3+ consecutive turns with same dialog — fixes SushiSwap support widget loops - Auto-restart Anvil with fresh fork state in validation runner - Add RPC reverse proxy for MetaMask service worker interception - Expand wallet.md guide: architecture, DeFi patterns, RPC interception details, troubleshooting, "Testing Your Own EVM App" section - Validated 7/7 DeFi cases: Uniswap, Aave, 1inch, SushiSwap ($0.98, 267s)
All three workflows were failing on PRs: - ci.yml: missing Playwright browser install before test step - tier1-gate.yml: hard fail when OPENAI_API_KEY unavailable on forks/PRs - tier2-staging-gate.yml: hard fail when secrets unavailable on forks/PRs Now warns and skips gate steps when secrets are missing instead of failing.
…tests - Add .rpc-proxy-cert/ and .rpc-proxy.pid to .gitignore - Fix JSON injection in rpc-proxy.mjs error response (use JSON.stringify) - Fix dead code in cli.ts RPC normalization (flip spread order) - Extract DeFi brain context to module-level constant in runner.ts - Add 3 tests for persistent dialog bypass in recovery.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
context.route('**/*')forwards only user-specific JSON-RPC calls (eth_getBalance, eth_call, eth_estimateGas containing wallet address) to Anvil — pool/protocol data goes to real endpoints for reliability. Includes JSON-RPC normalization for non-standard dApp formats (Aave omits jsonrpc/id fields)walletMode: true, injects crypto-specific guidance into the agent's first-turn context — transaction flows, persistent widget handling, token selection, cookie banner dismissalwallet.addressconfig option replaces hardcoded Anvil default — supports custom mnemonics/HD pathsdocs/guides/wallet.mdexpanded from config reference to full EVM testing playbook — architecture diagram, "Testing Your Own EVM App" section, RPC interception details, DeFi patterns, troubleshootingValidated: 7/7 DeFi cases pass (Uniswap, Aave, 1inch, SushiSwap — connect + swap/supply flows), $0.98 total, 267s.
Test plan
pnpm lint— type-check passespnpm check:boundaries— architecture boundaries passpnpm test— 549/549 unit + integration tests passpnpm wallet:validate— 7/7 DeFi cases pass on fresh Anvil fork