Add CLI tool for asset management and improve documentation#1715
Add CLI tool for asset management and improve documentation#1715drqsatoshi wants to merge 6 commits intoMetaMask:masterfrom
Conversation
- Implemented a test to ensure that the old icon is removed when the asset's image format changes from PNG to SVG. - Added a test to verify that the CLI does not crash when the metadata.logo field is missing. - Included cleanup logic to remove temporary files and directories created during tests.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Caution MetaMask internal reviewing guidelines:
|
| const CAIP19Schema = z.string().regex( | ||
| /^[-a-z0-9]{3,8}:[-a-zA-Z0-9]{1,32}\/[-a-z0-9]{3,8}:[a-zA-Z0-9]+$/, | ||
| 'Invalid CAIP-19 format. Expected: namespace:chainId/assetNamespace:assetReference' | ||
| ); |
There was a problem hiding this comment.
CAIP-19 regex rejects valid asset references with hyphens
Medium Severity
The CAIP19Schema regex uses [a-zA-Z0-9]+ for the asset reference segment, but the CAIP-19 specification defines asset references as [-a-zA-Z0-9]{1,64}. The regex is missing the hyphen character class and the max-length constraint. This causes the tool to reject valid CAIP-19 identifiers whose asset references contain hyphens, which some chain ecosystems may use. The fix would be changing the trailing segment to [-a-zA-Z0-9]{1,64}.
There was a problem hiding this comment.
ooooo this is why Regex is hard. trailing commas, trailing egements.... segmentation faults suck.


Introduce a CLI tool for managing CAIP-19 contract metadata and icons, along with comprehensive documentation. This update also includes bug fixes and tests to ensure functionality, such as verifying asset integrity and handling image format changes.
Note
Medium Risk
Introduces new filesystem- and network-touching CLI behavior (downloading/writing/removing asset files) plus new dependency (
zod), which could affect contributor workflows if edge cases aren’t handled.Overview
Adds a new
cli-update-asset.jscommand-line tool to create/update, verify, and list CAIP-19 assets, including downloading icons from URLs, validating metadata withzod, and cleaning up stale icon files when formats change.Updates
package.jsonwithasset:*scripts and adds tests covering icon replacement andverifyrobustness, plus expands documentation inREADME.mdand adds AI instruction pointers (.cursorrules,CLAUDE.md,.github/copilot-instructions.md).Written by Cursor Bugbot for commit a11139b. This will update automatically on new commits. Configure here.