Skip to content

Fixed --transfer-hook CLI option not allowing default Pubkey as value #605

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tiago18c
Copy link
Contributor

Running spl-token create-token --program-2022 --transfer-hook 11111111111111111111111111111111 would error out, when its expected to be a valid value that represents the lack of a transfer-hook program. This PR fixes this.

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.

Just a nit, then we can get this in, thanks for the contribution!

Comment on lines +354 to +358
let program_id: OptionalNonZeroPubkey = if let Some(program_id) = transfer_hook_program_id {
OptionalNonZeroPubkey(program_id)
} else {
OptionalNonZeroPubkey::default()
};
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it would be a bit simpler to use unwrap_or_default(), ie

Suggested change
let program_id: OptionalNonZeroPubkey = if let Some(program_id) = transfer_hook_program_id {
OptionalNonZeroPubkey(program_id)
} else {
OptionalNonZeroPubkey::default()
};
let program_id = transfer_hook_program_id.map(OptionalNonZeroPubkey).unwrap_or_default();

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.

2 participants