| 221 | * Load and parse the Solana CLI config file to determine which payer to use |
| 222 | */ |
| 223 | export async function getPayer(): Promise<Keypair> { |
| 224 | try { |
| 225 | const config = await getConfig(); |
| 226 | if (!config.keypair_path) throw new Error("Missing keypair path"); |
| 227 | return await createKeypairFromFile(config.keypair_path); |
| 228 | } catch (err) { |
| 229 | console.warn( |
| 230 | "Failed to create keypair from CLI config file, falling back to new random keypair" |
| 231 | ); |
| 232 | return Keypair.generate(); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | /** |
| 237 | * Create a Keypair from a secret key stored in file as bytes' array |