-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add set_token_name to SFT pallet #914
base: main
Are you sure you want to change the base?
Conversation
let mut token_info = TokenInfo::<T>::get(token_id).ok_or(Error::<T>::NoToken)?; | ||
token_info.token_name = token_name.clone(); | ||
|
||
TokenInfo::<T>::insert(token_id, token_info); |
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.
nit: can get and set - using mutate:
TokenInfo::<T>::try_mutate(token_id, |maybe_token_info| -> DispatchResult {
let token_info = maybe_token_info.as_mut().ok_or(Error::<T>::NoToken)?;
token_info.token_name = token_name.clone();
Ok(())
})?;
set_token_name { | ||
let owner = account::<T>("Alice"); | ||
let token_id = build_token::<T>(Some(owner.clone()), 1); | ||
let token_name = bounded_string::<T>("Token"); |
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 test max string limit as that would be testing upperbound of the extrinsic weight
use super::*; | ||
|
||
#[test] | ||
fn set_name_works() { |
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.
would also be good to validate event is emitted as part of this success test
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 weight calc should be looked at - so we estimate the upperbound instead.
Other suggestions are optional.
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
Description
Context & Background
Related Issues
Release Notes
Key Changes
Type of Change
Extrinsic Changes
Added
Event Changes
Added