From 26b6b658f78056c168779f616d4864ede2154497 Mon Sep 17 00:00:00 2001 From: Danilo Guanabara Date: Wed, 15 Oct 2025 19:46:59 -0300 Subject: [PATCH 1/2] :adhesive_bandage: Making bolt-cli buildable again --- Cargo.lock | 15 ++++ Cargo.toml | 6 +- crates/bolt-cli/Cargo.toml | 4 +- crates/bolt-cli/src/instructions.rs | 4 +- crates/bolt-cli/src/lib.rs | 123 ++++++++++++---------------- 5 files changed, 75 insertions(+), 77 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b0151bef..e3f467ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -869,6 +869,8 @@ dependencies = [ "clap 4.5.22", "heck 0.5.0", "serde_json", + "solana-client", + "solana-system-interface", "syn 1.0.109", "sysinfo", "tokio", @@ -5349,6 +5351,19 @@ dependencies = [ "x509-parser", ] +[[package]] +name = "solana-system-interface" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94d7c18cb1a91c6be5f5a8ac9276a1d7c737e39a21beba9ea710ab4b9c63bc90" +dependencies = [ + "js-sys", + "num-traits", + "solana-decode-error", + "solana-pubkey", + "wasm-bindgen", +] + [[package]] name = "solana-thin-client" version = "2.1.0" diff --git a/Cargo.toml b/Cargo.toml index fc13c77f..aacb98ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,8 +42,10 @@ anchor-lang = { version = "^0", features = ["init-if-needed"] } anchor-cli = { version = "^0" } anchor-client = { version = "^0", features = ["async"] } anchor-syn = { version = "^0" } -anchor-lang-idl = { version = "^0" } -solana-program = { version = "^2" } +anchor-lang-idl = { version = "^0" } +solana-program = "^2" +solana-client = "^2" +solana-system-interface = "^1" zeroize = "^1.7" mpl-token-metadata = { version = "^5" } solana-security-txt = "^1" diff --git a/crates/bolt-cli/Cargo.toml b/crates/bolt-cli/Cargo.toml index 96d794b0..3e3bdf47 100644 --- a/crates/bolt-cli/Cargo.toml +++ b/crates/bolt-cli/Cargo.toml @@ -19,6 +19,7 @@ dev = [] [dependencies] anchor-cli = { workspace = true } anchor-client = { workspace = true } +solana-client = { workspace = true } anchor-syn = { workspace = true } anchor-lang-idl = { workspace = true, features = ["build"] } anyhow = { workspace = true } @@ -30,4 +31,5 @@ world = { workspace = true } which = { workspace = true } tokio = { workspace = true } sysinfo = { workspace = true } -bytemuck_derive = { workspace = true } \ No newline at end of file +bytemuck_derive = { workspace = true } +solana-system-interface = { workspace = true } \ No newline at end of file diff --git a/crates/bolt-cli/src/instructions.rs b/crates/bolt-cli/src/instructions.rs index 39eabf0b..1b3330d0 100644 --- a/crates/bolt-cli/src/instructions.rs +++ b/crates/bolt-cli/src/instructions.rs @@ -1,11 +1,11 @@ use anchor_cli::config::{Config, ConfigOverride}; -use anchor_client::solana_client::rpc_config::RpcSendTransactionConfig; use anchor_client::solana_sdk::commitment_config::CommitmentConfig; use anchor_client::solana_sdk::pubkey::Pubkey; use anchor_client::solana_sdk::signature::{read_keypair_file, Keypair}; use anchor_client::solana_sdk::signer::Signer; -use anchor_client::solana_sdk::system_program; +use solana_system_interface::program as system_program; use anchor_client::Client; +use solana_client::rpc_config::RpcSendTransactionConfig; use anyhow::{anyhow, Result}; use std::rc::Rc; use world::{accounts, instruction, Registry, World, ID}; diff --git a/crates/bolt-cli/src/lib.rs b/crates/bolt-cli/src/lib.rs index d6f50422..03c79b4d 100644 --- a/crates/bolt-cli/src/lib.rs +++ b/crates/bolt-cli/src/lib.rs @@ -122,7 +122,6 @@ pub async fn entry(opts: Opts) -> Result<()> { anchor_cli::Command::Init { name, javascript, - solidity, no_install, no_git, template, @@ -133,7 +132,6 @@ pub async fn entry(opts: Opts) -> Result<()> { &opts.cfg_override, name, javascript, - solidity, no_install, no_git, template, @@ -214,7 +212,6 @@ fn init( cfg_override: &ConfigOverride, name: String, javascript: bool, - solidity: bool, no_install: bool, no_git: bool, template: anchor_cli::rust_template::ProgramTemplate, @@ -289,33 +286,31 @@ fn init( idl: None, }, ); - if !solidity { - let component_id = anchor_cli::rust_template::get_or_create_program_id(component_name); - let system_id = anchor_cli::rust_template::get_or_create_program_id(system_name); - localnet.insert( - component_name.to_owned(), - ProgramDeployment { - address: component_id, - path: None, - idl: None, - }, - ); - localnet.insert( - system_name.to_owned(), - ProgramDeployment { - address: system_id, - path: None, - idl: None, - }, - ); - cfg.workspace.members.push("programs/*".to_owned()); - cfg.workspace - .members - .push("programs-ecs/components/*".to_owned()); - cfg.workspace - .members - .push("programs-ecs/systems/*".to_owned()); - } + let component_id = anchor_cli::rust_template::get_or_create_program_id(component_name); + let system_id = anchor_cli::rust_template::get_or_create_program_id(system_name); + localnet.insert( + component_name.to_owned(), + ProgramDeployment { + address: component_id, + path: None, + idl: None, + }, + ); + localnet.insert( + system_name.to_owned(), + ProgramDeployment { + address: system_id, + path: None, + idl: None, + }, + ); + cfg.workspace.members.push("programs/*".to_owned()); + cfg.workspace + .members + .push("programs-ecs/components/*".to_owned()); + cfg.workspace + .members + .push("programs-ecs/systems/*".to_owned()); // Setup the test validator to clone Bolt programs from devnet let validator = Validator { @@ -359,7 +354,7 @@ fn init( // Remove the default programs if `--force` is passed if force { let programs_path = std::env::current_dir()? - .join(if solidity { "solidity" } else { "programs" }) + .join("programs") .join(&project_name); fs::create_dir_all(&programs_path)?; fs::remove_dir_all(&programs_path)?; @@ -371,32 +366,28 @@ fn init( } // Build the program. - if solidity { - anchor_cli::solidity_template::create_program(&project_name)?; - } else { - create_system(system_name)?; - create_component(component_name)?; - rust_template::create_program(&project_name, template)?; - - // Add the component as a dependency to the system - std::process::Command::new("cargo") - .arg("add") - .arg("--package") - .arg(system_name) - .arg("--path") - .arg(format!("programs-ecs/components/{}", component_name)) - .arg("--features") - .arg("cpi") - .stdout(std::process::Stdio::null()) - .stderr(std::process::Stdio::null()) - .spawn() - .map_err(|e| { - anyhow::format_err!( - "error adding component as dependency to the system: {}", - e.to_string() - ) - })?; - } + create_system(system_name)?; + create_component(component_name)?; + rust_template::create_program(&project_name, template)?; + + // Add the component as a dependency to the system + std::process::Command::new("cargo") + .arg("add") + .arg("--package") + .arg(system_name) + .arg("--path") + .arg(format!("programs-ecs/components/{}", component_name)) + .arg("--features") + .arg("cpi") + .stdout(std::process::Stdio::null()) + .stderr(std::process::Stdio::null()) + .spawn() + .map_err(|e| { + anyhow::format_err!( + "error adding component as dependency to the system: {}", + e.to_string() + ) + })?; // Build the test suite. fs::create_dir_all("tests/fixtures")?; @@ -429,18 +420,10 @@ fn init( if jest { let mut test = File::create(format!("tests/{}.test.js", &project_name))?; - if solidity { - test.write_all(anchor_cli::solidity_template::jest(&project_name).as_bytes())?; - } else { - test.write_all(templates::workspace::jest(&project_name).as_bytes())?; - } + test.write_all(templates::workspace::jest(&project_name).as_bytes())?; } else { let mut test = File::create(format!("tests/{}.js", &project_name))?; - if solidity { - test.write_all(anchor_cli::solidity_template::mocha(&project_name).as_bytes())?; - } else { - test.write_all(templates::workspace::mocha(&project_name).as_bytes())?; - } + test.write_all(templates::workspace::mocha(&project_name).as_bytes())?; } let mut deploy = File::create("migrations/deploy.js")?; @@ -458,11 +441,7 @@ fn init( deploy.write_all(anchor_cli::rust_template::ts_deploy_script().as_bytes())?; let mut mocha = File::create(format!("tests/{}.ts", &project_name))?; - if solidity { - mocha.write_all(anchor_cli::solidity_template::ts_mocha(&project_name).as_bytes())?; - } else { - mocha.write_all(templates::workspace::ts_mocha(&project_name).as_bytes())?; - } + mocha.write_all(templates::workspace::ts_mocha(&project_name).as_bytes())?; } if !no_install { From 9c89cd474a8fcfc5a98578f777a5a34307b5fa0b Mon Sep 17 00:00:00 2001 From: Danilo Guanabara Date: Wed, 15 Oct 2025 19:52:48 -0300 Subject: [PATCH 2/2] :rotating_light: Fixing linter warnings --- crates/bolt-cli/src/instructions.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bolt-cli/src/instructions.rs b/crates/bolt-cli/src/instructions.rs index 1b3330d0..094be707 100644 --- a/crates/bolt-cli/src/instructions.rs +++ b/crates/bolt-cli/src/instructions.rs @@ -3,10 +3,10 @@ use anchor_client::solana_sdk::commitment_config::CommitmentConfig; use anchor_client::solana_sdk::pubkey::Pubkey; use anchor_client::solana_sdk::signature::{read_keypair_file, Keypair}; use anchor_client::solana_sdk::signer::Signer; -use solana_system_interface::program as system_program; use anchor_client::Client; -use solana_client::rpc_config::RpcSendTransactionConfig; use anyhow::{anyhow, Result}; +use solana_client::rpc_config::RpcSendTransactionConfig; +use solana_system_interface::program as system_program; use std::rc::Rc; use world::{accounts, instruction, Registry, World, ID};