From 92c104d1f90a94ddaa81a777b4b68f5a50a0727b Mon Sep 17 00:00:00 2001 From: Daksh <41485688+Daksh14@users.noreply.github.com> Date: Tue, 8 Oct 2024 03:03:28 -0400 Subject: [PATCH] rusk-wallet: Add confirmation prompts for various transactions --- rusk-wallet/src/bin/interactive.rs | 124 +++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/rusk-wallet/src/bin/interactive.rs b/rusk-wallet/src/bin/interactive.rs index db284371f2..20000110da 100644 --- a/rusk-wallet/src/bin/interactive.rs +++ b/rusk-wallet/src/bin/interactive.rs @@ -718,6 +718,22 @@ fn confirm(cmd: &Command) -> anyhow::Result { println!(" > Max fee = {} DUSK", Dusk::from(max_fee)); prompt::ask_confirm() } + Command::MoonlightStake { + addr_idx, + amt, + gas_limit, + gas_price, + } => { + let max_fee = gas_limit * gas_price; + println!( + " > Stake from {}", + address_idx_string(addr_idx.unwrap_or_default()) + ); + println!(" > Amount to stake = {} DUSK", amt); + println!(" > Max fee = {} DUSK", Dusk::from(max_fee)); + println!(" > ALERT: THIS IS A PUBLIC TRANSACTION"); + prompt::ask_confirm() + } Command::PhoenixUnstake { addr_idx, gas_limit, @@ -731,6 +747,20 @@ fn confirm(cmd: &Command) -> anyhow::Result { println!(" > Max fee = {} DUSK", Dusk::from(max_fee)); prompt::ask_confirm() } + Command::MoonlightUnstake { + addr_idx, + gas_limit, + gas_price, + } => { + let max_fee = gas_limit * gas_price; + println!( + " > Unstake from {}", + address_idx_string(addr_idx.unwrap_or_default()) + ); + println!(" > Max fee = {} DUSK", Dusk::from(max_fee)); + println!(" > ALERT: THIS IS A PUBLIC TRANSACTION"); + prompt::ask_confirm() + } Command::PhoenixWithdraw { addr_idx, gas_limit, @@ -744,6 +774,100 @@ fn confirm(cmd: &Command) -> anyhow::Result { println!(" > Max fee = {} DUSK", Dusk::from(max_fee)); prompt::ask_confirm() } + Command::MoonlightWithdraw { + addr_idx, + gas_limit, + gas_price, + } => { + let max_fee = gas_limit * gas_price; + println!( + " > Reward from {}", + address_idx_string(addr_idx.unwrap_or_default()) + ); + println!(" > Max fee = {} DUSK", Dusk::from(max_fee)); + println!(" > ALERT: THIS IS A PUBLIC TRANSACTION"); + prompt::ask_confirm() + } + Command::PhoenixMemo { + sndr_idx, + memo, + rcvr, + amt, + gas_limit, + gas_price, + } => { + let max_fee = gas_limit * gas_price; + println!( + " > Send from = {}", + address_idx_string(sndr_idx.unwrap_or_default()) + ); + println!(" > Recipient = {}", rcvr.preview()); + println!(" > Amount to transfer = {} DUSK", amt); + println!(" > Memo = {}", memo); + println!(" > Max fee = {} DUSK", Dusk::from(max_fee)); + prompt::ask_confirm() + } + Command::MoonlightMemo { + sndr_idx, + memo, + rcvr, + amt, + gas_limit, + gas_price, + } => { + let max_fee = gas_limit * gas_price; + println!( + " > Send from = {}", + address_idx_string(sndr_idx.unwrap_or_default()) + ); + println!(" > Recipient = {}", rcvr.preview()); + println!(" > Amount to transfer = {} DUSK", amt); + println!(" > Memo = {}", memo); + println!(" > Max fee = {} DUSK", Dusk::from(max_fee)); + println!(" > ALERT: THIS IS A PUBLIC TRANSACTION"); + prompt::ask_confirm() + } + Command::PhoenixContractDeploy { + addr_idx, + code, + init_args, + gas_limit, + gas_price, + } => { + let code_len = code.metadata()?.len(); + let max_fee = gas_limit * gas_price; + + println!( + " > Deploy from = {}", + address_idx_string(addr_idx.unwrap_or_default()) + ); + println!(" > Code len = {}", code_len); + println!(" > Init args = {}", hex::encode(init_args)); + println!(" > Max fee = {} DUSK", Dusk::from(max_fee)); + + prompt::ask_confirm() + } + Command::MoonlightContractDeploy { + addr_idx, + code, + init_args, + gas_limit, + gas_price, + } => { + let code_len = code.metadata()?.len(); + let max_fee = gas_limit * gas_price; + + println!( + " > Deploy from = {}", + address_idx_string(addr_idx.unwrap_or_default()) + ); + println!(" > Code len = {}", code_len); + println!(" > Init args = {}", hex::encode(init_args)); + println!(" > Max fee = {} DUSK", Dusk::from(max_fee)); + println!(" > ALERT: THIS IS A PUBLIC TRANSACTION"); + + prompt::ask_confirm() + } _ => Ok(true), } }