-
Notifications
You must be signed in to change notification settings - Fork 6
feat: update identity payout address #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
9961345
7b86a8c
0a1bb03
cd231d6
549e555
944a2cd
ffbc170
e4c299f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,239 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use crate::app::AppAction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use crate::backend_task::core::CoreTask; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use crate::backend_task::BackendTask; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use crate::context::AppContext; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use crate::model::qualified_identity::{IdentityType, QualifiedIdentity}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use crate::model::wallet::Wallet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use crate::ui::components::top_panel::add_top_panel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use crate::ui::{MessageType, ScreenLike}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use dash_sdk::dashcore_rpc::dashcore::Address; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use dash_sdk::dpp::identity::accessors::IdentityGettersV0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use dash_sdk::dpp::platform_value::string_encoding::Encoding; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use eframe::egui::Context; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use egui::{ComboBox, Ui}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use std::sync::atomic::Ordering; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
use std::sync::{Arc, RwLock}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
pub struct UpdateIdentityPayoutScreen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
pub app_context: Arc<AppContext>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
pub identity: QualifiedIdentity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
selected_wallet: Option<Arc<RwLock<Wallet>>>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
selected_payout_address: Option<Address>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
selected_funding_address: Option<Address>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
error_message: Option<String>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
impl UpdateIdentityPayoutScreen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
pub fn new(identity: QualifiedIdentity, app_context: &Arc<AppContext>) -> Self { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
let selected_wallet = None; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Self { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
app_context: app_context.clone(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
identity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
selected_wallet, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
selected_payout_address: None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
selected_funding_address: None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
error_message: None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
fn render_wallet_selection(&mut self, ui: &mut Ui) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.horizontal(|ui| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if self.app_context.has_wallet.load(Ordering::Relaxed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
let wallets = &self.app_context.wallets.read().unwrap(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
let wallet_aliases: Vec<String> = wallets | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.values() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.map(|wallet| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
wallet | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.read() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.unwrap() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.alias | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.clone() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.unwrap_or_else(|| "Unnamed Wallet".to_string()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.collect(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
let selected_wallet_alias = self | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.selected_wallet | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.as_ref() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.and_then(|wallet| wallet.read().ok()?.alias.clone()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.unwrap_or_else(|| "Select".to_string()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
// Display the ComboBox for wallet selection | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ComboBox::from_label("") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.selected_text(selected_wallet_alias.clone()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.show_ui(ui, |ui| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
for (idx, wallet) in wallets.values().enumerate() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
let wallet_alias = wallet_aliases[idx].clone(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
let is_selected = self | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.selected_wallet | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.as_ref() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.map_or(false, |selected| Arc::ptr_eq(selected, wallet)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if ui | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.selectable_label(is_selected, wallet_alias.clone()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.clicked() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
// Update the selected wallet | ||||||||||||||||||||||||||||||||||||||||||||||||||||
self.selected_wallet = Some(wallet.clone()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.add_space(20.0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.label("No wallets available."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
fn render_selected_wallet_payout_addresses(&mut self, ctx: &Context, ui: &mut Ui) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if let Some(selected_wallet) = &self.selected_wallet { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
// Acquire a read lock | ||||||||||||||||||||||||||||||||||||||||||||||||||||
let wallet = selected_wallet.read().unwrap(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.add_space(20.0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.heading("Select a Payout Address:"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.add_space(5.0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.push_id("payout_combo_id", |ui| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ComboBox::from_label("") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.selected_text( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
self.selected_payout_address | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.as_ref() // Get a reference to the Option<Address> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.map(|address| address.to_string()) // Convert Address to String | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.unwrap_or_else(|| "".to_string()), // Use default "" if None | ||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.show_ui(ui, |ui| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
for (address, _) in &wallet.known_addresses { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if ui | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.selectable_value( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
&mut self.selected_payout_address, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Some(address.clone()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
address.to_string(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.clicked() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
{} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.add_space(20.0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if let Some(selected_address) = &self.selected_payout_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if let Some(value) = wallet.address_balances.get(&selected_address) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.label(format!("Selected Address has a balance of {} DASH", value)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
// TODO: Why sometimes balance is not found? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
//ui.label("Balance NOT FOUND DASH".to_string()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
fn render_selected_wallet_funding_addresses(&mut self, ctx: &Context, ui: &mut Ui) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ogabrielides marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
if let Some(selected_wallet) = &self.selected_wallet { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
// Acquire a read lock | ||||||||||||||||||||||||||||||||||||||||||||||||||||
let wallet = selected_wallet.read().unwrap(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.add_space(20.0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.heading("Select a Funding Address:"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.add_space(5.0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.push_id("funding_combo_id", |ui| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ComboBox::from_label("") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.selected_text( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
self.selected_funding_address | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.as_ref() // Get a reference to the Option<Address> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.map(|address| address.to_string()) // Convert Address to String | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.unwrap_or_else(|| "".to_string()), // Use default "" if None | ||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.show_ui(ui, |ui| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
for (address, _) in &wallet.known_addresses { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if ui | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.selectable_value( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
&mut self.selected_funding_address, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Some(address.clone()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
address.to_string(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
.clicked() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
{} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.add_space(20.0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if let Some(selected_address) = &self.selected_funding_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if let Some(value) = wallet.address_balances.get(&selected_address) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.label(format!("Selected Address has a balance of {} DASH", value)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
// TODO: Why sometimes balance is not found? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
//ui.label("Balance NOT FOUND DASH".to_string()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
impl ScreenLike for UpdateIdentityPayoutScreen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
fn display_message(&mut self, message: &str, _message_type: MessageType) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ogabrielides marked this conversation as resolved.
Show resolved
Hide resolved
ogabrielides marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
if _message_type == MessageType::Error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ogabrielides marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
self.error_message = Some(message.to_string()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Renders the UI components for the withdrawal screen | ||||||||||||||||||||||||||||||||||||||||||||||||||||
fn ui(&mut self, ctx: &Context) -> AppAction { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
let mut action = add_top_panel( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ctx, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
&self.app_context, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
vec![ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
("Identities", AppAction::GoToMainScreen), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
("Update Payout Address", AppAction::None), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
vec![], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
egui::CentralPanel::default().show(ctx, |mut ui| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if (self.identity.identity_type == IdentityType::User) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ogabrielides marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.heading( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
"Updating Payout Address for User identities is not allowed.".to_string(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if (!self.app_context.has_wallet.load(Ordering::Relaxed)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ogabrielides marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.heading("Load a Wallet in order to continue.".to_string()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.heading("Update Payout Address".to_string()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.add_space(20.0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.heading("Load Address from wallet".to_string()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
self.render_wallet_selection(&mut ui); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ogabrielides marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
if self.selected_wallet.is_some() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
self.render_selected_wallet_payout_addresses(ctx, &mut ui); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ogabrielides marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
if self.selected_payout_address.is_some() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
self.render_selected_wallet_funding_addresses(ctx, &mut ui); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ogabrielides marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
if self.selected_funding_address.is_some() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.add_space(20.0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.colored_label( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
egui::Color32::ORANGE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
"The owner key of the Masternode/Evonode must be known to your wallet.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.add_space(20.0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if ui.button("Update Payout Address").clicked() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
action |= AppAction::BackendTask(BackendTask::CoreTask( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
CoreTask::ProRegUpdateTx( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
self.identity.identity.id().to_string(Encoding::Hex), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
self.selected_payout_address.clone().unwrap(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
self.selected_funding_address.clone().unwrap(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure required fields are selected before proceeding When the "Update Payout Address" button is clicked, the code assumes that both Proposed change: if ui.button("Update Payout Address").clicked() {
+ if let (Some(payout_address), Some(funding_address)) = (
+ self.selected_payout_address.clone(),
+ self.selected_funding_address.clone(),
+ ) {
action |= AppAction::BackendTask(BackendTask::CoreTask(
CoreTask::ProRegUpdateTx(
self.identity.identity.id().to_string(Encoding::Hex),
- self.selected_payout_address.clone().unwrap(),
- self.selected_funding_address.clone().unwrap(),
+ payout_address,
+ funding_address,
),
));
+ } else {
+ self.error_message = Some("Please select both payout and funding addresses.".to_string());
+ }
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
if self.error_message.is_some() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.add_space(20.0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ui.colored_label( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
egui::Color32::RED, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
self.error_message.as_ref().unwrap(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reset error message after displaying it The error message is displayed but not reset, which may cause it to persist longer than intended. Reset Proposed change: if self.error_message.is_some() {
ui.add_space(20.0);
ui.colored_label(
egui::Color32::RED,
self.error_message.as_ref().unwrap(),
);
+ self.error_message = None;
} 📝 Committable suggestion
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure this will just make the error message flash for a millisecond There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're absolutely right. Resetting the error message immediately after displaying it would cause it to disappear too quickly, preventing the user from reading it. Thank you for pointing that out. ✏️ Learnings added
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
action | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
Uh oh!
There was an error while loading. Please reload this page.