INNER CODE UNIT · TypeScript
require_program
Deezzir/solana-bot · src/commands.ts:30
function require_program(supported: common.Program[], command: string): void {
if (!supported.includes(global.PROGRAM)) throw new Error(`${command} is not supported for ${global.PROGRAM}.`);
}
export async function burn_token(mint: PublicKey, burner: Keypair, amount?: number, percent?: number): Promise<void> {
if (!amount && !percent) throw new Error('Either amount or percent should be provided.');
if (amount && percent) throw new Error('Only one of amount or percent should be provided.');
if (amount && amount <= 0) throw new Error('Amount should be greater than 0.');
if (percent && (percent <= 0 || percent > 1)) throw new Error('Percent should be between 0 and 1.');
const mint_meta = await trade.get_token_meta(mint);
if (!mint_meta) throw new Error(`Mint metadata not found for the mint: ${mint.toString()}.`);
common.log(common.yellow(`Burning the token by the mint ${mint.toString()}...`));
common.log(
common.yellow(
`Burning ${amount ? `${amount} tokens` : `${percent! * 100}% of ${mint_meta.token_symbol.toUpperCase()}`}...`
)