diff --git a/src/collections/items.rs b/src/collections/items.rs index a50b75c..47448ed 100644 --- a/src/collections/items.rs +++ b/src/collections/items.rs @@ -150,7 +150,7 @@ pub async fn check_collection_items( Ok(()) } -async fn get_mint_collection<'a>( +async fn get_mint_collection( client: &AsyncRpcClient, mint: String, ) -> AnyResult<(String, Option)> { diff --git a/src/derive.rs b/src/derive.rs index 52ec1ce..17171a9 100644 --- a/src/derive.rs +++ b/src/derive.rs @@ -32,8 +32,8 @@ pub fn get_token_account_pda(mint: String, owner: Option, token_22: bool pub fn get_generic_pda(str_seeds: String, program_id: String) { let seeds: Vec> = str_seeds .split(',') - .map(|s| s.into()) - .map(pubkey_or_bytes) + .map(|s| s.trim()) + .flat_map(parse_seed) .collect(); let seeds: Vec<&[u8]> = seeds.iter().map(|seed| seed.as_slice()).collect(); @@ -43,6 +43,22 @@ pub fn get_generic_pda(str_seeds: String, program_id: String) { println!("{}", derive_generic_pda(seeds, program_id)); } +fn parse_seed(s: &str) -> Vec> { + if s.starts_with('"') && s.ends_with('"') { + // Handle quoted strings + vec![s[1..s.len() - 1].as_bytes().to_vec()] + } else if s.chars().all(|c| c.is_ascii_digit()) { + // Handle numbers: each digit becomes a separate u8 + s.chars() + .map(|c| c.to_digit(10).unwrap() as u8) + .map(|digit| vec![digit]) + .collect() + } else { + // Default to pubkey_or_bytes for other cases + vec![pubkey_or_bytes(s.to_string())] + } +} + fn pubkey_or_bytes(seed: String) -> Vec { let res = Pubkey::from_str(&seed); let value: Vec = match res { diff --git a/src/snapshot/print_editions.rs b/src/snapshot/print_editions.rs index 455a492..ba16abf 100644 --- a/src/snapshot/print_editions.rs +++ b/src/snapshot/print_editions.rs @@ -27,7 +27,7 @@ pub struct SnapshotPrintEditionsArgs { pub output: String, } -pub async fn snapshot_print_editions<'a>(args: SnapshotPrintEditionsArgs) -> Result<()> { +pub async fn snapshot_print_editions(args: SnapshotPrintEditionsArgs) -> Result<()> { let master_mint_pubkey = Pubkey::from_str(&args.master_mint)?; let master_edition_pubkey = derive_edition_pda(&master_mint_pubkey);