diff --git a/cli/src/command/deployments/fork.rs b/cli/src/command/deployments/fork.rs deleted file mode 100644 index b627352..0000000 --- a/cli/src/command/deployments/fork.rs +++ /dev/null @@ -1,83 +0,0 @@ -#![allow(clippy::enum_variant_names)] - -use anyhow::Result; -use clap::Args; -use slot::graphql::deployments::fork_deployment::ForkDeploymentForkDeployment::KatanaConfig; -use slot::graphql::deployments::{fork_deployment::*, ForkDeployment}; -use slot::graphql::GraphQLQuery; -use slot::{api::Client, credential::Credentials, vars}; -use starknet::providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; -use url::Url; - -use super::{services::ForkServiceCommands, Tier}; - -#[derive(Debug, Args)] -#[command(next_help_heading = "Fork options")] -pub struct ForkArgs { - #[arg(help = "The name of the project to fork.")] - pub project: String, - #[arg(short, long, default_value = "basic")] - #[arg(value_name = "tier")] - #[arg(help = "Deployment tier.")] - pub tier: Tier, - - #[command(subcommand)] - fork_commands: ForkServiceCommands, -} - -impl ForkArgs { - pub async fn run(&self) -> Result<()> { - let (fork_name, fork_block_number) = self.fork_config().await?; - - let tier = match &self.tier { - Tier::Basic => DeploymentTier::basic, - Tier::Common => DeploymentTier::common, - Tier::Rare => DeploymentTier::rare, - Tier::Epic => DeploymentTier::epic, - }; - - let request_body = ForkDeployment::build_query(Variables { - project: self.project.clone(), - fork_name: fork_name.clone(), - fork_block_number, - tier, - wait: Some(true), - }); - - let user = Credentials::load()?; - let client = Client::new_with_token(user.access_token); - - let data: ResponseData = client.query(&request_body).await?; - println!("Fork success 🚀"); - if let KatanaConfig(config) = data.fork_deployment { - println!("\nEndpoints:"); - println!(" RPC: {}", config.rpc); - println!( - "\nStream logs with `slot deployments logs {} katana -f`", - fork_name - ); - } - - Ok(()) - } - - async fn fork_config(&self) -> Result<(String, u64)> { - match &self.fork_commands { - ForkServiceCommands::Katana(config) => { - let block_number = if let Some(block_number) = config.fork_block_number { - block_number - } else { - let url = vars::get_cartridge_api_url(); - // Workaround to get latest block number. Perhaps Katana could default to latest if none is supplied - let rpc_client = JsonRpcClient::new(HttpTransport::new(Url::parse(&format!( - "{url}/x/{}/katana", - self.project - ))?)); - rpc_client.block_number().await? - }; - - Ok((config.fork_name.clone(), block_number)) - } - } - } -} diff --git a/cli/src/command/deployments/mod.rs b/cli/src/command/deployments/mod.rs index 2d30813..2eb7cdb 100644 --- a/cli/src/command/deployments/mod.rs +++ b/cli/src/command/deployments/mod.rs @@ -4,14 +4,13 @@ use colored::*; use self::{ accounts::AccountsArgs, create::CreateArgs, delete::DeleteArgs, describe::DescribeArgs, - fork::ForkArgs, list::ListArgs, logs::LogsArgs, update::UpdateArgs, + list::ListArgs, logs::LogsArgs, update::UpdateArgs, }; mod accounts; mod create; mod delete; mod describe; -mod fork; mod list; mod logs; mod services; @@ -27,8 +26,6 @@ pub enum Deployments { Delete(DeleteArgs), #[command(about = "Update a deployment.")] Update(UpdateArgs), - #[command(about = "Fork a deployment.")] - Fork(ForkArgs), #[command(about = "Describe a deployment's configuration.")] Describe(DescribeArgs), #[command(about = "List all deployments.", aliases = ["ls"])] @@ -45,7 +42,6 @@ impl Deployments { Deployments::Create(args) => args.run().await, Deployments::Delete(args) => args.run().await, Deployments::Update(args) => args.run().await, - Deployments::Fork(args) => args.run().await, Deployments::Describe(args) => args.run().await, Deployments::List(args) => args.run().await, Deployments::Logs(args) => args.run().await, diff --git a/cli/src/command/deployments/services/katana.rs b/cli/src/command/deployments/services/katana.rs index 0c41f39..4ac0e8a 100644 --- a/cli/src/command/deployments/services/katana.rs +++ b/cli/src/command/deployments/services/katana.rs @@ -23,17 +23,6 @@ pub struct KatanaUpdateArgs { pub node_args: NodeArgs, } -#[derive(Debug, Args, serde::Serialize)] -#[command(next_help_heading = "Katana fork options")] -pub struct KatanaForkArgs { - #[arg(long, value_name = "fork_name")] - #[arg(help = "Specify the fork name")] - pub fork_name: String, - #[arg(long, value_name = "fork_block_number")] - #[arg(help = "Specify block number to fork. (latests if not provided)")] - pub fork_block_number: Option, -} - #[derive(Debug, Args, serde::Serialize)] #[command(next_help_heading = "Katana account options")] pub struct KatanaAccountArgs {} diff --git a/cli/src/command/deployments/services/mod.rs b/cli/src/command/deployments/services/mod.rs index ef2afc8..2675d9e 100644 --- a/cli/src/command/deployments/services/mod.rs +++ b/cli/src/command/deployments/services/mod.rs @@ -1,7 +1,7 @@ use clap::{Subcommand, ValueEnum}; use self::{ - katana::{KatanaAccountArgs, KatanaCreateArgs, KatanaForkArgs, KatanaUpdateArgs}, + katana::{KatanaAccountArgs, KatanaCreateArgs, KatanaUpdateArgs}, saya::{SayaCreateArgs, SayaUpdateArgs}, torii::{ToriiCreateArgs, ToriiUpdateArgs}, }; @@ -32,15 +32,6 @@ pub enum UpdateServiceCommands { Saya(SayaUpdateArgs), } -#[derive(Debug, Subcommand, serde::Serialize)] -#[serde(untagged)] -pub enum ForkServiceCommands { - #[command(about = "Katana deployment.")] - Katana(KatanaForkArgs), - // #[command(about = "Torii deployment.")] - // Torii(ToriiUpdateArgs), -} - #[derive(Debug, Subcommand, serde::Serialize)] #[serde(untagged)] pub enum KatanaAccountCommands { diff --git a/slot/src/graphql/deployments/fork.graphql b/slot/src/graphql/deployments/fork.graphql deleted file mode 100644 index 7298eea..0000000 --- a/slot/src/graphql/deployments/fork.graphql +++ /dev/null @@ -1,20 +0,0 @@ -mutation ForkDeployment( - $project: String! - $forkName: String! - $forkBlockNumber: Long! - $tier: DeploymentTier! - $wait: Boolean -) { - forkDeployment( - name: $project - forkName: $forkName - forkBlockNumber: $forkBlockNumber - tier: $tier - wait: $wait - ) { - __typename - ... on KatanaConfig { - rpc - } - } -} diff --git a/slot/src/graphql/deployments/fork.rs b/slot/src/graphql/deployments/fork.rs deleted file mode 100644 index cf774cd..0000000 --- a/slot/src/graphql/deployments/fork.rs +++ /dev/null @@ -1,10 +0,0 @@ -use crate::graphql::deployments::Long; -use graphql_client::GraphQLQuery; - -#[derive(GraphQLQuery)] -#[graphql( - response_derives = "Debug", - schema_path = "schema.json", - query_path = "src/graphql/deployments/fork.graphql" -)] -pub struct ForkDeployment; diff --git a/slot/src/graphql/deployments/mod.rs b/slot/src/graphql/deployments/mod.rs index 381dc3f..a56285f 100644 --- a/slot/src/graphql/deployments/mod.rs +++ b/slot/src/graphql/deployments/mod.rs @@ -7,7 +7,6 @@ mod accounts; mod create; mod delete; mod describe; -mod fork; mod list; mod logs; mod update; @@ -16,7 +15,6 @@ pub use accounts::*; pub use create::*; pub use delete::*; pub use describe::*; -pub use fork::*; pub use list::*; pub use logs::*; pub use update::*;