Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Add remaining CLI functionality for SPL Token Group #5937

Closed
buffalojoec opened this issue Dec 1, 2023 · 8 comments
Closed

Add remaining CLI functionality for SPL Token Group #5937

buffalojoec opened this issue Dec 1, 2023 · 8 comments
Labels
good first issue Good for newcomers

Comments

@buffalojoec
Copy link
Contributor

Problem

As of #5911 and #5912, the SPL Token CLI supports adding GroupPointer and GroupMemberPointer to Token2022 mints. However, there's no CLI support for adding the actual TokenGroup or TokenGroupMember extensions to mints.

Solution

Add the necessary commands!

@buffalojoec buffalojoec added the good first issue Good for newcomers label Dec 1, 2023
@github-project-automation github-project-automation bot moved this to Needs triage in SPL Token 22 Dec 1, 2023
@joncinque joncinque moved this from Needs triage to Token Clients in SPL Token 22 Dec 1, 2023
@tonton-sol
Copy link
Contributor

Can you expand on what is needed for this? Is this not taken care of by the --enable-group flag?

@buffalojoec
Copy link
Contributor Author

@tonton-sol All of the Token Group support should be present in the Token Client, but we don't have it in the CLI yet. If you take a look at Token Metadata for reference, we're basically just setting up clap commands for driving the Token Client and using those functions!

async fn command_initialize_metadata(

The CLI only has the ability to create Group and Group Member pointers. You can pass an address or use --enable-group or --enable-member to set the pointer to the mint itself. You can't run InitializeGroup or the others from the interface.

ad86abe

@tonton-sol
Copy link
Contributor

Understood, I didn't catch that. I'll take a look at it!

@tonton-sol
Copy link
Contributor

tonton-sol commented Jan 15, 2024

A few questions:

  1. spl-token initialize-group should only invoke token_group_initialize_with_rent_transfer()? and requires the mint and size?
  2. spl-token initialize-member should only invoke token_group_initialize_memeber_with_rent_transfer() and requires the mint and group-mint?
  3. Should I also add the cli functionality for updating? Or should that be in a separate PR?

@tonton-sol
Copy link
Contributor

Also, I want to make sure I understand the spirit of the extensions based on reading the tests. You can create a group account then initialize it with a size. That size is the max number of members, say 10. You can then create a member, then initialize it with the group-mint. This gives 1 member. You can then use the member pointer extension, point to the first member mint and create the remaining 9. If you want to create another separate but related group of 10 members, you would use a group pointer. Then you would need to create and initialize a new member mint and initialize it, and repeat the process for minting the member pointers. Is this correct?

@buffalojoec
Copy link
Contributor Author

buffalojoec commented Jan 15, 2024

Also, I want to make sure I understand the spirit of the extensions based on reading the tests. You can create a group account then initialize it with a size. That size is the max number of members, say 10.

Correct! Max size is maximum number of members.

You can then create a member, then initialize it with the group-mint. This gives 1 member. You can then use the member pointer extension, point to the first member mint and create the remaining 9.

You've got this one backwards. You first add MemberPointer when you create the mint for the group member. After the mint is created, you can initialize_group_member with both the group and member mints, thus initializing it as a member of the provided group. The group's authority is required here since the group is writable, and that current count of "number of member" (or size) is incremented in the group.

If you want to create another separate but related group of 10 members, you would use a group pointer. Then you would need to create and initialize a new member mint and initialize it, and repeat the process for minting the member pointers. Is this correct?

I don't think I'm 100% clear on what you're asking here, but it sounds like you're referring to making sub-groups. If so, you'd basically have something like this:

  1. Create the parent group
  2. Create the child group, which is a member of the parent group
  3. Create the members of the child group

In other words:

parent group
            ====== child member
                   child group
                                ====== grandchild member

In this case, you'd have the following extensions:

  1. GroupPointer | TokenGroup
  2. GroupPointer, MemberPointer | TokenGroup, TokenGroupMember
  3. MemberPointer | TokenGroupMember

I guess this makes me realize I don't believe the client allows for 2), but the program does. We probably need to add that functionality.

@buffalojoec
Copy link
Contributor Author

A few questions:

  1. spl-token initialize-group should only invoke token_group_initialize_with_rent_transfer()? and requires the mint and size?
  2. spl-token initialize-member should only invoke token_group_initialize_memeber_with_rent_transfer() and requires the mint and group-mint?
  3. Should I also add the cli functionality for updating? Or should that be in a separate PR?

Yep 1) and 2) are correct. For 3), yeah let's add one at a time per PR! So first one can be command_initialize_group.

@buffalojoec
Copy link
Contributor Author

Thanks @tonton-sol !! This should be all wrapped!

@github-project-automation github-project-automation bot moved this from Token Clients to Closed in SPL Token 22 Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers
Projects
Status: Closed
Development

No branches or pull requests

2 participants