Skip to content

Commit f7fe8a9

Browse files
committed
🩹 Making bolt-cli buildable again
1 parent f5186d9 commit f7fe8a9

File tree

5 files changed

+75
-77
lines changed

5 files changed

+75
-77
lines changed

Cargo.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ anchor-lang = { version = "^0", features = ["init-if-needed"] }
4343
anchor-cli = { version = "^0" }
4444
anchor-client = { version = "^0", features = ["async"] }
4545
anchor-syn = { version = "^0" }
46-
anchor-lang-idl = { version = "^0" }
47-
solana-program = { version = "^2" }
46+
anchor-lang-idl = { version = "^0" }
47+
solana-program = "^2"
48+
solana-client = "^2"
49+
solana-system-interface = "^1"
4850
zeroize = "^1.7"
4951
mpl-token-metadata = { version = "^5" }
5052
solana-security-txt = "^1"

crates/bolt-cli/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dev = []
1919
[dependencies]
2020
anchor-cli = { workspace = true }
2121
anchor-client = { workspace = true }
22+
solana-client = { workspace = true }
2223
anchor-syn = { workspace = true }
2324
anchor-lang-idl = { workspace = true, features = ["build"] }
2425
anyhow = { workspace = true }
@@ -30,4 +31,5 @@ world = { workspace = true }
3031
which = { workspace = true }
3132
tokio = { workspace = true }
3233
sysinfo = { workspace = true }
33-
bytemuck_derive = { workspace = true }
34+
bytemuck_derive = { workspace = true }
35+
solana-system-interface = { workspace = true }

crates/bolt-cli/src/instructions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use anchor_cli::config::{Config, ConfigOverride};
2-
use anchor_client::solana_client::rpc_config::RpcSendTransactionConfig;
32
use anchor_client::solana_sdk::commitment_config::CommitmentConfig;
43
use anchor_client::solana_sdk::pubkey::Pubkey;
54
use anchor_client::solana_sdk::signature::{read_keypair_file, Keypair};
65
use anchor_client::solana_sdk::signer::Signer;
7-
use anchor_client::solana_sdk::system_program;
6+
use solana_system_interface::program as system_program;
87
use anchor_client::Client;
8+
use solana_client::rpc_config::RpcSendTransactionConfig;
99
use anyhow::{anyhow, Result};
1010
use std::rc::Rc;
1111
use world::{accounts, instruction, Registry, World, ID};

crates/bolt-cli/src/lib.rs

Lines changed: 51 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ pub async fn entry(opts: Opts) -> Result<()> {
122122
anchor_cli::Command::Init {
123123
name,
124124
javascript,
125-
solidity,
126125
no_install,
127126
no_git,
128127
template,
@@ -133,7 +132,6 @@ pub async fn entry(opts: Opts) -> Result<()> {
133132
&opts.cfg_override,
134133
name,
135134
javascript,
136-
solidity,
137135
no_install,
138136
no_git,
139137
template,
@@ -214,7 +212,6 @@ fn init(
214212
cfg_override: &ConfigOverride,
215213
name: String,
216214
javascript: bool,
217-
solidity: bool,
218215
no_install: bool,
219216
no_git: bool,
220217
template: anchor_cli::rust_template::ProgramTemplate,
@@ -289,33 +286,31 @@ fn init(
289286
idl: None,
290287
},
291288
);
292-
if !solidity {
293-
let component_id = anchor_cli::rust_template::get_or_create_program_id(component_name);
294-
let system_id = anchor_cli::rust_template::get_or_create_program_id(system_name);
295-
localnet.insert(
296-
component_name.to_owned(),
297-
ProgramDeployment {
298-
address: component_id,
299-
path: None,
300-
idl: None,
301-
},
302-
);
303-
localnet.insert(
304-
system_name.to_owned(),
305-
ProgramDeployment {
306-
address: system_id,
307-
path: None,
308-
idl: None,
309-
},
310-
);
311-
cfg.workspace.members.push("programs/*".to_owned());
312-
cfg.workspace
313-
.members
314-
.push("programs-ecs/components/*".to_owned());
315-
cfg.workspace
316-
.members
317-
.push("programs-ecs/systems/*".to_owned());
318-
}
289+
let component_id = anchor_cli::rust_template::get_or_create_program_id(component_name);
290+
let system_id = anchor_cli::rust_template::get_or_create_program_id(system_name);
291+
localnet.insert(
292+
component_name.to_owned(),
293+
ProgramDeployment {
294+
address: component_id,
295+
path: None,
296+
idl: None,
297+
},
298+
);
299+
localnet.insert(
300+
system_name.to_owned(),
301+
ProgramDeployment {
302+
address: system_id,
303+
path: None,
304+
idl: None,
305+
},
306+
);
307+
cfg.workspace.members.push("programs/*".to_owned());
308+
cfg.workspace
309+
.members
310+
.push("programs-ecs/components/*".to_owned());
311+
cfg.workspace
312+
.members
313+
.push("programs-ecs/systems/*".to_owned());
319314

320315
// Setup the test validator to clone Bolt programs from devnet
321316
let validator = Validator {
@@ -359,7 +354,7 @@ fn init(
359354
// Remove the default programs if `--force` is passed
360355
if force {
361356
let programs_path = std::env::current_dir()?
362-
.join(if solidity { "solidity" } else { "programs" })
357+
.join("programs")
363358
.join(&project_name);
364359
fs::create_dir_all(&programs_path)?;
365360
fs::remove_dir_all(&programs_path)?;
@@ -371,32 +366,28 @@ fn init(
371366
}
372367

373368
// Build the program.
374-
if solidity {
375-
anchor_cli::solidity_template::create_program(&project_name)?;
376-
} else {
377-
create_system(system_name)?;
378-
create_component(component_name)?;
379-
rust_template::create_program(&project_name, template)?;
380-
381-
// Add the component as a dependency to the system
382-
std::process::Command::new("cargo")
383-
.arg("add")
384-
.arg("--package")
385-
.arg(system_name)
386-
.arg("--path")
387-
.arg(format!("programs-ecs/components/{}", component_name))
388-
.arg("--features")
389-
.arg("cpi")
390-
.stdout(std::process::Stdio::null())
391-
.stderr(std::process::Stdio::null())
392-
.spawn()
393-
.map_err(|e| {
394-
anyhow::format_err!(
395-
"error adding component as dependency to the system: {}",
396-
e.to_string()
397-
)
398-
})?;
399-
}
369+
create_system(system_name)?;
370+
create_component(component_name)?;
371+
rust_template::create_program(&project_name, template)?;
372+
373+
// Add the component as a dependency to the system
374+
std::process::Command::new("cargo")
375+
.arg("add")
376+
.arg("--package")
377+
.arg(system_name)
378+
.arg("--path")
379+
.arg(format!("programs-ecs/components/{}", component_name))
380+
.arg("--features")
381+
.arg("cpi")
382+
.stdout(std::process::Stdio::null())
383+
.stderr(std::process::Stdio::null())
384+
.spawn()
385+
.map_err(|e| {
386+
anyhow::format_err!(
387+
"error adding component as dependency to the system: {}",
388+
e.to_string()
389+
)
390+
})?;
400391

401392
// Build the test suite.
402393
fs::create_dir_all("tests/fixtures")?;
@@ -429,18 +420,10 @@ fn init(
429420

430421
if jest {
431422
let mut test = File::create(format!("tests/{}.test.js", &project_name))?;
432-
if solidity {
433-
test.write_all(anchor_cli::solidity_template::jest(&project_name).as_bytes())?;
434-
} else {
435-
test.write_all(templates::workspace::jest(&project_name).as_bytes())?;
436-
}
423+
test.write_all(templates::workspace::jest(&project_name).as_bytes())?;
437424
} else {
438425
let mut test = File::create(format!("tests/{}.js", &project_name))?;
439-
if solidity {
440-
test.write_all(anchor_cli::solidity_template::mocha(&project_name).as_bytes())?;
441-
} else {
442-
test.write_all(templates::workspace::mocha(&project_name).as_bytes())?;
443-
}
426+
test.write_all(templates::workspace::mocha(&project_name).as_bytes())?;
444427
}
445428

446429
let mut deploy = File::create("migrations/deploy.js")?;
@@ -458,11 +441,7 @@ fn init(
458441
deploy.write_all(anchor_cli::rust_template::ts_deploy_script().as_bytes())?;
459442

460443
let mut mocha = File::create(format!("tests/{}.ts", &project_name))?;
461-
if solidity {
462-
mocha.write_all(anchor_cli::solidity_template::ts_mocha(&project_name).as_bytes())?;
463-
} else {
464-
mocha.write_all(templates::workspace::ts_mocha(&project_name).as_bytes())?;
465-
}
444+
mocha.write_all(templates::workspace::ts_mocha(&project_name).as_bytes())?;
466445
}
467446

468447
if !no_install {

0 commit comments

Comments
 (0)