Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ sdks/ts/docs-html/
sdks/ts/docs-md/

# AI
.claude/helpers/
.claude/
36 changes: 34 additions & 2 deletions crates/lib/src/admin/token_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use solana_sdk::{
use spl_associated_token_account::{
get_associated_token_address, instruction::create_associated_token_account,
};
use std::{str::FromStr, sync::Arc};
use std::{fmt::Display, str::FromStr, sync::Arc};

#[cfg(not(test))]
use {crate::cache::CacheUtil, crate::state::get_config};
Expand All @@ -38,6 +38,12 @@ pub struct ATAToCreate {
pub token_program: Pubkey,
}

impl Display for ATAToCreate {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Token {}: ATA {} (Token program: {})", self.mint, self.ata, self.token_program)
}
}

/// Initialize ATAs for all allowed payment tokens for the paymaster
/// This function initializes ATAs for ALL signers in the pool
///
Expand Down Expand Up @@ -93,7 +99,7 @@ pub async fn initialize_atas_with_chunk_size(

if atas_to_create.is_empty() {
println!("✓ All required ATAs already exist for address: {address}");
return Ok(());
continue;
}

create_atas_for_signer(
Expand Down Expand Up @@ -204,13 +210,39 @@ async fn create_atas_for_signer(
created_atas_idx = chunk_end;
}
Err(e) => {
println!("✗ Chunk {chunk_num}/{num_chunks} failed: {e}");

if created_atas_idx > 0 {
println!("\nSuccessfully created ATAs ({created_atas_idx}/{total_atas}):");
println!(
"{}",
atas_to_create[0..created_atas_idx]
.iter()
.map(|ata| format!(" ✓ {ata}"))
.collect::<Vec<String>>()
.join("\n")
);
println!("\nRemaining ATAs to create: {}", total_atas - created_atas_idx);
} else {
println!("No ATAs were successfully created.");
}

println!("This may be a temporary network issue. Please re-run the command to retry ATA creation.");
return Err(KoraError::RpcError(format!(
"Failed to send ATA creation transaction for chunk {chunk_num}/{num_chunks}: {e}"
)));
}
}
}

// Show summary of all successfully created ATAs
println!("\n🎉 All ATA creation completed successfully!");
println!("Successfully created ATAs ({total_atas}/{total_atas}):");
println!(
"{}",
atas_to_create.iter().map(|ata| format!(" ✓ {ata}")).collect::<Vec<String>>().join("\n")
);

Ok(total_atas)
}

Expand Down
Loading