Skip to content

Commit

Permalink
Merge pull request #31 from cartridge-gg/madara-support
Browse files Browse the repository at this point in the history
Madara support
  • Loading branch information
tarrencev authored Feb 28, 2024
2 parents 08819c5 + 7ea6e20 commit bc49143
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 7 deletions.
97 changes: 97 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11583,6 +11583,27 @@
"name": "CreateKatanaConfigInput",
"possibleTypes": []
},
{
"description": null,
"enumValues": [],
"fields": [],
"inputFields": [
{
"defaultValue": null,
"description": null,
"name": "name",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
],
"interfaces": [],
"kind": "INPUT_OBJECT",
"name": "CreateMadaraConfigInput",
"possibleTypes": []
},
{
"description": null,
"enumValues": [],
Expand All @@ -11607,6 +11628,16 @@
"name": "CreateToriiConfigInput",
"ofType": null
}
},
{
"defaultValue": null,
"description": null,
"name": "madara",
"type": {
"kind": "INPUT_OBJECT",
"name": "CreateMadaraConfigInput",
"ofType": null
}
}
],
"interfaces": [],
Expand Down Expand Up @@ -12094,6 +12125,11 @@
"kind": "OBJECT",
"name": "ToriiConfig",
"ofType": null
},
{
"kind": "OBJECT",
"name": "MadaraConfig",
"ofType": null
}
]
},
Expand Down Expand Up @@ -12265,6 +12301,12 @@
"description": null,
"isDeprecated": false,
"name": "torii"
},
{
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "madara"
}
],
"fields": [],
Expand Down Expand Up @@ -18630,6 +18672,61 @@
"name": "Long",
"possibleTypes": []
},
{
"description": null,
"enumValues": [],
"fields": [
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "version",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "rpc",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "name",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
],
"inputFields": [],
"interfaces": [],
"kind": "OBJECT",
"name": "MadaraConfig",
"possibleTypes": []
},
{
"description": null,
"enumValues": [],
Expand Down
4 changes: 4 additions & 0 deletions src/command/deployments/create.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ mutation CreateDeployment(
world
startBlock
}
... on MadaraConfig {
rpc
name
}
}
}
23 changes: 20 additions & 3 deletions src/command/deployments/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ use graphql_client::{GraphQLQuery, Response};
use crate::{
api::ApiClient,
command::deployments::create::create_deployment::{
CreateDeploymentCreateDeployment::{KatanaConfig, ToriiConfig},
CreateKatanaConfigInput, CreateServiceConfigInput, CreateServiceInput,
CreateToriiConfigInput, DeploymentService, DeploymentTier, Variables,
CreateDeploymentCreateDeployment::{KatanaConfig, ToriiConfig, MadaraConfig}, CreateKatanaConfigInput, CreateMadaraConfigInput, CreateServiceConfigInput, CreateServiceInput, CreateToriiConfigInput, DeploymentService, DeploymentTier, Variables
},
};

Expand Down Expand Up @@ -61,20 +59,34 @@ impl CreateArgs {
genesis: config.genesis.clone(),
}),
torii: None,
madara: None,

}),
},
CreateServiceCommands::Torii(config) => CreateServiceInput {
type_: DeploymentService::torii,
version: config.version.clone(),
config: Some(CreateServiceConfigInput {
katana: None,
madara: None,
torii: Some(CreateToriiConfigInput {
rpc: config.rpc.clone(),
world: format!("{:#x}", config.world),
start_block: Some(config.start_block),
}),
}),
},
CreateServiceCommands::Madara(config) => CreateServiceInput {
type_: DeploymentService::madara,
version: config.version.clone(),
config: Some(CreateServiceConfigInput {
katana: None,
torii: None,
madara: Some(CreateMadaraConfigInput {
name: config.name.clone()
}),
}),
},
};

let tier = match &self.tier {
Expand Down Expand Up @@ -114,12 +126,17 @@ impl CreateArgs {
println!("\nEndpoints:");
println!(" RPC: {}", config.rpc);
}
MadaraConfig(config) => {
println!("\nEndpoints:");
println!(" RPC: {}", config.rpc);
}
}
}

let service = match &self.create_commands {
CreateServiceCommands::Katana(_) => "katana",
CreateServiceCommands::Torii(_) => "torii",
CreateServiceCommands::Madara(_) => "madara",
};

println!(
Expand Down
2 changes: 2 additions & 0 deletions src/command/deployments/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct DeleteDeployment;
pub enum Service {
Katana,
Torii,
Madara,
}

#[derive(Debug, Args)]
Expand All @@ -38,6 +39,7 @@ impl DeleteArgs {
let service = match &self.service {
Service::Katana => DeploymentService::katana,
Service::Torii => DeploymentService::torii,
Service::Madara => DeploymentService::madara,
};

let request_body = DeleteDeployment::build_query(Variables {
Expand Down
5 changes: 5 additions & 0 deletions src/command/deployments/describe.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ query DescribeDeployment($project: String!, $service: DeploymentService!) {
world
startBlock
}
... on MadaraConfig {
version
rpc
name
}
}
}
}
8 changes: 7 additions & 1 deletion src/command/deployments/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::api::ApiClient;

use self::describe_deployment::{
DeploymentService,
DescribeDeploymentDeploymentConfig::{KatanaConfig, ToriiConfig},
DescribeDeploymentDeploymentConfig::{KatanaConfig, ToriiConfig, MadaraConfig},
ResponseData, Variables,
};

Expand Down Expand Up @@ -39,6 +39,7 @@ impl DescribeArgs {
let service = match self.service {
Service::Torii => DeploymentService::torii,
Service::Katana => DeploymentService::katana,
Service::Madara => DeploymentService::madara,
};

let request_body = DescribeDeployment::build_query(Variables {
Expand Down Expand Up @@ -79,6 +80,11 @@ impl DescribeArgs {
println!(" Version: {}", config.version);
println!(" RPC: {}", config.rpc);
}
MadaraConfig(config) => {
println!("\nEndpoints:");
println!(" Version: {}", config.version);
println!(" RPC: {}", config.rpc);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/command/deployments/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ impl LogReader {
let service = match self.service {
Service::Katana => DeploymentService::katana,
Service::Torii => DeploymentService::torii,
Service::Madara => DeploymentService::madara,
};

let request_body = DeploymentLogs::build_query(Variables {
Expand Down
12 changes: 10 additions & 2 deletions src/command/deployments/services/madara.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
use clap::Args;

#[derive(Debug, Args, serde::Serialize)]
#[command(next_help_heading = "Madara options")]
pub struct MadaraArgs {}
#[command(next_help_heading = "Madara create options")]
pub struct MadaraCreateArgs {
#[arg(long, short, value_name = "version")]
#[arg(help = "Service version to use.")]
pub version: Option<String>,

#[arg(long, short, value_name = "name")]
#[arg(help = "Name.")]
pub name: Option<String>,
}
4 changes: 4 additions & 0 deletions src/command/deployments/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use clap::{Subcommand, ValueEnum};
use self::{
katana::{KatanaCreateArgs, KatanaForkArgs, KatanaUpdateArgs},
torii::{ToriiCreateArgs, ToriiUpdateArgs},
madara::MadaraCreateArgs,
};

mod katana;
Expand All @@ -16,6 +17,8 @@ pub enum CreateServiceCommands {
Katana(KatanaCreateArgs),
#[command(about = "Torii deployment.")]
Torii(ToriiCreateArgs),
#[command(about = "Madara deployment.")]
Madara(MadaraCreateArgs),
}

#[derive(Debug, Subcommand, serde::Serialize)]
Expand All @@ -40,4 +43,5 @@ pub enum ForkServiceCommands {
pub enum Service {
Katana,
Torii,
Madara
}
1 change: 1 addition & 0 deletions src/command/deployments/update.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ mutation UpdateDeployment(
world
startBlock
}
# TODO: handle update
}
}
3 changes: 2 additions & 1 deletion src/command/deployments/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
api::ApiClient,
command::deployments::update::update_deployment::{
DeploymentService, DeploymentTier,
UpdateDeploymentUpdateDeployment::{KatanaConfig, ToriiConfig},
UpdateDeploymentUpdateDeployment::{KatanaConfig, ToriiConfig, MadaraConfig},
UpdateKatanaConfigInput, UpdateServiceConfigInput, Variables,
},
};
Expand Down Expand Up @@ -107,6 +107,7 @@ impl UpdateArgs {
println!("\nEndpoints:");
println!(" RPC: {}", config.rpc);
}
MadaraConfig => {} // TODO: implement
}
}

Expand Down

0 comments on commit bc49143

Please sign in to comment.