Skip to content

Commit

Permalink
Merge #211: Rework settings panel 🎉
Browse files Browse the repository at this point in the history
7f0da99 Rework settings panel (Daniela Brozzoni)
e52ad7b Use SettingBox trait for Bitcoin Core (Daniela Brozzoni)
4f764d7 Remove descriptors from settings (Daniela Brozzoni)

Pull request description:

  Needs revault/revaultd#256

  Stakeholder view:
  ![Revault GUI_097](https://user-images.githubusercontent.com/25042473/130096345-97591e3d-6514-44cb-bd37-03455685eaf7.png)
  ![Revault GUI_098](https://user-images.githubusercontent.com/25042473/130096354-29c0f8f4-9076-4e14-88a0-8415aa4a67d4.png)

  (Sadly watchtowers are always dead 🤷🏻♀️)

  Manager view:
  ![Revault GUI_099](https://user-images.githubusercontent.com/25042473/130096437-44e81b0b-19be-4760-bec4-38cf8605737e.png)
  ![Revault GUI_100](https://user-images.githubusercontent.com/25042473/130096441-ead84263-e048-4a7c-bc11-d56a5ff2b1b3.png)

ACKs for top commit:
  edouardparis:
    ACK 7f0da99

Tree-SHA512: 077851a3b7b64850ed865a38057659cf1545c1448e079519922bf12a9266969922cfc3a553af42bf2399b779b888163c6619b45b38a438eab8f71caa4bfe80a3
  • Loading branch information
edouardparis committed Aug 31, 2021
2 parents 3c7be53 + 7f0da99 commit 58e877c
Show file tree
Hide file tree
Showing 7 changed files with 354 additions and 216 deletions.
3 changes: 2 additions & 1 deletion src/app/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
RevocationTransactions, SpendTransaction, SpendTx, UnvaultTransaction, Vault,
VaultStatus, VaultTransactions,
},
GetInfoResponse, RevaultD, RevaultDError,
GetInfoResponse, RevaultD, RevaultDError, ServerStatusResponse,
},
};

Expand All @@ -29,6 +29,7 @@ pub enum Message {
Vault(VaultMessage),
FilterVaults(VaultFilterMessage),
BlockHeight(Result<u64, RevaultDError>),
ServerStatus(Result<ServerStatusResponse, RevaultDError>),
Connected(Result<Arc<RevaultD>, Error>),
Menu(Menu),
Next,
Expand Down
8 changes: 7 additions & 1 deletion src/app/state/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::revaultd::{
RevocationTransactions, SpendTransaction, SpendTx, SpendTxStatus, UnvaultTransaction,
Vault, VaultStatus, VaultTransactions,
},
RevaultD, RevaultDError,
RevaultD, RevaultDError, ServerStatusResponse,
};

/// retrieves a bitcoin address for deposit.
Expand Down Expand Up @@ -115,3 +115,9 @@ pub async fn revault(revaultd: Arc<RevaultD>, outpoint: String) -> Result<(), Re
pub async fn emergency(revaultd: Arc<RevaultD>) -> Result<(), RevaultDError> {
revaultd.emergency()
}

pub async fn get_server_status(
revaultd: Arc<RevaultD>,
) -> Result<ServerStatusResponse, RevaultDError> {
revaultd.get_server_status()
}
25 changes: 23 additions & 2 deletions src/app/state/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@ use super::State;
use crate::app::config::Config;

use crate::app::{
context::Context, error::Error, message::Message, state::cmd::get_blockheight,
context::Context,
error::Error,
message::Message,
state::cmd::{get_blockheight, get_server_status},
view::SettingsView,
};

use crate::revaultd::ServerStatusResponse;

#[derive(Debug)]
pub struct SettingsState {
blockheight: u64,
config: Config,
warning: Option<Error>,
view: SettingsView,
server_status: Option<ServerStatusResponse>,
}

impl SettingsState {
Expand All @@ -26,6 +32,7 @@ impl SettingsState {
config,
view: SettingsView::new(),
warning: None,
server_status: None,
}
}
}
Expand All @@ -44,6 +51,13 @@ impl State for SettingsState {
};
Command::none()
}
Message::ServerStatus(s) => {
match s {
Ok(server_status) => self.server_status = Some(server_status),
Err(e) => self.warning = Error::from(e).into(),
};
Command::none()
}
_ => Command::none(),
}
}
Expand All @@ -54,11 +68,18 @@ impl State for SettingsState {
self.warning.as_ref(),
self.blockheight,
&ctx.revaultd.config,
self.server_status.clone(),
)
}

fn load(&self, ctx: &Context) -> Command<Message> {
Command::perform(get_blockheight(ctx.revaultd.clone()), Message::BlockHeight)
Command::batch(vec![
Command::perform(get_blockheight(ctx.revaultd.clone()), Message::BlockHeight),
Command::perform(
get_server_status(ctx.revaultd.clone()),
Message::ServerStatus,
),
])
}
}

Expand Down
Loading

0 comments on commit 58e877c

Please sign in to comment.