Conversation
Switches the wrap-token command to `wrap_token_v2` and adds an optional `--uri`, validated against `MAX_URI_LEN` read from the IDL. The length check counts UTF-8 bytes to match the onchain check. The metadata hash preimage is deliberately left alone, mirroring `PartialTokenMetadata::hash`, so the derived mint still matches the program's. Co-authored-by: Cursor <cursoragent@cursor.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.
Part 3 of 3. Stacked on #200, which in turn sits on #199. Review those first; the diff here shrinks to two files once they merge.
What's in it
The wrap-token command now calls
wrap_token_v2and takes an optional--uri, which is what serves a wrapped token's icon and description. Leaving it blank still works and produces a token without either, matching today's behavior.Validation lives in the zod schema so the flag path and the interactive prompt share one definition, with the prompt surfacing the schema's own message. The length check counts UTF-8 bytes rather than characters, to match the onchain check, which measures
uri.len()on a RustString.MAX_URI_LENis read from the IDL viagetIdlConstantrather than duplicated here.Worth a look during review
The metadata hash preimage in the handler is deliberately left alone. It has to mirror
PartialTokenMetadata::hashon the program side, which excludesuri, or the script derives a mint address the program will not recognize. There's a comment to that effect at the call site.Because a wrapped token's metadata is immutable after creation, whatever uri is passed here is permanent for that token.
Verification
scriptstypechecks and the CLI loads on this branch, with--uripresent inwrap-token --help.