-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[framework] Display object module #7668
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
/// we don't need to perform an authorization check. | ||
/// | ||
/// Also, the only place it can be used is the function where the Display | ||
/// object was created; hence values and names are likely to be hardcoded and |
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.
I think I understand what this is saying (Move doesn't currently allow string constants and thus wannabe string constants have type vector<u8>
), but I think asking for strings is clearer/less error-prone here--a UTF8 decoding error inside this function would be puzzling.
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.
Don't we now allow String on entry
functions?
I agree though that we probably want to make these functions all take String
instead of vector<u8>
to avoid confusion.
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.
I noticed this has been merged with vector<u8>
. Are we still planning to change this to String
?
} | ||
|
||
/// Create an empty Display object. It can either be shared empty of filled | ||
/// with data right away via cheaper `set_owned` method. |
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.
Is there also a case where we'd want Display
to be single-owner or immutable rather than shared?
Intuitively, it seems like a single-owner display owned by the address that has the Publisher
cap would be the most common--you want anyone to be able to read the Display
info, but no one else needs to update it or read it on-chain.
|
||
/// Create an empty Display object. It can either be shared empty of filled | ||
/// with data right away via cheaper `set_owned` method. | ||
public fun empty<T: key>(pub: &Publisher, ctx: &mut TxContext): Display<T> { |
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.
Should this specify that it should be called at most once for a given type T
(and explain what happens if that assumption is violated)?
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.
That's a good one! I have an idea of creating a centralized registry of displays for the sake of discoverability and also uniqueness. We might handle versions there as well.
Another benefit we can get from the centralization is the ability to destroy older versions of the display and get a storage rebate (as opposed to shared objects which are not deletable yet).
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.
Can you update the comment to explain the intention?
/// we don't need to perform an authorization check. | ||
/// | ||
/// Also, the only place it can be used is the function where the Display | ||
/// object was created; hence values and names are likely to be hardcoded and |
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.
Don't we now allow String on entry
functions?
I agree though that we probably want to make these functions all take String
instead of vector<u8>
to avoid confusion.
This sounds like a great initiative and is a big step forward for display standards in SUI! I would like to structure my feedback in two, how this structure affects OriginByte NFTs and perhaps proposing an alternative approach. Displaying OriginByte NFTs thus far works based on A collection using OB NFTs does not have to use these domains and may opt to instead provide its own methods of storing display information. Since domains are indexed by type, not string, and are dynamic objects, I'm not sure if this proposal will allow for indexing into them like so: In the same vein, will dynamic fields with string keys be supported for this indexing? As I mentioned initially, we would like to propose an alternative approach. Since An initial solution that comes to mind is allowing entry functions (or view functions) to return view structs that contain fields otherwise available in the These view functions would run immutably and be limited in complexity, and be run on the same module that would otherwise populate the template fields in |
Hey @Suficio! Thank you for your feedback. I've replied on the Sui Developers (link to the reply). Hopefully this answers all of the topics raised in your question, please feel free to disagree or ask if anything is unclear. |
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.
Suggesting changes to add a version field + more tests, but otherwise LGTM!
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.
LGTM pending tests!
/// we don't need to perform an authorization check. | ||
/// | ||
/// Also, the only place it can be used is the function where the Display | ||
/// object was created; hence values and names are likely to be hardcoded and |
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.
I noticed this has been merged with vector<u8>
. Are we still planning to change this to String
?
let i = 0; | ||
while (i < 0) { |
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.
Uh this should be while (i < len)
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.
Good catch! Thank you!
## Description This PR adds the RPC support for #7668 and added e2e TS tests Todos(in separate PRs) - [ ] merge the display endpoint into the[ new queryObjects API](https://www.notion.so/mystenlabs/RFC-GetObjects-API-Refactoring-27ff6b8d6ffc42c8b492c1efa368b70a?pvs=4) - [ ] Handle struct that has no Display defined `Overall display should be treated as Debug and Display traits in Rust. If we don’t have Display defined, we show default debug (on the FE/Apps), if there’s Display, we show things nicely.` I'll implement this when we implement the new queryObjects API - [ ] Add rust based tests ## Test Plan How did you test the new or updated feature? Added e2e TS tests to cover the following test cases - Escape syntax (e.g., `\{name\}` should return `{name}` instead of `Alice` even if there's a field called Alice) - Nested fields - multiple fields - option::some and option::none - no template value - sui address - UID - `sui::url::Url` type --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
@damirka Hi, is there any update regarding template syntax (df or dynamic_field_key)? |
Hey @jovicheng. We're at full capacity already; more updates will be coming next year. But yes, df and vectors and a lot more will be there! |
Thank you for your reply. I would like to confirm again, currently, this feature is not supported, correct? |
Correct, you can't fetch dynamic fields just yet. |
thanks, looking forward to this new features." |
sui::display
module which allows setting a display for theT
by the publisher of theT