-
Notifications
You must be signed in to change notification settings - Fork 34
feat: add register ssri method #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: releases/udt
Are you sure you want to change the base?
Conversation
ashuralyk
commented
Jan 9, 2026
- I have read the Contributing Guidelines
|
✅ Deploy Preview for docsccc ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for apiccc ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for liveccc ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Summary of ChangesHello @ashuralyk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the UDT package by introducing a dedicated Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
✅ Deploy Preview for appccc ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a register method for UDTs through a new UdtRegister class. The implementation looks solid, providing both an SSRI-based registration path and a fallback to a standard Type ID-based creation. I've provided a few suggestions to improve code clarity, maintainability, and documentation accuracy. Key points include removing a redundant check, replacing a magic string with a constant, correcting a misleading example in the documentation, and adding clarification for a method parameter's constraints. The most critical feedback is to fix the documentation example to prevent user confusion.
| * const udt = new Udt(codeOutPoint, scriptConfig); | ||
| * const { tx, tokenHash } = await udt.register( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example is incorrect. It instantiates Udt instead of UdtRegister, but the register method is part of the UdtRegister class. Additionally, the UdtRegister constructor requires an executor in its configuration, which is missing from the example.
| * const udt = new Udt(codeOutPoint, scriptConfig); | |
| * const { tx, tokenHash } = await udt.register( | |
| * const udtRegister = new UdtRegister(codeOutPoint, scriptConfig, { executor }); | |
| * const { tx, tokenHash } = await udtRegister.register( |
| metadata: { | ||
| name: string; | ||
| symbol: string; | ||
| decimals: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The decimals property is encoded as a Uint8, meaning its value must be an integer between 0 and 255. The current type number is too broad and doesn't communicate this important constraint. Adding a JSDoc comment will help developers use this method correctly and prevent potential runtime errors.
| decimals: number; | |
| /** Must be an integer between 0 and 255. */ | |
| decimals: number; |
| if (this.executor) { | ||
| const res = await this.executor.runScriptTry( | ||
| this.code, | ||
| "SSRIUDT.create", | ||
| [ | ||
| register.toBytes(), | ||
| ccc.Script.from(owner.script).toBytes(), | ||
| UdtMetadata.encode(metadata), | ||
| ], | ||
| ); | ||
| if (res) { | ||
| resTx = res.map((res) => ccc.Transaction.fromBytes(res)); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UdtRegister constructor requires an executor to be present in the config, making this.executor always defined within this class. The if (this.executor) check is therefore redundant. You can simplify the code by removing this conditional check. The SSRI path will always be attempted, and the fallback logic will still be correctly triggered if runScriptTry returns undefined.
const res = await this.executor.runScriptTry(
this.code,
"SSRIUDT.create",
[
register.toBytes(),
ccc.Script.from(owner.script).toBytes(),
UdtMetadata.encode(metadata),
],
);
if (res) {
resTx = res.map((res) => ccc.Transaction.fromBytes(res));
}| lock: owner.script, | ||
| type: { | ||
| codeHash: | ||
| "00000000000000000000000000000000000000000000000000545950455f4944", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
