Skip to content

feat(scripts): accept a metadata uri when wrapping a token - #201

Draft
jackchuma wants to merge 1 commit into
jack/wrapped-token-uri-clientfrom
jack/wrapped-token-uri-cli
Draft

jackchuma wants to merge 1 commit into
jack/wrapped-token-uri-clientfrom
jack/wrapped-token-uri-cli

Conversation

@jackchuma

Copy link
Copy Markdown
Collaborator

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_v2 and 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 Rust String. MAX_URI_LEN is read from the IDL via getIdlConstant rather than duplicated here.

Worth a look during review

The metadata hash preimage in the handler is deliberately left alone. It has to mirror PartialTokenMetadata::hash on the program side, which excludes uri, 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

scripts typechecks and the CLI loads on this branch, with --uri present in wrap-token --help.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant