Skip to content

Commit

Permalink
fix: rebase damage
Browse files Browse the repository at this point in the history
  • Loading branch information
grumbach committed Feb 1, 2024
1 parent 9851a99 commit 73b0c5a
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 765 deletions.
15 changes: 14 additions & 1 deletion sn_cli/src/subcommands/wallet/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use sn_transfers::{SpendAddress, GENESIS_CASHNOTE};

const SPEND_DAG_FILENAME: &str = "spend_dag";

pub(crate) async fn gather_spend_dag(client: &Client, root_dir: &Path) -> Result<SpendDag> {
async fn gather_spend_dag(client: &Client, root_dir: &Path) -> Result<SpendDag> {
let dag_path = root_dir.join(SPEND_DAG_FILENAME);
let dag = match SpendDag::load_from_file(&dag_path) {
Ok(mut dag) => {
Expand All @@ -33,3 +33,16 @@ pub(crate) async fn gather_spend_dag(client: &Client, root_dir: &Path) -> Result

Ok(dag)
}

pub async fn audit(client: &Client, to_dot: bool, root_dir: &Path) -> Result<()> {
if to_dot {
let dag = gather_spend_dag(client, root_dir).await?;
println!("{}", dag.dump_dot_format());
} else {
//NB TODO use the above DAG to audit too
println!("Auditing the Currency, note that this might take a very long time...");
let genesis_addr = SpendAddress::from_unique_pubkey(&GENESIS_CASHNOTE.unique_pubkey());
client.follow_spend(genesis_addr).await?;
}
Ok(())
}
23 changes: 1 addition & 22 deletions sn_cli/src/subcommands/wallet/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,10 @@

use color_eyre::{eyre::eyre, Result};
use sn_client::Client;
use sn_transfers::{LocalWallet, SpendAddress, Transfer, UniquePubkey, GENESIS_CASHNOTE};
use sn_transfers::{LocalWallet, SpendAddress, Transfer, UniquePubkey};
use std::path::Path;
use url::Url;

pub async fn audit(
client: &Client,
to_dot: bool,
find_royalties: bool,
root_dir: &Path,
) -> Result<()> {
let genesis_addr = SpendAddress::from_unique_pubkey(&GENESIS_CASHNOTE.unique_pubkey());

if to_dot {
let dag = client.build_spend_dag_from(genesis_addr).await?;
println!("{}", dag.dump_dot_format());
} else {
println!("Auditing the Currency, note that this might take a very long time...");
client
.follow_spend(genesis_addr, find_royalties, root_dir)
.await?;
}

Ok(())
}

pub async fn get_faucet(root_dir: &Path, client: &Client, url: String) -> Result<()> {
let wallet = LocalWallet::load_from(root_dir)?;
let address_hex = wallet.address().to_hex();
Expand Down
9 changes: 3 additions & 6 deletions sn_cli/src/subcommands/wallet/hot_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// permissions and limitations relating to use of the SAFE Network Software.

use super::{
helpers::{audit, get_faucet, receive, verify_spend},
audit::audit,
helpers::{get_faucet, receive, verify_spend},
WalletApiHelper,
};
use crate::get_stdin_response;
Expand Down Expand Up @@ -145,10 +146,6 @@ pub enum WalletCmds {
/// EXPERIMENTAL Dump Audit DAG in dot format on stdout
#[clap(long, default_value = "false")]
dot: bool,
/// EXPERIMENTAL Find and redeem all Network Royalties
/// only works if the wallet has the Network Royalties private key
#[clap(long, default_value = "false")]
royalties: bool,
},
}

Expand Down Expand Up @@ -228,7 +225,7 @@ pub(crate) async fn wallet_cmds(
WalletCmds::Send { amount, to } => send(amount, to, client, root_dir, verify_store).await,
WalletCmds::Receive { file, transfer } => receive(transfer, file, client, root_dir).await,
WalletCmds::GetFaucet { url } => get_faucet(root_dir, client, url.clone()).await,
WalletCmds::Audit { dot, royalties } => audit(client, dot, royalties, root_dir).await,
WalletCmds::Audit { dot } => audit(client, dot, root_dir).await,
WalletCmds::Verify {
spend_address,
genesis,
Expand Down
Loading

0 comments on commit 73b0c5a

Please sign in to comment.