Skip to content

Commit 3460f51

Browse files
committed
🚨 Fixing linter warnings
1 parent 5e6ba3b commit 3460f51

File tree

26 files changed

+413
-269
lines changed

26 files changed

+413
-269
lines changed

clients/typescript/test/intermediate-level/acceleration.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ export function acceleration(framework: Framework) {
113113
expect(acc?.owner.toBase58()).to.equal(DELEGATION_PROGRAM_ID.toBase58());
114114
});
115115

116-
return;
117-
118116
it("Apply Simple Movement System (Up) on Entity 1 on Accelerator 10 times", async () => {
119117
if (process.env.GITHUB_ACTIONS === "true") {
120118
// Skip this test if running in GitHub Actions

clients/typescript/test/intermediate-level/ecs.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ export function ecs(framework: Framework) {
172172
expect(position.z.toNumber()).to.equal(0);
173173
});
174174

175-
return;
176-
177175
it("Apply bundled movement system on Entity 1", async () => {
178176
const applySystem = await ApplySystem({
179177
authority: framework.provider.wallet.publicKey,

crates/bolt-cli/src/bundle.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use crate::{
2-
rust_template::create_bundle,
3-
workspace::with_workspace,
4-
};
1+
use crate::{rust_template::create_bundle, workspace::with_workspace};
52
use anchor_cli::config::{ConfigOverride, ProgramDeployment};
63
use anyhow::{anyhow, Result};
74
use std::fs;

crates/bolt-cli/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
mod commands;
22
mod ephemeral_validator;
33

4-
mod component;
54
mod bundle;
5+
mod component;
66
mod instructions;
77
mod rust_template;
88
mod system;
@@ -11,13 +11,13 @@ mod workspace;
1111

1212
pub use ephemeral_validator::EphemeralValidator;
1313

14+
use crate::bundle::new_bundle;
1415
use crate::component::new_component;
1516
use crate::instructions::{
1617
approve_system, authorize, create_registry, create_world, deauthorize, remove_system,
1718
};
1819
use crate::rust_template::{create_component, create_system};
1920
use crate::system::new_system;
20-
use crate::bundle::new_bundle;
2121
use anchor_cli::config;
2222
use anchor_cli::config::{
2323
BootstrapMode, Config, ConfigOverride, GenesisEntry, ProgramArch, ProgramDeployment,

crates/bolt-cli/src/rust_template.rs

Lines changed: 94 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -4,78 +4,81 @@ use anchor_lang_idl::types::{IdlArrayLen, IdlGenericArg, IdlType};
44
use anyhow::Result;
55
use std::path::{Path, PathBuf};
66

7+
use crate::templates::bundle::create_bundle_template;
78
use crate::templates::component::create_component_template_simple;
89
use crate::templates::program::{create_program_template_multiple, create_program_template_single};
910
use crate::templates::system::create_system_template_simple;
10-
use crate::templates::bundle::create_bundle_template;
1111
use crate::templates::workspace::{
12-
cargo_toml, cargo_toml_with_serde, workspace_manifest, xargo_toml,
12+
cargo_toml, cargo_toml_with_serde, workspace_manifest, xargo_toml,
1313
};
1414

1515
/// Create a component from the given name.
1616
pub fn create_component(name: &str) -> Result<()> {
17-
let program_path = Path::new("programs-ecs/components").join(name);
18-
let common_files = vec![
19-
(
20-
PathBuf::from("Cargo.toml".to_string()),
21-
workspace_manifest().to_string(),
22-
),
23-
(program_path.join("Cargo.toml"), cargo_toml(name)),
24-
(program_path.join("Xargo.toml"), xargo_toml().to_string()),
25-
] as Files;
17+
let program_path = Path::new("programs-ecs/components").join(name);
18+
let common_files = vec![
19+
(
20+
PathBuf::from("Cargo.toml".to_string()),
21+
workspace_manifest().to_string(),
22+
),
23+
(program_path.join("Cargo.toml"), cargo_toml(name)),
24+
(program_path.join("Xargo.toml"), xargo_toml().to_string()),
25+
] as Files;
2626

27-
let template_files = create_component_template_simple(name, &program_path);
28-
anchor_cli::create_files(&[common_files, template_files].concat())
27+
let template_files = create_component_template_simple(name, &program_path);
28+
anchor_cli::create_files(&[common_files, template_files].concat())
2929
}
3030

3131
/// Create a bundle from a given name.
3232
pub(crate) fn create_bundle(name: &str) -> Result<()> {
33-
let program_path = Path::new("programs-ecs/bundles").join(name);
34-
let common_files = vec![
35-
(PathBuf::from("Cargo.toml".to_string()), workspace_manifest().to_string()),
36-
(program_path.join("Cargo.toml"), cargo_toml_with_serde(name)),
37-
(program_path.join("Xargo.toml"), xargo_toml().to_string()),
38-
] as Files;
33+
let program_path = Path::new("programs-ecs/bundles").join(name);
34+
let common_files = vec![
35+
(
36+
PathBuf::from("Cargo.toml".to_string()),
37+
workspace_manifest().to_string(),
38+
),
39+
(program_path.join("Cargo.toml"), cargo_toml_with_serde(name)),
40+
(program_path.join("Xargo.toml"), xargo_toml().to_string()),
41+
] as Files;
3942

40-
let template_files = create_bundle_template(name, &program_path);
41-
anchor_cli::create_files(&[common_files, template_files].concat())
43+
let template_files = create_bundle_template(name, &program_path);
44+
anchor_cli::create_files(&[common_files, template_files].concat())
4245
}
4346

4447
/// Create a system from the given name.
4548
pub(crate) fn create_system(name: &str) -> Result<()> {
46-
let program_path = Path::new("programs-ecs/systems").join(name);
47-
let common_files = vec![
48-
(
49-
PathBuf::from("Cargo.toml".to_string()),
50-
workspace_manifest().to_string(),
51-
),
52-
(program_path.join("Cargo.toml"), cargo_toml_with_serde(name)),
53-
(program_path.join("Xargo.toml"), xargo_toml().to_string()),
54-
] as Files;
49+
let program_path = Path::new("programs-ecs/systems").join(name);
50+
let common_files = vec![
51+
(
52+
PathBuf::from("Cargo.toml".to_string()),
53+
workspace_manifest().to_string(),
54+
),
55+
(program_path.join("Cargo.toml"), cargo_toml_with_serde(name)),
56+
(program_path.join("Xargo.toml"), xargo_toml().to_string()),
57+
] as Files;
5558

56-
let template_files = create_system_template_simple(name, &program_path);
57-
anchor_cli::create_files(&[common_files, template_files].concat())
59+
let template_files = create_system_template_simple(name, &program_path);
60+
anchor_cli::create_files(&[common_files, template_files].concat())
5861
}
5962

6063
/// Create an anchor program
6164
pub fn create_program(name: &str, template: ProgramTemplate) -> Result<()> {
62-
let program_path = Path::new("programs").join(name);
63-
let common_files = vec![
64-
("Cargo.toml".into(), workspace_manifest()),
65-
(program_path.join("Cargo.toml"), cargo_toml(name)),
66-
(program_path.join("Xargo.toml"), xargo_toml().into()),
67-
];
65+
let program_path = Path::new("programs").join(name);
66+
let common_files = vec![
67+
("Cargo.toml".into(), workspace_manifest()),
68+
(program_path.join("Cargo.toml"), cargo_toml(name)),
69+
(program_path.join("Xargo.toml"), xargo_toml().into()),
70+
];
6871

69-
let template_files = match template {
70-
ProgramTemplate::Single => create_program_template_single(name, &program_path),
71-
ProgramTemplate::Multiple => create_program_template_multiple(name, &program_path),
72-
};
72+
let template_files = match template {
73+
ProgramTemplate::Single => create_program_template_single(name, &program_path),
74+
ProgramTemplate::Multiple => create_program_template_multiple(name, &program_path),
75+
};
7376

74-
create_files(&[common_files, template_files].concat())
77+
create_files(&[common_files, template_files].concat())
7578
}
7679

7780
pub fn registry_account() -> &'static str {
78-
r#"
81+
r#"
7982
{
8083
"pubkey": "EHLkWwAT9oebVv9ht3mtqrvHhRVMKrt54tF3MfHTey2K",
8184
"account": {
@@ -95,51 +98,51 @@ pub fn registry_account() -> &'static str {
9598

9699
/// Map Idl type to rust type
97100
pub fn convert_idl_type_to_str(ty: &IdlType) -> String {
98-
match ty {
99-
IdlType::Bool => "bool".into(),
100-
IdlType::U8 => "u8".into(),
101-
IdlType::I8 => "i8".into(),
102-
IdlType::U16 => "u16".into(),
103-
IdlType::I16 => "i16".into(),
104-
IdlType::U32 => "u32".into(),
105-
IdlType::I32 => "i32".into(),
106-
IdlType::F32 => "f32".into(),
107-
IdlType::U64 => "u64".into(),
108-
IdlType::I64 => "i64".into(),
109-
IdlType::F64 => "f64".into(),
110-
IdlType::U128 => "u128".into(),
111-
IdlType::I128 => "i128".into(),
112-
IdlType::U256 => "u256".into(),
113-
IdlType::I256 => "i256".into(),
114-
IdlType::Bytes => "bytes".into(),
115-
IdlType::String => "String".into(),
116-
IdlType::Pubkey => "Pubkey".into(),
117-
IdlType::Option(ty) => format!("Option<{}>", convert_idl_type_to_str(ty)),
118-
IdlType::Vec(ty) => format!("Vec<{}>", convert_idl_type_to_str(ty)),
119-
IdlType::Array(ty, len) => format!(
120-
"[{}; {}]",
121-
convert_idl_type_to_str(ty),
122-
match len {
123-
IdlArrayLen::Generic(len) => len.into(),
124-
IdlArrayLen::Value(len) => len.to_string(),
125-
}
126-
),
127-
IdlType::Defined { name, generics } => generics
128-
.iter()
129-
.map(|generic| match generic {
130-
IdlGenericArg::Type { ty } => convert_idl_type_to_str(ty),
131-
IdlGenericArg::Const { value } => value.into(),
132-
})
133-
.reduce(|mut acc, cur| {
134-
if !acc.is_empty() {
135-
acc.push(',');
136-
}
137-
acc.push_str(&cur);
138-
acc
139-
})
140-
.map(|generics| format!("{name}<{generics}>"))
141-
.unwrap_or(name.into()),
142-
IdlType::Generic(ty) => ty.into(),
143-
_ => unimplemented!("{ty:?}"),
144-
}
101+
match ty {
102+
IdlType::Bool => "bool".into(),
103+
IdlType::U8 => "u8".into(),
104+
IdlType::I8 => "i8".into(),
105+
IdlType::U16 => "u16".into(),
106+
IdlType::I16 => "i16".into(),
107+
IdlType::U32 => "u32".into(),
108+
IdlType::I32 => "i32".into(),
109+
IdlType::F32 => "f32".into(),
110+
IdlType::U64 => "u64".into(),
111+
IdlType::I64 => "i64".into(),
112+
IdlType::F64 => "f64".into(),
113+
IdlType::U128 => "u128".into(),
114+
IdlType::I128 => "i128".into(),
115+
IdlType::U256 => "u256".into(),
116+
IdlType::I256 => "i256".into(),
117+
IdlType::Bytes => "bytes".into(),
118+
IdlType::String => "String".into(),
119+
IdlType::Pubkey => "Pubkey".into(),
120+
IdlType::Option(ty) => format!("Option<{}>", convert_idl_type_to_str(ty)),
121+
IdlType::Vec(ty) => format!("Vec<{}>", convert_idl_type_to_str(ty)),
122+
IdlType::Array(ty, len) => format!(
123+
"[{}; {}]",
124+
convert_idl_type_to_str(ty),
125+
match len {
126+
IdlArrayLen::Generic(len) => len.into(),
127+
IdlArrayLen::Value(len) => len.to_string(),
128+
}
129+
),
130+
IdlType::Defined { name, generics } => generics
131+
.iter()
132+
.map(|generic| match generic {
133+
IdlGenericArg::Type { ty } => convert_idl_type_to_str(ty),
134+
IdlGenericArg::Const { value } => value.into(),
135+
})
136+
.reduce(|mut acc, cur| {
137+
if !acc.is_empty() {
138+
acc.push(',');
139+
}
140+
acc.push_str(&cur);
141+
acc
142+
})
143+
.map(|generics| format!("{name}<{generics}>"))
144+
.unwrap_or(name.into()),
145+
IdlType::Generic(ty) => ty.into(),
146+
_ => unimplemented!("{ty:?}"),
147+
}
145148
}

crates/bolt-cli/src/templates/bundle/mod.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ use heck::ToSnakeCase;
33
use std::path::Path;
44

55
pub fn create_bundle_template(name: &str, program_path: &Path) -> Files {
6-
let program_id = anchor_cli::rust_template::get_or_create_program_id(name);
7-
let program_name = name.to_snake_case();
8-
vec![
9-
(
10-
program_path.join("src").join("lib.rs"),
11-
format!(
12-
include_str!("lib.rs.template"),
13-
program_id = program_id,
14-
program_name = program_name
15-
),
16-
),
17-
]
6+
let program_id = anchor_cli::rust_template::get_or_create_program_id(name);
7+
let program_name = name.to_snake_case();
8+
vec![(
9+
program_path.join("src").join("lib.rs"),
10+
format!(
11+
include_str!("lib.rs.template"),
12+
program_id = program_id,
13+
program_name = program_name
14+
),
15+
)]
1816
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
pub mod bundle;
12
pub mod component;
23
pub mod program;
34
pub mod system;
45
pub mod workspace;
5-
pub mod bundle;

crates/bolt-lang/attribute/bundle/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ use proc_macro::TokenStream;
88
#[proc_macro_attribute]
99
pub fn bundle(attr: TokenStream, item: TokenStream) -> TokenStream {
1010
bolt_attribute::bundle::process(attr, item)
11-
}
11+
}

crates/bolt-lang/attribute/src/bundle/mod.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
11
use heck::ToSnakeCase;
22
use proc_macro::TokenStream;
3-
use syn::{parse_macro_input, parse_quote, ItemMod};
43
use quote::ToTokens;
4+
use syn::{parse_macro_input, parse_quote, ItemMod};
55

6+
use crate::common::generate_program;
67
use crate::component;
78
use crate::system;
8-
use crate::common::generate_program;
99

1010
pub fn process(attr: TokenStream, item: TokenStream) -> TokenStream {
1111
let bundle_mod = parse_macro_input!(item as ItemMod);
1212
let mut program = generate_program(&bundle_mod.ident.to_string());
1313
if attr.to_string().contains("delegate") {
14-
program.attrs.insert(0, syn::parse_quote! { #[bolt_lang::delegate] });
14+
program
15+
.attrs
16+
.insert(0, syn::parse_quote! { #[bolt_lang::delegate] });
1517
}
1618
if let Some((_, items)) = bundle_mod.content {
1719
for item in items {
1820
match item {
1921
syn::Item::Struct(item) => {
2022
let attributes = component::Attributes::from(item.attrs.clone());
2123
if attributes.is_component {
22-
let data = syn::Data::Struct(syn::DataStruct { struct_token: Default::default(), fields: item.fields, semi_token: Default::default() });
24+
let data = syn::Data::Struct(syn::DataStruct {
25+
struct_token: Default::default(),
26+
fields: item.fields,
27+
semi_token: Default::default(),
28+
});
2329
let mut type_ = syn::DeriveInput {
2430
attrs: item.attrs,
2531
vis: item.vis,
2632
ident: item.ident,
2733
generics: item.generics,
28-
data: data,
34+
data,
2935
};
3036
component::generate_implementation(&mut program, &attributes, &type_);
31-
component::generate_instructions(&mut program, &attributes, &type_.ident, Some(&type_.ident.to_string().to_snake_case()));
37+
component::generate_instructions(
38+
&mut program,
39+
&attributes,
40+
&type_.ident,
41+
Some(&type_.ident.to_string().to_snake_case()),
42+
);
3243
component::remove_component_attributes(&mut type_.attrs);
3344
component::enrich_type(&mut type_);
3445
let (_, items) = program.content.as_mut().unwrap();
@@ -43,7 +54,8 @@ pub fn process(attr: TokenStream, item: TokenStream) -> TokenStream {
4354
syn::Item::Mod(mut mod_item) => {
4455
if mod_item.attrs.iter().any(|a| a.path.is_ident("system")) {
4556
let suffix = mod_item.ident.to_string().to_snake_case();
46-
let inlined_items = system::transform_module_for_bundle(&mut mod_item, Some(&suffix));
57+
let inlined_items =
58+
system::transform_module_for_bundle(&mut mod_item, Some(&suffix));
4759
let (_, program_items) = program.content.as_mut().unwrap();
4860
program_items.extend(inlined_items.into_iter());
4961
} else {
@@ -64,4 +76,3 @@ pub fn process(attr: TokenStream, item: TokenStream) -> TokenStream {
6476

6577
program.to_token_stream().into()
6678
}
67-

0 commit comments

Comments
 (0)