chore(solana): silence devnet airdrop retry spam
Catch and swallow airdrop errors quietly. Logs were flooded with 429 retry messages. Now fails fast and lets DB-only credits take over when devnet faucet is dry.
This commit is contained in:
@@ -56,37 +56,36 @@ export async function getTokenMint(): Promise<PublicKey | null> {
|
||||
|
||||
// Auto-create mint on devnet if authority exists
|
||||
if (mintAuthority && RPC_URL.includes("devnet")) {
|
||||
console.log("Auto-creating token mint on devnet...");
|
||||
try {
|
||||
// Fund mint authority with SOL first
|
||||
const balance = await connection.getBalance(mintAuthority.publicKey);
|
||||
if (balance < 500000000) {
|
||||
const signature = await connection.requestAirdrop(
|
||||
mintAuthority.publicKey,
|
||||
2 * 1000000000,
|
||||
);
|
||||
await connection.confirmTransaction(signature);
|
||||
}
|
||||
|
||||
// Fund mint authority with SOL first
|
||||
const balance = await connection.getBalance(mintAuthority.publicKey);
|
||||
if (balance < 500000000) {
|
||||
console.log(
|
||||
`Airdropping SOL to mint authority ${mintAuthority.publicKey.toBase58()}...`,
|
||||
);
|
||||
const signature = await connection.requestAirdrop(
|
||||
const mintKeypair = Keypair.generate();
|
||||
const mint = await createMint(
|
||||
connection,
|
||||
mintAuthority,
|
||||
mintAuthority.publicKey,
|
||||
2 * 1000000000,
|
||||
null,
|
||||
DECIMALS,
|
||||
mintKeypair,
|
||||
);
|
||||
await connection.confirmTransaction(signature);
|
||||
console.log("Airdrop complete");
|
||||
cachedMint = mint;
|
||||
console.log(`Token mint created: ${mint.toBase58()}`);
|
||||
console.log(
|
||||
`Add SOLANA_MINT_ADDRESS=${mint.toBase58()} to your .env to persist it`,
|
||||
);
|
||||
return mint;
|
||||
} catch {
|
||||
// Devnet faucet rate-limited, will use DB-only credits
|
||||
return null;
|
||||
}
|
||||
|
||||
const mintKeypair = Keypair.generate();
|
||||
const mint = await createMint(
|
||||
connection,
|
||||
mintAuthority,
|
||||
mintAuthority.publicKey,
|
||||
null,
|
||||
DECIMALS,
|
||||
mintKeypair,
|
||||
);
|
||||
cachedMint = mint;
|
||||
console.log(`Token mint created: ${mint.toBase58()}`);
|
||||
console.log(
|
||||
`Add SOLANA_MINT_ADDRESS=${mint.toBase58()} to your .env to persist it`,
|
||||
);
|
||||
return mint;
|
||||
}
|
||||
return null;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user