Skip to content
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

using accounts_import api #45

Merged
merged 4 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 98 additions & 98 deletions Cargo.lock

Large diffs are not rendered by default.

2,130 changes: 1,266 additions & 864 deletions core/resources/i18n/i18n.json

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions core/src/core.rs
Original file line number Diff line number Diff line change
@@ -812,16 +812,16 @@ impl Core {
match metrics {
MetricsUpdate::WalletMetrics {
mempool_size,
node_peers: peers,
network_tps: tps,
// node_peers: peers,
// network_tps: tps,
} => {
self.sender().try_send(Events::MempoolSize {
mempool_size: mempool_size as usize,
})?;

self.state.node_peers = Some(peers as usize);
// self.state.node_peers = None;
self.state.node_mempool_size = Some(mempool_size as usize);
self.state.network_tps = Some(tps);
// self.state.network_tps = None;
}
}
}
@@ -1115,7 +1115,7 @@ impl Core {
if let Some(account) = account_collection.get(&id.into()) {
account.update_balance(balance)?;
} else {
log_error!("unable to find account {}", id);
log_error!("unable to find account {} while updating balance.", id);
}
} else {
log_error!(
@@ -1298,6 +1298,15 @@ impl Core {
});

if let Some(first) = accounts.first() {
self.load_account_transactions_with_range(first, 0..TRANSACTION_PAGE_SIZE)
.map_err(|err| {
log_error!(
"error loading transactions for account {}: {}",
first.id(),
err
);
})
.ok();
let device = self.device().clone();
let wallet = self.wallet();
self.get_mut::<modules::AccountManager>().select(
16 changes: 8 additions & 8 deletions core/src/modules/account_manager/balance.rs
Original file line number Diff line number Diff line change
@@ -53,21 +53,21 @@ impl<'context> BalancePane<'context> {
}

if balance.pending != 0 {
ui.label(format!(
"Pending: {}",
sompi_to_kaspa_string_with_suffix(
ui.label(i18n_args(
"Pending: {amount}",
&[("amount", &sompi_to_kaspa_string_with_suffix(
balance.pending,
network_type
)
))]
));
}
if balance.outgoing != 0 {
ui.label(format!(
"Sending: {}",
sompi_to_kaspa_string_with_suffix(
ui.label(i18n_args(
"Sending: {amount}",
&[("amount", &sompi_to_kaspa_string_with_suffix(
balance.outgoing,
network_type
)
))]
));
}

6 changes: 3 additions & 3 deletions core/src/modules/account_manager/menus.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ impl WalletMenu {
let wallet_name = if let Some(wallet_descriptor) = core.wallet_descriptor.as_ref() {
wallet_descriptor.title.as_deref().unwrap_or(wallet_descriptor.filename.as_str()).to_string()
} else {
ui.label("Missing wallet descriptor");
ui.label(i18n("Missing wallet descriptor"));
return;
};

@@ -41,7 +41,7 @@ impl WalletMenu {
let wallet_filename = if let Some(wallet_descriptor) = core.wallet_descriptor.as_ref() {
wallet_descriptor.filename.clone()
} else {
ui.label("Missing wallet descriptor");
ui.label(i18n("Missing wallet descriptor"));
return;
};

@@ -241,7 +241,7 @@ impl ToolsMenu {
}
pub fn render(&mut self, core: &mut Core, ui : &mut Ui, _account_manager : &mut AccountManager, _rc : &RenderContext, max_height: f32) {

PopupPanel::new(PopupPanel::id(ui,"tools_popup"),|ui|{ ui.add(Label::new(i18n("Tools ⏷")).sense(Sense::click())) }, |ui, _| {
PopupPanel::new(PopupPanel::id(ui,"tools_popup"),|ui|{ ui.add(Label::new(format!("{} ⏷", i18n("Tools"))).sense(Sense::click())) }, |ui, _| {

egui::ScrollArea::vertical()
.id_source("tools_popup_scroll")
2 changes: 1 addition & 1 deletion core/src/modules/account_manager/overview.rs
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ impl<'manager> Overview<'manager> {
ui.vertical_centered(|ui|{

ui.add_space(16.);
ui.label(RichText::new("An error has occurred while submitting transaction:"));
ui.label(RichText::new(i18n("An error has occurred while submitting transaction:")));
ui.add_space(16.);
ui.separator();
ui.add_space(8.);
2 changes: 1 addition & 1 deletion core/src/modules/block_dag.rs
Original file line number Diff line number Diff line change
@@ -171,7 +171,7 @@ impl ModuleT for BlockDag {
ui.heading(i18n("Block DAG"));

ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
PopupPanel::new(PopupPanel::id(ui,"block_dag_settings"),|ui|{ ui.add(Label::new("Settings ⏷").sense(Sense::click())) }, |ui, _| {
PopupPanel::new(PopupPanel::id(ui,"block_dag_settings"),|ui|{ ui.add(Label::new(format!("{} ⏷", i18n("Settings"))).sense(Sense::click())) }, |ui, _| {

CollapsingHeader::new(i18n("Dimensions"))
.open(Some(true))
21 changes: 13 additions & 8 deletions core/src/modules/scanner.rs
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ impl ModuleT for Scanner {
let back = Rc::new(RefCell::new(false));

Panel::new(self)
.with_caption("Scanner")
.with_caption(i18n("Scanner"))
.with_back(|_this| {
*back.borrow_mut() = true;
})
@@ -295,7 +295,7 @@ impl ModuleT for Scanner {
).await?;

} else {
*status.lock().unwrap() = Status::error("Account not found");
*status.lock().unwrap() = Status::error(i18n("Account not found"));
}

Ok(())
@@ -328,10 +328,13 @@ impl ModuleT for Scanner {
ui.label(message);
}
Status::Processing { index, utxo_count, balance } => {
ui.label(format!("Scanning address derivation {}...", index.separated_string()));
ui.label(format!("Located {} UTXOs", utxo_count.separated_string()));
//ui.label(format!("Scanning address derivation {}...", index.separated_string()));
//ui.label(format!("Located {} UTXOs", utxo_count.separated_string()));
ui.label(i18n_args("Scanning address derivation {index}...", &[("index", &index.separated_string())]));
ui.label(i18n_args("Located {utxo_count} UTXOs", &[("utxo_count", &utxo_count.separated_string())]));

ui.add_space(16.);
ui.label(RichText::new("BALANCE").size(12.).raised());
ui.label(RichText::new(i18n("BALANCE")).size(12.).raised());
ui.label(
s2kws_layout_job(core.balance_padding(), *balance, &network_type, theme_color().balance_color,FontId::proportional(28.))
);
@@ -368,10 +371,12 @@ impl ModuleT for Scanner {
.with_body(|this,ui| {

if let Status::Processing { index,utxo_count, balance } = &*this.context.status.lock().unwrap() {
ui.label(format!("Total addresses scanned: {}", index.separated_string()));
ui.label(format!("Located {} UTXOs", utxo_count.separated_string()));
//ui.label(format!("Total addresses scanned: {}", index.separated_string()));
//ui.label(format!("Located {} UTXOs", utxo_count.separated_string()));
ui.label(i18n_args("Total addresses scanned: {index}", &[("index", &index.separated_string())]));
ui.label(i18n_args("Located {utxo_count} UTXOs", &[("utxo_count", &utxo_count.separated_string())]));
ui.add_space(16.);
ui.label(RichText::new("BALANCE").size(12.).raised());
ui.label(RichText::new(i18n("BALANCE")).size(12.).raised());
ui.label(
s2kws_layout_job(balance_padding, *balance, &network_type, theme_color().balance_color,FontId::proportional(28.))
);
6 changes: 3 additions & 3 deletions core/src/modules/wallet_create.rs
Original file line number Diff line number Diff line change
@@ -519,7 +519,7 @@ impl ModuleT for WalletCreate {

})
.with_footer(|this,ui| {
let text = if this.context.account_name.is_not_empty() { i18n("Continue") } else { "Skip" };
let text = if this.context.account_name.is_not_empty() { i18n("Continue") } else { i18n("Skip") };
if ui.large_button(i18n(text)).clicked() {
this.state = State::PhishingHint;
this.focus.next(Focus::PhishingHint);
@@ -1167,7 +1167,7 @@ impl ModuleT for WalletCreate {
prv_key_data_id,
args.account_name.is_not_empty().then_some(args.account_name.clone()),
);
account_descriptors.push(wallet.clone().accounts_create(wallet_secret.clone(), account_create_args).await?);
account_descriptors.push(wallet.clone().accounts_import(wallet_secret.clone(), account_create_args).await?);
}
}else{
for account_index in 0..number_of_accounts {
@@ -1177,7 +1177,7 @@ impl ModuleT for WalletCreate {
args.account_name.is_not_empty().then_some(args.account_name.clone()),
Some(account_index as u64),
);
account_descriptors.push(wallet.clone().accounts_create(wallet_secret.clone(), account_create_args).await?);
account_descriptors.push(wallet.clone().accounts_import(wallet_secret.clone(), account_create_args).await?);
}
}

2 changes: 1 addition & 1 deletion core/src/modules/wallet_secret.rs
Original file line number Diff line number Diff line change
@@ -131,7 +131,7 @@ impl ModuleT for WalletSecret {
// let mut back = false;

Panel::new(self)
.with_caption("Change Wallet Secret")
.with_caption(i18n("Change Wallet Secret"))
.with_back(|_this| {
*back.borrow_mut() = true;
})
7 changes: 4 additions & 3 deletions core/src/modules/welcome.rs
Original file line number Diff line number Diff line change
@@ -158,7 +158,8 @@ impl Welcome {
if ui.medium_button(format!("{} {}", egui_phosphor::light::CHECK, i18n("Apply"))).clicked() {
let mut settings = self.settings.clone();
settings.initialized = true;
settings.store_sync().expect("Unable to store settings");
let message = i18n("Unable to store settings");
settings.store_sync().expect(message);
self.runtime.kaspa_service().update_services(&self.settings.node, None);
core.settings = settings.clone();
core.get_mut::<modules::Settings>().load(settings);
@@ -231,8 +232,8 @@ impl Welcome {
if proceed {
let mut settings = self.settings.clone();
settings.initialized = true;

settings.store_sync().expect("Unable to store settings");
let message = i18n("Unable to store settings");
settings.store_sync().expect(message);
core.settings = settings.clone();
self.runtime.kaspa_service().update_services(&settings.node, None);