-
Notifications
You must be signed in to change notification settings - Fork 70
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
Use TS ? to replace option in nft standard interface #304
Conversation
@volovyks Ready for review. workspace starts to hit "key not found" error again, and pass on retrying. Not sure it worth investigaing. |
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.
So, what is the behavior in Rust?
If the field is Optional and None, how it will be represented in a view function? Should we strive for the same behavior here?
this.base_uri = null; | ||
this.reference = null; | ||
this.reference_hash = null; | ||
this.icon = undefined; |
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 there is no point to set it to undefined. It's undefined by default.
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 point! In rust, json with these field are returned, with null as value. so I'll change it to null.
@@ -45,10 +44,10 @@ export class NFTContractMetadata { | |||
assert_valid() { | |||
assert(this.spec == NFT_METADATA_SPEC, "Spec is not NFT metadata"); | |||
assert( | |||
(this.reference != null) == (this.reference_hash != null), | |||
(this.reference !== undefined) == (this.reference_hash !== undefined), |
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.
What will happen if it is null? Should we check for it?
"Reference and reference hash must be present" | ||
); | ||
if (this.reference_hash != null) { | ||
if (this.reference_hash !== undefined) { |
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.
Same here and in other places.
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.
Ok, I think my concerns about null vs undefined should be ok because we are initializing everything with null in the constructor.
Fix #289