From fec8734e7a1380cc5806ddda2ee7f1248c3e1bc0 Mon Sep 17 00:00:00 2001 From: tiago Date: Thu, 24 Jul 2025 14:40:38 +0100 Subject: [PATCH 1/2] Fixed transfer-hook CLI option not allowing default Pubkey as value --- Cargo.lock | 1 + clients/cli/Cargo.toml | 1 + clients/cli/src/command.rs | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 185f5be1..5aed3b7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9934,6 +9934,7 @@ dependencies = [ "solana-transaction-status", "spl-associated-token-account-client", "spl-memo", + "spl-pod", "spl-token", "spl-token-2022 9.0.0", "spl-token-client", diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index 28619e79..75fbe2b2 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -32,6 +32,7 @@ solana-sdk = "2.2.1" solana-system-interface = "1" solana-transaction-status = "2.3.4" spl-associated-token-account-client = { version = "2.0.0" } +spl-pod = { version = "0.5.1" } spl-token = { version = "8.0", features = ["no-entrypoint"] } spl-token-2022 = { version = "9.0.0", path = "../../program", features = ["no-entrypoint"] } spl-token-client = { version = "0.16.1", path = "../rust-legacy" } diff --git a/clients/cli/src/command.rs b/clients/cli/src/command.rs index 769b1d07..8c226bb1 100644 --- a/clients/cli/src/command.rs +++ b/clients/cli/src/command.rs @@ -35,6 +35,7 @@ use { }, solana_system_interface::program as system_program, spl_associated_token_account_client::address::get_associated_token_address_with_program_id, + spl_pod::optional_keys::OptionalNonZeroPubkey, spl_token_2022::{ extension::{ confidential_transfer::{ @@ -350,9 +351,14 @@ async fn command_create_token( } if transfer_hook_program_id.is_some() || enable_transfer_hook { + let program_id: OptionalNonZeroPubkey = if let Some(program_id) = transfer_hook_program_id { + OptionalNonZeroPubkey(program_id) + } else { + OptionalNonZeroPubkey::default() + }; extensions.push(ExtensionInitializationParams::TransferHook { authority: Some(authority), - program_id: transfer_hook_program_id, + program_id: program_id.into(), }); } From 7143aa078d6aa7f23aa2357b82ca1818200473c0 Mon Sep 17 00:00:00 2001 From: tiago Date: Fri, 22 Aug 2025 12:08:21 +0100 Subject: [PATCH 2/2] review changes --- clients/cli/src/command.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/clients/cli/src/command.rs b/clients/cli/src/command.rs index 8c226bb1..de1baa4b 100644 --- a/clients/cli/src/command.rs +++ b/clients/cli/src/command.rs @@ -351,11 +351,9 @@ async fn command_create_token( } if transfer_hook_program_id.is_some() || enable_transfer_hook { - 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(); extensions.push(ExtensionInitializationParams::TransferHook { authority: Some(authority), program_id: program_id.into(),