Skip to content

Commit

Permalink
fully deprecate chainhooks subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
tippenein committed Feb 9, 2024
1 parent 3f6322c commit bea312a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 74 deletions.
61 changes: 9 additions & 52 deletions components/clarinet-cli/src/frontend/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use clarity_repl::frontend::terminal::print_clarity_wasm_warning;
use clarity_repl::repl::diagnostic::output_diagnostic;
use clarity_repl::repl::{ClarityCodeSource, ClarityContract, ContractDeployer, DEFAULT_EPOCH};
use clarity_repl::{analysis, repl, Terminal};
use stacks_network::{self, check_chainhooks, DevnetOrchestrator};
use stacks_network::{self, DevnetOrchestrator};
use std::collections::HashMap;
use std::fs::{self, File};
use std::io::prelude::*;
Expand Down Expand Up @@ -73,9 +73,9 @@ enum Command {
/// Interact with contracts deployed on Mainnet
#[clap(subcommand, name = "requirements", aliases = &["requirement"])]
Requirements(Requirements),
/// Subcommands for working with chainhooks
#[clap(subcommand, name = "chainhooks", aliases = &["chainhook"])]
Chainhooks(Chainhooks),
/// Subcommands for working with chainhooks (deprecated)
#[clap(name = "chainhooks", aliases = &["chainhook"])]
Chainhooks,
/// Manage contracts deployments on Simnet/Devnet/Testnet/Mainnet
#[clap(subcommand, name = "deployments", aliases = &["deployment"])]
Deployments(Deployments),
Expand Down Expand Up @@ -141,20 +141,6 @@ enum Deployments {
ApplyDeployment(ApplyDeployment),
}

#[allow(clippy::enum_variant_names)]
#[derive(Subcommand, PartialEq, Clone, Debug)]
enum Chainhooks {
/// Generate files and settings for a new hook (deprecated)
#[clap(name = "new", bin_name = "new")]
NewChainhook,
/// Check hooks format
#[clap(name = "check", bin_name = "check")]
CheckChainhooks(CheckChainhooks),
/// Publish contracts on chain
#[clap(name = "deploy", bin_name = "deploy")]
DeployChainhook(DeployChainhook),
}

#[derive(Parser, PartialEq, Clone, Debug)]
struct DevnetPackage {
/// Output json file name
Expand Down Expand Up @@ -286,23 +272,6 @@ struct GenerateDeployment {
pub manual_cost: bool,
}

#[derive(Parser, PartialEq, Clone, Debug)]
struct CheckChainhooks {
/// Path to Clarinet.toml
#[clap(long = "manifest-path")]
pub manifest_path: Option<String>,
/// Display chainhooks JSON representation
#[clap(long = "output-json")]
pub output_json: bool,
}

#[derive(Parser, PartialEq, Clone, Debug)]
struct DeployChainhook {
/// Path to Clarinet.toml
#[clap(long = "manifest-path")]
pub manifest_path: Option<String>,
}

#[derive(Parser, PartialEq, Clone, Debug)]
struct ApplyDeployment {
/// Apply default deployment settings/default.devnet-plan.toml
Expand Down Expand Up @@ -856,23 +825,11 @@ pub fn main() {
}
}
},
Command::Chainhooks(subcommand) => match subcommand {
Chainhooks::NewChainhook => {
let message = "This command is deprecated. Use the chainhooks library instead (https://github.com/hirosystems/chainhook)";
println!("{}", format_err!(message));
std::process::exit(1);
}
Chainhooks::CheckChainhooks(cmd) => {
let manifest_location = get_manifest_location_or_exit(cmd.manifest_path);
// Ensure that all the hooks can correctly be deserialized.
println!("Checking chainhooks");
let _ = check_chainhooks(&manifest_location, cmd.output_json);
}
Chainhooks::DeployChainhook(_cmd) => {
// TODO(lgalabru): follow-up on this implementation
unimplemented!()
}
},
Command::Chainhooks => {
let message = "This command is deprecated. Use the chainhooks library instead (https://github.com/hirosystems/chainhook)";
println!("{}", format_err!(message));
std::process::exit(1);
}
Command::Contracts(subcommand) => match subcommand {
Contracts::NewContract(cmd) => {
let manifest = load_manifest_or_exit(cmd.manifest_path);
Expand Down
20 changes: 0 additions & 20 deletions components/stacks-network/src/chainhooks.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use chainhook_sdk::chainhooks::types::{ChainhookConfig, ChainhookFullSpecification};
use chainhook_sdk::types::{BitcoinNetwork, StacksNetwork};
use clarinet_files::FileLocation;
use hiro_system_kit::{green, red};
use std::fs::File;
use std::io::BufReader;
use std::path::PathBuf;
Expand Down Expand Up @@ -56,25 +55,6 @@ pub fn load_chainhooks(
})
}

pub fn check_chainhooks(manifest_location: &FileLocation, output_json: bool) -> Result<(), String> {
let hook_files = get_chainhooks_files(manifest_location)?;
for (path, relative_path) in hook_files.into_iter() {
let _hook = match parse_chainhook_full_specification(&path) {
Ok(hook) => hook,
Err(msg) => {
println!("{} {} syntax incorrect\n{}", red!("x"), relative_path, msg);
continue;
}
};
println!("{} {} succesfully checked", green!("✔"), relative_path);
if output_json {
let body = serde_json::to_string_pretty(&_hook).unwrap();
println!("{}", body);
}
}
Ok(())
}

fn get_chainhooks_files(
manifest_location: &FileLocation,
) -> Result<Vec<(PathBuf, String)>, String> {
Expand Down
2 changes: 1 addition & 1 deletion components/stacks-network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod ui;

pub use chainhook_sdk::observer::MempoolAdmissionData;
pub use chainhook_sdk::{self, utils::Context};
pub use chainhooks::{check_chainhooks, load_chainhooks, parse_chainhook_full_specification};
pub use chainhooks::{load_chainhooks, parse_chainhook_full_specification};
use chains_coordinator::BitcoinMiningCommand;
use clarinet_files::NetworkManifest;
pub use event::DevnetEvent;
Expand Down
2 changes: 1 addition & 1 deletion components/stacks-network/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn main() {
let res = hiro_system_kit::nestable_block_on(do_run_chain_coordinator(
orchestrator,
deployment,
&mut Some(hooks),
&mut Some(chainhooks),
None,
ctx,
orchestrator_terminated_tx,
Expand Down

0 comments on commit bea312a

Please sign in to comment.