import { Connection, Keypair } from '@solana/web3.js' import bs58 from 'bs58' import { getEnvOrThrow } from '../utils' let connectionInstance: Connection | null = null export function getConnection(): Connection { if (!connectionInstance) { const endpoint = process.env.RPC_ENDPOINT || 'https://api.mainnet-beta.solana.com' connectionInstance = new Connection(endpoint, { commitment: 'confirmed', wsEndpoint: process.env.WS_ENDPOINT || 'wss://api.mainnet-beta.solana.com', }) } return connectionInstance } export function getFollowerKeypair(): Keypair { const privateKey = getEnvOrThrow('FOLLOWER_PRIVATE_KEY') const secretKey = bs58.decode(privateKey) return Keypair.fromSecretKey(secretKey) }