| 153 | * Checks if provided account is executable and returns the public key |
| 154 | */ |
| 155 | export async function checkBinaryExists( |
| 156 | PROGRAM_KEYPAIR_PATH: string |
| 157 | ): Promise<PublicKey> { |
| 158 | try { |
| 159 | const programKeypair = await createKeypairFromFile(PROGRAM_KEYPAIR_PATH); |
| 160 | return programKeypair.publicKey; |
| 161 | } catch (err) { |
| 162 | const errMsg = (err as Error).message; |
| 163 | throw new Error( |
| 164 | `Failed to read program keypair at '${PROGRAM_KEYPAIR_PATH}' due to error: ${errMsg}. Program may need to be deployed with \`solana program deploy dist/program/helloworld.so\`` |
| 165 | ); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Checks if provided account is executable |