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

token-cli: add command for updating metadata address #4810

Merged
merged 11 commits into from
Jul 21, 2023

Conversation

sanjsingh07
Copy link
Contributor

resolved #4701

@mergify mergify bot added the community Community contribution label Jul 18, 2023
@sanjsingh07 sanjsingh07 changed the title resolved https://github.com/solana-labs/solana-program-library/issues/4701 Created top-level command for updating metadata address Jul 18, 2023
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! A few bits to firm up the interface, and also, could you add a test for this? You can use the existing metadata_pointer() test for creating, and then just add a step where you update the metadata address, and check that the change was properly propagated.

.arg(owner_address_arg())
.arg(multisig_signer_arg())
.nonce_args(true)
.offline_args(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can remove the offline args, since the instruction doesn't support sign-only

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Defaults to the client keypair.",
),
)
.arg(owner_address_arg())
Copy link
Contributor

Choose a reason for hiding this comment

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

You're using the authority arg and not the owner arg, so this can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

.validator(is_valid_signer)
.takes_value(true)
.help(
"Specify the token's authority. \
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Let's be clear

Suggested change
"Specify the token's authority. \
"Specify the token's metadata-pointer authority. \

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Comment on lines 3667 to 3675
.arg(
Arg::with_name("metadata_address")
.long("metadata-address")
.value_name("ADDRESS")
.takes_value(true)
.help(
"Specify address that stores token metadata."
),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will introduce a footgun. As it stands, if someone just accidentally forgets to put in a metadata address, the command will clear it.

Instead, this should look like the new_authority flag in Authorize, where someone can specify --disable to clear the metadata pointer address. Then if --disable is not provided, the metadata_address argument is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@@ -3624,6 +3652,44 @@ fn app<'a, 'b>(
.nonce_args(true)
.offline_args(),
)
.subcommand(
SubCommand::with_name(CommandName::UpdateMetadataPointerAddress.into())
.about("Updates default account state for the mint. Requires the default account state extension.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.about("Updates default account state for the mint. Requires the default account state extension.")
.about("Updates metadata pointer address for the mint. Requires the metadata pointer extension.")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

.takes_value(true)
.index(1)
.required(true)
.help("The address of the token mint to update default account state"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.help("The address of the token mint to update default account state"),
.help("The address of the token mint to update the metadata pointer address"),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@@ -144,6 +144,7 @@ pub enum CommandName {
EnableCpiGuard,
DisableCpiGuard,
UpdateDefaultAccountState,
UpdateMetadataPointerAddress,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit for ease of use

Suggested change
UpdateMetadataPointerAddress,
UpdateMetadataAddress,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@joncinque joncinque changed the title Created top-level command for updating metadata address token-cli: add command for updating metadata address Jul 18, 2023
@sanjsingh07
Copy link
Contributor Author

updated metadata_pointer() to have update-metadata-pointer address test case.
image

@sanjsingh07 sanjsingh07 requested a review from joncinque July 20, 2023 04:54
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

We're almost there! When you add the disable flag, can you add one more step to the test to disable the metadata pointer?

token/cli/src/main.rs Show resolved Hide resolved
token/cli/src/main.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

One last bit then this should be good to go!

)
.arg(
Arg::with_name("metadata_address")
.index(2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add .validator(is_valid_pubkey) for this arg too? Otherwise, if someone inputs an invalid pubkey, it'll disable the metadata pointer address!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yupp, Done! and also sorry about this many commits. :)

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for your patience! I'll ping you if CI has any issues.

And a lot of commits is really good, it makes it much easier for me to review. Do avoid merge commits in the future though, and prefer rebasing + force-pushing your branch whenever you need to.

@joncinque joncinque merged commit 6108baa into solana-labs:master Jul 21, 2023
@joncinque
Copy link
Contributor

All good, thanks for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

token-cli: Support updating metadata pointer extension
2 participants