Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

JasonTulp
Copy link
Contributor

@JasonTulp JasonTulp commented Dec 19, 2024

Description

  • Adds the ability to rename a token within the SFT pallet. Previously the collection could be renamed only

Context & Background

  • Rich has requested this change

Related Issues


Release Notes

Key Changes

  • Adds the ability to rename a token within the SFT pallet.

Type of Change

  • Runtime Changes
  • Client Changes

Extrinsic Changes

Added

  • SFT: set_token_name

Event Changes

Added

  • SFT: TokenNameSet

Comment on lines +425 to +428
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);
Copy link
Contributor

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");
Copy link
Contributor

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() {
Copy link
Contributor

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

Copy link
Contributor

@zees-dev zees-dev left a 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.

Copy link
Contributor

@surangap surangap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

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.

4 participants