From c6c62acf59292d53b97b981acfc7924d41e55c33 Mon Sep 17 00:00:00 2001 From: Christian Krueger Date: Thu, 27 Feb 2025 09:59:42 -0600 Subject: [PATCH] little fix --- core/src/account_payer.rs | 25 +++++++------------------ core/src/epoch_marker.rs | 5 +++-- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/core/src/account_payer.rs b/core/src/account_payer.rs index 27979c6e..2f054430 100644 --- a/core/src/account_payer.rs +++ b/core/src/account_payer.rs @@ -12,12 +12,16 @@ pub struct AccountPayer {} impl AccountPayer { pub fn seeds(ncn: &Pubkey) -> Vec> { - vec![b"account_payer".to_vec(), ncn.to_bytes().to_vec()] + // Note: The second NCN is an error from the original code, most presumably a copy/paste or Claude error + vec![ + b"account_payer".to_vec(), + ncn.to_bytes().to_vec(), + ncn.to_bytes().to_vec(), + ] } pub fn find_program_address(program_id: &Pubkey, ncn: &Pubkey) -> (Pubkey, u8, Vec>) { - let mut seeds = Self::seeds(ncn); - seeds.push(ncn.to_bytes().to_vec()); + let seeds = Self::seeds(ncn); let (address, bump) = Pubkey::find_program_address( &seeds.iter().map(|s| s.as_slice()).collect::>(), program_id, @@ -172,21 +176,6 @@ mod tests { use super::*; - #[test] - fn test_seeds() { - let ncn = Pubkey::new_unique(); - let seeds = AccountPayer::seeds(&ncn); - - // Verify we get exactly 2 seeds - assert_eq!(seeds.len(), 2); - - // Verify first seed is the string literal - assert_eq!(seeds[0], b"account_payer".to_vec()); - - // Verify second seed is the pubkey bytes - assert_eq!(seeds[1], ncn.to_bytes().to_vec()); - } - #[test] fn test_find_program_address() { let program_id = Pubkey::new_unique(); diff --git a/core/src/epoch_marker.rs b/core/src/epoch_marker.rs index a55f9653..fdb031f3 100644 --- a/core/src/epoch_marker.rs +++ b/core/src/epoch_marker.rs @@ -44,10 +44,12 @@ impl EpochMarker { } pub fn seeds(ncn: &Pubkey, epoch: u64) -> Vec> { + // Note: The second NCN is an error from the original code, most presumably a copy/paste or Claude error vec![ b"epoch_marker".to_vec(), ncn.to_bytes().to_vec(), epoch.to_le_bytes().to_vec(), + ncn.to_bytes().to_vec(), ] } @@ -56,8 +58,7 @@ impl EpochMarker { ncn: &Pubkey, epoch: u64, ) -> (Pubkey, u8, Vec>) { - let mut seeds = Self::seeds(ncn, epoch); - seeds.push(ncn.to_bytes().to_vec()); + let seeds = Self::seeds(ncn, epoch); let (address, bump) = Pubkey::find_program_address( &seeds.iter().map(|s| s.as_slice()).collect::>(), program_id,