Add comprehensive test coverage for intent validation#1
Merged
muhammadaus merged 17 commits intomainfrom Feb 14, 2026
Merged
Conversation
- Node.js test framework for browser-based decoders - Tests for core decode.js, recursive-decoder.js, advanced-decoder.js - Protocol test suites: Uniswap, Aave, Compound, Lido, Seaport, 1inch - Account abstraction tests: Safe, ERC-4337, EIP-7702 - Local metadata service for offline testing - Human-readable test output with ANSI colors - Scripts for fetching real mainnet transactions and metadata Test coverage: - 25/28 tests passing (89.3%) - All Uniswap Universal Router COMMANDS - EIP-7702 delegation parsing - Safe multiSend decoding 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Real calldata from tx 0xf82a7507... with executeMultiple - Contains 2 nested calls: USDC approve + Fluid deposit - Test validates EIP-7702 type detection and authorization parsing - All 5 EIP-7702 tests now passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use real authorization list from tx 0xf82a7507... - Update fetch-transactions to use Alchemy RPC - Update to Etherscan V2 API format - 26/29 tests passing (89.7%) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add USDC metadata for selector tests - Fix test harness to handle expected failures correctly - All core, protocol, and account abstraction tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add {amount} template variables to Aave, Compound, Lido, 1inch, 0x
- Create token-registry.js for symbol/decimals lookup
- Update decode.js substituteIntentTemplate() for nested paths
- Add USDC + Fluid metadata to EIP-7702 test
- All 33 tests passing with formatted values
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add substituteIntentTemplate method to advanced decoder - Fix decodeParametersWithFieldPaths to handle object results from ABI decoding - Add formatTokenAmountWithParams for proper decimal formatting - Include field.params in extractFieldInformation for token decimals/symbol - All 33 tests passing with formatted values like "Approve 0.05 USDC + Deposit 0.05 to Fluid" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1. Fix BigInt conversion error for unlimited approvals: - Detect scientific notation (e.g., "1.157920892373162e+77") before BigInt conversion - Detect MAX_UINT256 and return "Unlimited" instead of crashing 2. Fix ParaSwap tuple offset decoding: - Update isDynamicType() to check if tuple has dynamic components - Add tuple handling to decodeDynamicType() for dynamic tuples - Tuples with bytes/arrays/strings are now properly decoded from tail offset All 33 tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add comprehensive validators to catch metadata errors: - Exact intent matching (not just substring) - Negative validation (prevent raw max uint256) - Command array validation (Uniswap opcodes) - Enhanced nested intent validation (AA operations) Updated 34 tests across 14 test files: - Core decode tests with exact intent + amount validation - Uniswap tests with command registry validation - AA tests (ERC-4337, EIP-7702, Safe) with nested intent arrays - Protocol tests (1inch, 0x, Aave, Compound, Lido, ParaSwap, CoW, Seaport) All 34 tests passing (100% success rate). 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Automatically runs tests on: - Push to main or test-decoding branches - Pull requests to main Features: - Tests on Node.js 18.x and 20.x - Uploads test artifacts for debugging - Uses repository secrets for API keys 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…e symbols - Fix "Execute 0" bug: Skip value injection when value is zero (decode.js:597-610) - Fix calleePath resolution: Handle both JSONPath "$.to" and simple field names "to" (recursive-decoder.js:244-254) - Fix duplicate symbol bug: Detect and strip duplicate token symbols like "USDC USDC" (decode.js:858-870) - Add Safe execTransaction test with value=0 validation - Add duplicate symbol test using real USDC fixture - Add LiFi protocol tests with metadata fixture including calldata field for nested decoding 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add interpolatedIntent detection in format parsing (line 421)
- Add interpolated intent type handling (lines 596-601)
- Update substituteIntentTemplate to support ERC-7730 path syntax:
- Support #. prefix for parameter paths
- Support array index notation [0], [1] etc
- Handle paths like {#._swapData.[0].fromAmount}
- Now displays "Swap 0.20 USDC to ETH" instead of "Swap USDC to ETH"
Per ERC-7730 spec lines 244-249 and 835: - Wallet MUST locate corresponding field format specification - Wallet MUST apply field's format and params to format the value - Wallet MUST replace interpolation expression with formatted value Implementation: - substituteInterpolatedIntent(): Main processor per spec requirements - resolveFieldPath(): Navigate ERC-7730 paths like #._swapData.[0].fromAmount - applyFieldFormat(): Apply tokenAmount, addressName, etc. formats - Supports array indices [0], nested tuples, container paths Now displays "Swap 0.20 USDC to ETH" with actual formatted amounts
- Add KNOWN_TOKENS registry with USDC, USDT, DAI, WETH, WBTC, etc. - Replace hardcoded USDC with dynamic token lookup - Support native ETH addresses (0x0, 0xeee...) - Show shortened address for unknown tokens (0x1234...5678) - Works for ALL token pairs in registry, not just USDC
- Fix tuple[] dynamic type detection by passing input to isDynamicType() - Arrays of tuples with dynamic components (bytes, string) now decode correctly - Fixes LiFi swapTokensMultipleV3ERC20ToNative field offset bug - Remove hardcoded KNOWN_TOKENS registry - Fetch token metadata from Railway API instead of hardcoded values - Make applyFieldFormat async for API-based token lookups - Make substituteInterpolatedIntent async with parallel token fetches - Handle BigNumber objects from ethers.js in value conversion 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Sync metadata files from Kai-Sign-Builder/backend/metadata: - 1inch-router-v6.json: Added tokenAmount format with tokenPath - paraswap-augustus-v6.json: Added short tuple signature and interpolatedIntent - lifi-diamond.json: Updated to full backend version (3821 lines) - cow-protocol-settlement.json: Updated to backend version - Safe metadata (singleton, proxy-factory, multisend, proxy): Updated formats - Add symbol/decimals to tokens/usdc.json for proper token metadata lookup - Fix LiFi test selector (0xd24c2325 → 0x2c57e884 for swapTokensMultipleV3ERC20ToNative) - ParaSwap now shows interpolated intent: "Swap 1.00 USDC via ParaSwap" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extension changes: - Remove duplicate formatTokenAmount from content-script.js (uses decode.js) - Add rawParams to decoder return object - UI styling improvements for popup Metadata updates: - Add interpolatedIntent to 0x, 1inch, CoW, ParaSwap, LiFi - Add WETH token metadata - Update test expectations for new intent formats Test improvements: - Add types-advanced.test.js for edge cases - Expand recursive decoder tests - Add Uniswap Universal Router tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
6c91355 to
5cddde5
Compare
- Selector: 0xe3ead59e - Signature: swapExactAmountIn(address,tuple,uint256,bytes,bytes) - Added ABI with tuple components (srcToken, destToken, fromAmount, toAmount, etc.) - Added display format with interpolatedIntent 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
Validators Added
expected.intent) - Validates full intent text, not just substringsexpected.intentDoesNotContain) - Ensures raw values like max uint256 don't appearexpected.decodedCommands) - Validates Uniswap command opcodes and namesexpected.nestedIntents) - Validates nested operation structuresTest Coverage Improvements
Why This Matters
Previous tests used weak substring matching that allowed wrong metadata to pass. For example:
0xf0instead of0x00intentContains: 'Wrap'Now breaking metadata changes are caught immediately by test failures.
CI/CD Workflow
🤖 Generated with Claude Code