Skip to content

Commit

Permalink
chore: logo refactoring (#4781)
Browse files Browse the repository at this point in the history
  • Loading branch information
LesnyRumcajs authored Sep 20, 2024
1 parent 6383ea5 commit 302f596
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 29 deletions.
13 changes: 0 additions & 13 deletions build/ascii-art/butterfly

This file was deleted.

18 changes: 3 additions & 15 deletions src/daemon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ use crate::key_management::{
};
use crate::libp2p::{Libp2pConfig, Libp2pService, PeerManager};
use crate::message_pool::{MessagePool, MpoolConfig, MpoolRpcProvider};
use crate::networks::{self, ChainConfig, NetworkChain};
use crate::networks::{self, ChainConfig};
use crate::rpc::eth::filter::EthEventHandler;
use crate::rpc::start_rpc;
use crate::rpc::RPCState;
use crate::shim::address::{CurrentNetwork, Network};
use crate::shim::clock::ChainEpoch;
use crate::shim::version::NetworkVersion;
use crate::state_manager::StateManager;
use crate::utils;
use crate::utils::{
monitoring::MemStatsTracker, proofs_api::ensure_params_downloaded,
version::FOREST_VERSION_STRING,
Expand Down Expand Up @@ -294,7 +295,7 @@ pub(super) async fn start(
let network_name = get_network_name_from_genesis(&genesis_header, &state_manager)?;

info!("Using network :: {}", get_actual_chain_name(&network_name));
display_chain_logo(&config.chain);
utils::misc::display_chain_logo(&config.chain);
let (tipset_sender, tipset_receiver) = flume::bounded(20);

// if bootstrap peers are not set, set them
Expand Down Expand Up @@ -783,19 +784,6 @@ fn create_password(prompt: &str) -> dialoguer::Result<String> {
.interact_on(&term)
}

/// Displays the network logo/ASCII art if available.
fn display_chain_logo(chain: &NetworkChain) {
let logo = match chain {
NetworkChain::Butterflynet => {
Some(include_str!("../../build/ascii-art/butterfly").to_string())
}
_ => None,
};
if let Some(logo) = logo {
info!("\n{logo}");
}
}

fn init_ethereum_mapping<DB: Blockstore>(
state_manager: Arc<StateManager<DB>>,
config: &Config,
Expand Down
44 changes: 43 additions & 1 deletion src/utils/misc/logo.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use dialoguer::console::Term;
use tracing::info;

use crate::shim::version::NetworkVersion;
use crate::{networks::NetworkChain, shim::version::NetworkVersion};

/// Displays the network logo/ASCII art if available.
pub fn display_chain_logo(chain: &NetworkChain) {
// Non-interactive terminal - don't print the logo to avoid polluting prod-like environments.
if !Term::stderr().is_term() {
return;
}
match chain {
NetworkChain::Butterflynet => {
reveal_butterfly_logo();
}
NetworkChain::Mainnet | NetworkChain::Calibnet | NetworkChain::Devnet(_) => {
// no logo for these networks (yet)
}
};
}

pub fn reveal_upgrade_logo(network_version: NetworkVersion) {
// Non-interactive terminal - don't print the logo to avoid polluting prod-like environments.
if !Term::stderr().is_term() {
return;
}
match network_version {
NetworkVersion::V23 => reveal_waffle_upgrade(),
_ => reveal_three_trees(),
Expand Down Expand Up @@ -94,3 +115,24 @@ fn reveal_waffle_upgrade() {
"###
);
}

/// Reveals a Butterfly logo. A beautiful butterfly that will not enjoy its life for long.
fn reveal_butterfly_logo() {
info!(
r###"
,,_
zd$$??=
z$$P? F:`c, _
d$$, `c'cc$$i ,cd$?R
$$$$ cud$,?$$$i ,=P"2?z "
$" " ?$$$,?$$$. ,-''`>, bzP
'cLdb,?$$,?$$$ ,h' "I$'J$P
... `?$$$,"$$,`$$h $$PxrF'd$"
d$PP""?-,"?$$,?$h`$$,,$$'$F44"
?,,_`=4c,?=,"?hu?$`?L4$'? '
`""?==""=-"" `""-`'_,,,,
.ccu?m?e?JC,-,"=?
"""=='?"
"###
);
}

0 comments on commit 302f596

Please sign in to comment.