Skip to content

Commit

Permalink
using accounts_import api (#45)
Browse files Browse the repository at this point in the history
* using accounts_import api

* Improve translations #6 (#44)

* Updated cs, fa, fr, id, pl, pt, ro, uk and zh

* Updated es translation

* Add pending/sending to translatable strings

* Add missing descriptor to translatable strings

* Simplified tools string

* Add tx error to translatable strings

* Simplified settings string

* Use existing translation for scanner

* Use existing translation for skip

* Add change secret to translatable strings

* Add store settings error to translatable strings

* Add scanner strings to translatable strings

* Updated de with new translations

* Update all translations with currently untranslated strings

* Fix usage of function call after expect

* deps

---------

Co-authored-by: Helix <[email protected]>
  • Loading branch information
surinder83singh and HLXEasy authored Oct 10, 2024
1 parent d48db3d commit b757180
Show file tree
Hide file tree
Showing 11 changed files with 1,412 additions and 995 deletions.
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
Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -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!(
Expand Down Expand Up @@ -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(
Expand Down
16 changes: 8 additions & 8 deletions core/src/modules/account_manager/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
))]
));
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/modules/account_manager/menus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand All @@ -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;
};

Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion core/src/modules/account_manager/overview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.);
Expand Down
2 changes: 1 addition & 1 deletion core/src/modules/block_dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
21 changes: 13 additions & 8 deletions core/src/modules/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})
Expand Down Expand Up @@ -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(())
Expand Down Expand Up @@ -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.))
);
Expand Down Expand Up @@ -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.))
);
Expand Down
6 changes: 3 additions & 3 deletions core/src/modules/wallet_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand All @@ -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?);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/modules/wallet_secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})
Expand Down
7 changes: 4 additions & 3 deletions core/src/modules/welcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit b757180

Please sign in to comment.