Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove chainhook subcommands #1328

Merged
16 changes: 1 addition & 15 deletions components/clarinet-cli/src/devnet/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ use clarinet_deployments::types::DeploymentSpecification;
use hiro_system_kit::Drain;
use hiro_system_kit::{slog, slog_async, slog_term};
use stacks_network::{
chainhook_sdk::types::{BitcoinNetwork, StacksNetwork},
chainhook_sdk::utils::Context,
do_run_local_devnet, load_chainhooks, ChainsCoordinatorCommand, DevnetEvent,
chainhook_sdk::utils::Context, do_run_local_devnet, ChainsCoordinatorCommand, DevnetEvent,
DevnetOrchestrator, LogData,
};
use std::fs::OpenOptions;
Expand All @@ -29,17 +27,6 @@ pub fn start(
),
String,
> {
let hooks = match load_chainhooks(
tippenein marked this conversation as resolved.
Show resolved Hide resolved
&devnet.manifest.location,
&(BitcoinNetwork::Regtest, StacksNetwork::Devnet),
) {
Ok(hooks) => hooks,
Err(e) => {
println!("{}", e);
std::process::exit(1);
}
};

let working_dir = devnet
.network_config
.as_ref()
Expand Down Expand Up @@ -73,7 +60,6 @@ pub fn start(
let res = hiro_system_kit::nestable_block_on(do_run_local_devnet(
devnet,
deployment,
&mut Some(hooks),
log_tx,
display_dashboard,
ctx,
Expand Down
107 changes: 12 additions & 95 deletions components/clarinet-cli/src/frontend/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use clarinet_deployments::types::{DeploymentGenerationArtifacts, DeploymentSpeci
use clarinet_deployments::{
get_default_deployment_path, load_deployment, setup_session_with_deployment,
};
use clarinet_files::chainhook_types::Chain;
use clarinet_files::chainhook_types::StacksNetwork;
use clarinet_files::{
get_manifest_location, FileLocation, NetworkManifest, ProjectManifest, ProjectManifestFile,
Expand All @@ -37,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 @@ -75,8 +74,8 @@ enum Command {
#[clap(subcommand, name = "requirements", aliases = &["requirement"])]
Requirements(Requirements),
/// Subcommands for working with chainhooks
#[clap(subcommand, name = "chainhooks", aliases = &["chainhook"])]
Chainhooks(Chainhooks),
#[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 @@ -142,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
#[clap(name = "new", bin_name = "new")]
NewChainhook(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 @@ -287,38 +272,6 @@ struct GenerateDeployment {
pub manual_cost: bool,
}

#[derive(Parser, PartialEq, Clone, Debug)]
struct NewChainhook {
/// Hook's name
pub name: String,
/// Path to Clarinet.toml
#[clap(long = "manifest-path")]
pub manifest_path: Option<String>,
/// Generate a Bitcoin chainhook
#[clap(long = "bitcoin", conflicts_with = "stacks")]
pub bitcoin: bool,
/// Generate a Stacks chainhook
#[clap(long = "stacks", conflicts_with = "bitcoin")]
pub stacks: 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 @@ -872,49 +825,6 @@ pub fn main() {
}
}
},
Command::Chainhooks(subcommand) => match subcommand {
Chainhooks::NewChainhook(cmd) => {
let manifest = load_manifest_or_exit(cmd.manifest_path);

let chain = match (cmd.bitcoin, cmd.stacks) {
(true, false) => Chain::Bitcoin,
(false, true) => Chain::Stacks,
(_, _) => {
println!(
"{}",
format_err!("either --bitcoin or --stacks must be passed")
);
process::exit(1);
}
};

let changes =
match generate::get_changes_for_new_chainhook(&manifest, cmd.name, chain) {
Ok(changes) => changes,
Err(message) => {
println!("{}", format_err!(message));
std::process::exit(1);
}
};

if !execute_changes(changes) {
std::process::exit(1);
}
if global_settings.enable_hints.unwrap_or(true) {
display_post_check_hint();
}
}
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::Contracts(subcommand) => match subcommand {
Contracts::NewContract(cmd) => {
let manifest = load_manifest_or_exit(cmd.manifest_path);
Expand Down Expand Up @@ -1233,6 +1143,13 @@ pub fn main() {
);
devnet_start(cmd, global_settings)
}
Command::Chainhooks => {
println!(
"{}",
format_err!("This command is deprecated. Use the chainhooks library instead (https://github.com/hirosystems/chainhook)"),
);
process::exit(1);
}
Command::LSP => run_lsp(),
Command::DAP => match super::dap::run_dap() {
Ok(_) => (),
Expand Down Expand Up @@ -1749,7 +1666,7 @@ fn display_contract_new_hint(project_name: Option<&str>) {
yellow!(" Check contract syntax for all files in ./contracts.\n")
);

println!("{}", yellow!("Find more information on writing contracts with Clarinet here: https://docs.hiro.so/clarinet/how-to-guides/how-to-set-up-local-development-environment#developing-a-clarity-smart-contract"));
println!("{}", yellow!("Find more information on writing contracts with Clarinet here: https://docs.hiro.so/clarinet/guides/how-to-set-up-local-development-environment#developing-a-clarity-smart-contract"));
display_hint_footer();
}

Expand Down Expand Up @@ -1779,7 +1696,7 @@ fn display_deploy_hint() {
);
println!(
"{}",
yellow!("Find more information on the devnet here: https://docs.hiro.so/clarinet/guides/how-to-run-integration-environment")
yellow!("Find more information on the DevNet here: https://docs.hiro.so/clarinet/guides/how-to-run-integration-environment")
tippenein marked this conversation as resolved.
Show resolved Hide resolved
);
display_hint_footer();
}
Expand Down
154 changes: 0 additions & 154 deletions components/clarinet-cli/src/generate/chainhook.rs

This file was deleted.

14 changes: 0 additions & 14 deletions components/clarinet-cli/src/generate/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
mod chainhook;
pub mod changes;
mod contract;
mod project;

use chainhook::GetChangesForNewChainhook;
pub use changes::Changes;
use clarinet_files::chainhook_types::Chain;
use clarinet_files::FileLocation;
use contract::GetChangesForNewContract;
use project::GetChangesForNewProject;

use clarinet_files::ProjectManifest;

use self::contract::GetChangesForRmContract;

pub fn get_changes_for_new_project(
Expand Down Expand Up @@ -41,12 +36,3 @@ pub fn get_changes_for_rm_contract(
let mut command = GetChangesForRmContract::new(manifest_location.clone(), contract_name);
command.run()
}

pub fn get_changes_for_new_chainhook(
manifest: &ProjectManifest,
chainhook_name: String,
chain: Chain,
) -> Result<Vec<Changes>, String> {
let mut command = GetChangesForNewChainhook::new(manifest, chainhook_name, chain);
command.run()
}
Loading
Loading