From e6506e35a5d34319e2f900d282555111829828b9 Mon Sep 17 00:00:00 2001 From: mat-if <97762857+mat-if@users.noreply.github.com> Date: Wed, 18 Jan 2023 09:50:05 -0700 Subject: [PATCH] feat(cli): add confirm flag/step to burn (#2973) --- ironfish-cli/src/commands/wallet/burn.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ironfish-cli/src/commands/wallet/burn.ts b/ironfish-cli/src/commands/wallet/burn.ts index fc0473b4c3..5058dd1c89 100644 --- a/ironfish-cli/src/commands/wallet/burn.ts +++ b/ironfish-cli/src/commands/wallet/burn.ts @@ -35,6 +35,10 @@ export class Burn extends IronfishCommand { char: 'i', description: 'Identifier for the asset', }), + confirm: Flags.boolean({ + default: false, + description: 'Confirm without asking', + }), } async start(): Promise { @@ -104,6 +108,25 @@ export class Burn extends IronfishCommand { fee = CurrencyUtils.decodeIron(input) } + if (!flags.confirm) { + this.log(` +You are about to burn: +${CurrencyUtils.renderIron( + amount, + true, + assetId, +)} plus a transaction fee of ${CurrencyUtils.renderIron(fee, true)} with the account ${account} + +* This action is NOT reversible * +`) + + const confirm = await CliUx.ux.confirm('Do you confirm (Y/N)?') + if (!confirm) { + this.log('Transaction aborted.') + this.exit(0) + } + } + const bar = CliUx.ux.progress({ barCompleteChar: '\u2588', barIncompleteChar: '\u2591',