Skip to content

Commit

Permalink
Web monitor Autopay view (#562)
Browse files Browse the repository at this point in the history
* Removes static web monitor files path for the dev env

* Fixes #511 with temp file for monitor cache

* Fixes #500 using source_path for web files on dev env

* Sets monospace font family for hash codes on the web monitor

* Fix merge

* Git ignores web-monitor/public/build files

* Sorts web monitor validators set (ascending and descending)

* Removes unused key can_create_account from interface ValInfo

* Fetches validators stats from chain - WIP

* Enriches Vitals.chain_view.validator_view with ValsStats data fetched from the chain.
Adds new stats to the web monitor. #504

* Web Monitor: Removes font monospace from hash codes

* Studying to move query of validators stats at account state level - WIP

* Finishes getting validators stats from account_state already fetched by ChainView

* Sets web monitor dashboard and validators tab responsive
Clean up code

* Web Monitor Feat: Adds auto pay node owner setup view - WIP
Web Monitor Refactoring: Moves subscription to Dash level

* Web monitor: adds auto pay setup to check items
Web monitor: adds auto pay tab
Web monitor refactoring: moves subscription to the Main component

* Web monitor: changes auto pay empty message

* Web monitor autopay labels
  • Loading branch information
soaresa authored Jun 15, 2021
1 parent 10c81d5 commit 84bd948
Show file tree
Hide file tree
Showing 16 changed files with 22,011 additions and 213 deletions.
3 changes: 3 additions & 0 deletions ol/cli/src/check/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub struct Items {
pub sync_delay: i64,
/// is in the validator set
pub validator_set: bool,
/// has auto pay not empty
pub has_auto_pay: bool,
}

impl Default for Items {
Expand All @@ -49,6 +51,7 @@ impl Default for Items {
db_files_exist: false,
web_running: false,
node_mode: None,
has_auto_pay: false,
}
}
}
Expand Down
30 changes: 29 additions & 1 deletion ol/cli/src/node/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use libra_types::{account_state::AccountState, transaction::Version};
use resource_viewer::{AnnotatedAccountStateBlob, MoveValueAnnotator, NullStateView};
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use ol_types::autopay::{AutoPayResource, AutoPayView};

#[derive(Clone, Debug, Deserialize, Serialize)]
/// information on the owner account of this node.
pub struct OwnerAccountView {
Expand All @@ -16,6 +18,8 @@ pub struct OwnerAccountView {
balance: u64,
/// if is jailed
is_in_validator_set: bool,
/// auto pay
auto_pay: Option<AutoPayView>,
}

impl OwnerAccountView {
Expand All @@ -25,6 +29,15 @@ impl OwnerAccountView {
address,
balance: 0,
is_in_validator_set: false,
auto_pay: None,
}
}

/// query if account has auto pay settings, and not empty
pub fn has_auto_pay_not_empty(&self) -> bool {
match &self.auto_pay {
Some(auto_pay) => auto_pay.payments.len() > 0,
None => false
}
}
}
Expand All @@ -36,7 +49,7 @@ impl Node {
Some(av) => {
self.vitals.account_view.balance = get_balance(av);
self.vitals.account_view.is_in_validator_set = self.is_in_validator_set();

self.vitals.account_view.auto_pay = self.get_auto_pay_view(self.vitals.account_view.address);
Some(&self.vitals.account_view)
}
None => None
Expand All @@ -52,6 +65,21 @@ impl Node {
}
}

/// Get account auto pay resource
pub fn get_auto_pay_view(&mut self, account: AccountAddress) -> Option<AutoPayView> {
let state = self.get_account_state(account);
match state {
Ok(state) => match state.get_resource::<AutoPayResource>(
AutoPayResource::resource_path().as_slice()
) {
Ok(Some(res)) => Some(res.get_view()),
Ok(None) => None,
Err(_) => None
}
Err(_) => None
}
}

/// Return a full Move-annotated account resource struct
pub fn get_annotate_account_blob(
&mut self,
Expand Down
1 change: 1 addition & 0 deletions ol/cli/src/node/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl Node {
self.vitals.items.sync_height = 404;
}
self.vitals.items.validator_set = self.is_in_validator_set();
self.vitals.items.has_auto_pay = self.vitals.account_view.has_auto_pay_not_empty();
self
}

Expand Down
Loading

0 comments on commit 84bd948

Please sign in to comment.