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

feat: update identity payout address #123

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
23 changes: 22 additions & 1 deletion src/backend_task/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use crate::backend_task::BackendTaskSuccessResult;
use crate::config::Config;
use crate::context::AppContext;
use crate::model::wallet::Wallet;
use dash_sdk::dashcore_rpc::RpcApi;
use dash_sdk::dashcore_rpc::dashcore::address::Payload;
use dash_sdk::dashcore_rpc::dashcore::hashes::{hash160, Hash};
use dash_sdk::dashcore_rpc::dashcore::PubkeyHash;
use dash_sdk::dashcore_rpc::{dashcore, RpcApi};
use dash_sdk::dashcore_rpc::{Auth, Client};
use dash_sdk::dpp::dashcore::{Address, ChainLock, Network, OutPoint, Transaction, TxOut};
use std::sync::{Arc, RwLock};
Expand All @@ -16,6 +19,7 @@ pub(crate) enum CoreTask {
GetBestChainLocks,
RefreshWalletInfo(Arc<RwLock<Wallet>>),
StartDashQT(Network, Option<String>, bool),
ProRegUpdateTx(String, Address, Address),
}
impl PartialEq for CoreTask {
fn eq(&self, other: &Self) -> bool {
Expand All @@ -24,6 +28,7 @@ impl PartialEq for CoreTask {
(CoreTask::GetBestChainLocks, CoreTask::GetBestChainLocks) => true,
(CoreTask::RefreshWalletInfo(_), CoreTask::RefreshWalletInfo(_)) => true,
(CoreTask::StartDashQT(_, _, _), CoreTask::StartDashQT(_, _, _)) => true,
(CoreTask::ProRegUpdateTx(_, _, _), CoreTask::ProRegUpdateTx(_, _, _)) => true,
_ => false,
}
}
Expand All @@ -34,6 +39,7 @@ pub(crate) enum CoreItem {
ReceivedAvailableUTXOTransaction(Transaction, Vec<(OutPoint, TxOut, Address)>),
ChainLock(ChainLock, Network),
ChainLocks(Option<ChainLock>, Option<ChainLock>), // Mainnet, Testnet
ProRegUpdateTx(String),
}

impl AppContext {
Expand Down Expand Up @@ -135,6 +141,21 @@ impl AppContext {
.start_dash_qt(network, custom_dash_qt, overwrite_dash_conf)
.map_err(|e| e.to_string())
.map(|_| BackendTaskSuccessResult::None),
CoreTask::ProRegUpdateTx(pro_tx_hash, voting_address, payout_address) => self
.core_client
.get_protx_update_registrar(
pro_tx_hash.as_str(),
"",
payout_address,
voting_address,
None,
)
.map(|pro_tx_hash| {
BackendTaskSuccessResult::CoreItem(CoreItem::ProRegUpdateTx(
pro_tx_hash.to_string(),
))
})
.map_err(|e| e.to_string()),
}
}
}
89 changes: 52 additions & 37 deletions src/ui/identities/identities_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::ui::components::top_panel::add_top_panel;
use crate::ui::identities::keys::add_key_screen::AddKeyScreen;
use crate::ui::identities::keys::key_info_screen::KeyInfoScreen;
use crate::ui::identities::top_up_identity_screen::TopUpIdentityScreen;
use crate::ui::identities::update_identity_payout_address::UpdateIdentityPayoutScreen;
use crate::ui::transfers::TransferScreen;
use crate::ui::{RootScreenType, Screen, ScreenLike, ScreenType};
use dash_sdk::dpp::identity::accessors::IdentityGettersV0;
Expand Down Expand Up @@ -428,49 +429,63 @@ impl IdentitiesScreen {
));
}});
});
row.col(|ui| {
Self::show_balance(ui, qualified_identity);
if ui.button("Withdraw").clicked() {
action = AppAction::AddScreen(
Screen::WithdrawalScreen(WithdrawalScreen::new(
qualified_identity.clone(),
&self.app_context,
)),
);
}
if ui.button("Top up").clicked() {
action = AppAction::AddScreen(
Screen::TopUpIdentityScreen(TopUpIdentityScreen::new(
qualified_identity.clone(),
&self.app_context,
)),
);
}
if ui.button("Transfer").clicked() {
action = AppAction::AddScreen(Screen::TransferScreen(
TransferScreen::new(
qualified_identity.clone(),
&self.app_context,
),
));
}
});
row.col(|ui| {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 10.0;
Self::show_balance(ui, qualified_identity);
ui.spacing_mut().item_spacing.x = 3.0;

if ui.button("Refresh").clicked() {
action =
AppAction::BackendTask(BackendTask::IdentityTask(
IdentityTask::RefreshIdentity(
if ui.button("Withdraw").clicked() {
action = AppAction::AddScreen(
Screen::WithdrawalScreen(WithdrawalScreen::new(
qualified_identity.clone(),
&self.app_context,
)),
);
}
if ui.button("Top up").clicked() {
action = AppAction::AddScreen(
Screen::TopUpIdentityScreen(TopUpIdentityScreen::new(
qualified_identity.clone(),
&self.app_context,
)),
);
}
if ui.button("Transfer").clicked() {
action = AppAction::AddScreen(Screen::TransferScreen(
TransferScreen::new(
qualified_identity.clone(),
&self.app_context,
),
));
}
if ui.button("Remove").clicked() {
self.identity_to_remove =
Some(qualified_identity.clone());
}});
}
});
});
row.col(|ui| {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 3.0;
if ui.button("Refresh").clicked() {
action =
AppAction::BackendTask(BackendTask::IdentityTask(
IdentityTask::RefreshIdentity(
qualified_identity.clone(),
),
));
}
if ui.button("Remove").clicked() {
self.identity_to_remove =
Some(qualified_identity.clone());
}
if qualified_identity.identity_type != IdentityType::User {
if ui.button("Update Payout Address").clicked() {
action = AppAction::AddScreen(Screen::UpdatePayoutAddressScreen(
UpdateIdentityPayoutScreen::new(
qualified_identity.clone(),
&self.app_context,
),
));
}
}
});
});
});
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/identities/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pub mod identities_screen;
pub mod keys;
pub mod register_dpns_name_screen;
pub mod top_up_identity_screen;
pub mod update_identity_payout_address;
pub mod withdraw_from_identity_screen;
Loading