Skip to content

Commit

Permalink
feat: ui for template registration in console wallet (#5444)
Browse files Browse the repository at this point in the history
Description
---
Added code template registration tab to the console wallet.
The UI shows proper errors. It will not erase the fields when something
is wrong.
Autofill everything that it can from the binary url (template name,
version, type, repo link).
Computes the hash for the template.

Motivation and Context
---
The autofill works like this:
If the link is e.g.
`https://github.com/tari-project/tari/blob/development/template.12.wasm`.
It will fill the repo as `https://github.com/tari-project/tari`
Template name `template`, template version `12`, template type `WASM:1`.
The hash is always computed as of now, because there is no way for the
user to generate it manually.

How Has This Been Tested?
---
Manually.

What process can a PR reviewer use to test or verify this change?
---
Register a code template, and look into the VN UI.

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->

---------

Co-authored-by: Andrejs Gubarevs <[email protected]>
Co-authored-by: stringhandler <[email protected]>
  • Loading branch information
3 people authored Jun 14, 2023
1 parent d492c30 commit 701e3c2
Show file tree
Hide file tree
Showing 18 changed files with 1,315 additions and 32 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl From<SideChainFeature> for grpc::side_chain_feature::SideChainFeature {
SideChainFeature::ValidatorNodeRegistration(template_reg) => {
grpc::side_chain_feature::SideChainFeature::ValidatorNodeRegistration(template_reg.into())
},
SideChainFeature::TemplateRegistration(template_reg) => {
SideChainFeature::CodeTemplateRegistration(template_reg) => {
grpc::side_chain_feature::SideChainFeature::TemplateRegistration(template_reg.into())
},
SideChainFeature::ConfidentialOutput(output_data) => {
Expand All @@ -73,7 +73,7 @@ impl TryFrom<grpc::side_chain_feature::SideChainFeature> for SideChainFeature {
Ok(SideChainFeature::ValidatorNodeRegistration(vn_reg.try_into()?))
},
grpc::side_chain_feature::SideChainFeature::TemplateRegistration(template_reg) => {
Ok(SideChainFeature::TemplateRegistration(template_reg.try_into()?))
Ok(SideChainFeature::CodeTemplateRegistration(template_reg.try_into()?))
},
grpc::side_chain_feature::SideChainFeature::ConfidentialOutput(output_data) => {
Ok(SideChainFeature::ConfidentialOutput(output_data.try_into()?))
Expand Down
2 changes: 2 additions & 0 deletions applications/tari_console_wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ log = { version = "0.4.8", features = ["std"] }
qrcode = { version = "0.12" }
rand = "0.7.3"
regex = "1.5.4"
reqwest = "0.11.18"
rpassword = "5.0"
rustyline = "9.0"
serde = "1.0.136"
Expand All @@ -53,6 +54,7 @@ unicode-segmentation = "1.6.0"
unicode-width = "0.1"
zeroize = "1"
zxcvbn = "2"
url = "2.3.1"

[dependencies.tari_core]
path = "../../base_layer/core"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
let mut output = output_manager
.create_output_with_features(1 * T, OutputFeatures {
output_type: OutputType::CodeTemplateRegistration,
sidechain_feature: Some(SideChainFeature::TemplateRegistration(template_registration)),
sidechain_feature: Some(SideChainFeature::CodeTemplateRegistration(template_registration)),
..Default::default()
})
.await
Expand Down
2 changes: 2 additions & 0 deletions applications/tari_console_wallet/src/ui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use crate::{
network_tab::NetworkTab,
notification_tab::NotificationTab,
receive_tab::ReceiveTab,
register_template_tab::RegisterTemplateTab,
send_tab::SendTab,
tabs_container::TabsContainer,
transactions_tab::TransactionsTab,
Expand Down Expand Up @@ -90,6 +91,7 @@ impl<B: Backend> App<B> {
.add("Send".into(), Box::new(SendTab::new(&app_state)))
.add("Receive".into(), Box::new(ReceiveTab::new()))
.add("Burn".into(), Box::new(BurnTab::new(&app_state)))
.add("Templates".into(), Box::new(RegisterTemplateTab::new(&app_state)))
.add("Contacts".into(), Box::new(ContactsTab::new()))
.add("Network".into(), Box::new(NetworkTab::new(base_node_selected)))
.add("Events".into(), Box::new(EventsComponent::new()))
Expand Down
1 change: 1 addition & 0 deletions applications/tari_console_wallet/src/ui/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub use self::component::*;
pub mod burn_tab;
pub mod contacts_tab;
pub mod events_component;
pub mod register_template_tab;

#[derive(PartialEq, Eq)]
pub enum KeyHandled {
Expand Down
Loading

0 comments on commit 701e3c2

Please sign in to comment.