feat: add SVG icon support (V2)#10
Conversation
- Add svgIcons and svgIconVersions mappings for SVG storage - Add IconFormat enum (None, PNG, SVG) for format discrimination - Add setSvgIcon and setSvgIconsBatch admin functions - Add SVG validation (_validateSVG) with <svg tag check and 32KB max size - Update mapToken, mapTokensBatch, mapChain to accept PNG OR SVG icons - Add SVG getters: getSvgIcon, getSvgIconBySlug, getSvgIconByToken, etc. - Add best-icon helpers: getBestIcon, getBestIconDataURI, getBestIconByToken - Add getAvailableFormats to check PNG/SVG availability - Add comprehensive tests for all SVG functionality (26 new tests) - Add sync-web3icons.ts script for fetching web3icons SVGs - Update README with SVG usage and security documentation Closes #8 Co-Authored-By: Player 53627 <github.stagnate430@passmail.com>
Original prompt from Player 53627 |
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
📚 Contract Documentation GeneratedContract documentation has been generated from NatSpec comments. Artifacts available: Download from the Actions artifacts tab Contracts documented:
|
|
Closing due to inactivity for more than 30 days. Configure here. |
feat: add SVG icon support (V2)
Summary
This PR implements SVG icon support for the IconRegistry contract (V2), addressing issue #8. The contract now supports both PNG and SVG icons with a "best icon" API that prefers SVG when available.
Contract changes:
svgIconsandsvgIconVersionsstorage mappings (reduced__gapfrom 50 to 48)IconFormatenum (None, PNG, SVG) for format discriminationsetSvgIcon()andsetSvgIconsBatch()admin functions with 32KB max size limit_validateSVG()- checks for<svgtag in first 1KBmapToken,mapTokensBatch,mapChainto accept slugs with PNG OR SVG iconsgetSvgIcon,getSvgIconBySlug,getSvgIconByToken,getSvgChainIcon, etc.getBestIcon,getBestIconDataURI,getBestIconByToken,getBestChainIcongetAvailableFormats()to check PNG/SVG availability for a slugOff-chain tooling:
sync-web3icons.tsscript to fetch SVGs from web3icons CDNTests:
Review & Testing Checklist for Human
svgIcons,svgIconVersions) and reducing__gapfrom 50 to 48 maintains correct storage layout for UUPS upgrade from current mainnet deploymentmapToken,mapTokensBatch,mapChainnow throwNoIconAvailableinstead ofIconNotFound- confirm no existing integrations depend on catching the old error_containsSvgTagfunction only searches the first 1KB for<svgtag - verify this is sufficient or if malicious SVGs could bypass this checksync-web3icons.tsscript uses basic regex sanitization, not SVGO as documented in README - decide if this is acceptable or needs SVGO integration before useRecommended test plan:
forge testto verify all 61 tests passNotes
Closes #8
Link to Devin run: https://app.devin.ai/sessions/2e14a5bf03404cd487480690545ac356
Requested by: @igor53627