From 5071cc248475f7310fbb09834309166fb2fb3b66 Mon Sep 17 00:00:00 2001 From: Danilo Guanabara Date: Fri, 6 Dec 2024 12:35:40 -0300 Subject: [PATCH 1/2] refactor: re-exporting anchor-lang --- Cargo.lock | 5 ----- cli/src/templates/program/constants.rs.template | 4 ++-- cli/src/templates/program/error.rs.template | 2 +- .../templates/program/instructions/initialize.rs.template | 2 +- cli/src/templates/program/multiple.lib.rs.template | 2 +- cli/src/templates/program/single.lib.rs.template | 2 +- cli/src/templates/workspace/Cargo.serde.toml.template | 7 +++---- cli/src/templates/workspace/Cargo.toml.template | 5 ++--- cli/src/templates/workspace/mod.rs | 4 +--- cli/src/templates/workspace/workspace.toml.template | 1 - crates/bolt-lang/Cargo.toml | 4 ++++ crates/bolt-lang/src/lib.rs | 3 +++ crates/bolt-lang/src/prelude.rs | 2 ++ examples/component-position/Cargo.toml | 5 ++--- examples/component-velocity/Cargo.toml | 5 ++--- examples/system-apply-velocity/Cargo.toml | 5 ++--- examples/system-fly/Cargo.toml | 5 ++--- examples/system-simple-movement/Cargo.toml | 5 ++--- 18 files changed, 31 insertions(+), 37 deletions(-) create mode 100644 crates/bolt-lang/src/prelude.rs diff --git a/Cargo.lock b/Cargo.lock index 67e6fee..2f1ce28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3365,7 +3365,6 @@ dependencies = [ name = "position" version = "0.1.11" dependencies = [ - "anchor-lang", "bolt-lang 0.1.11", ] @@ -5486,7 +5485,6 @@ dependencies = [ name = "system-apply-velocity" version = "0.1.11" dependencies = [ - "anchor-lang", "anchor-spl", "bolt-lang 0.1.11", "position", @@ -5518,7 +5516,6 @@ dependencies = [ name = "system-fly" version = "0.1.11" dependencies = [ - "anchor-lang", "bolt-lang 0.1.11", "position", ] @@ -5527,7 +5524,6 @@ dependencies = [ name = "system-simple-movement" version = "0.1.11" dependencies = [ - "anchor-lang", "bolt-lang 0.1.11", "bolt-types", "serde", @@ -6037,7 +6033,6 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" name = "velocity" version = "0.1.11" dependencies = [ - "anchor-lang", "bolt-lang 0.1.11", ] diff --git a/cli/src/templates/program/constants.rs.template b/cli/src/templates/program/constants.rs.template index fae4535..aca644d 100644 --- a/cli/src/templates/program/constants.rs.template +++ b/cli/src/templates/program/constants.rs.template @@ -1,4 +1,4 @@ -use anchor_lang::prelude::*; +use bolt_lang::prelude::*; #[constant] -pub const SEED: &str = "anchor"; +pub const SEED: &str = "bolt"; diff --git a/cli/src/templates/program/error.rs.template b/cli/src/templates/program/error.rs.template index c37199a..13b369b 100644 --- a/cli/src/templates/program/error.rs.template +++ b/cli/src/templates/program/error.rs.template @@ -1,4 +1,4 @@ -use anchor_lang::prelude::*; +use bolt_lang::prelude::*; #[error_code] pub enum ErrorCode { diff --git a/cli/src/templates/program/instructions/initialize.rs.template b/cli/src/templates/program/instructions/initialize.rs.template index bc0305f..9bd6c2f 100644 --- a/cli/src/templates/program/instructions/initialize.rs.template +++ b/cli/src/templates/program/instructions/initialize.rs.template @@ -1,4 +1,4 @@ -use anchor_lang::prelude::*; +use bolt_lang::prelude::*; #[derive(Accounts)] pub struct Initialize {} diff --git a/cli/src/templates/program/multiple.lib.rs.template b/cli/src/templates/program/multiple.lib.rs.template index 66359f6..a76fea4 100644 --- a/cli/src/templates/program/multiple.lib.rs.template +++ b/cli/src/templates/program/multiple.lib.rs.template @@ -3,7 +3,7 @@ pub mod error; pub mod instructions; pub mod state; -use anchor_lang::prelude::*; +use bolt_lang::prelude::*; pub use constants::*; pub use instructions::*; diff --git a/cli/src/templates/program/single.lib.rs.template b/cli/src/templates/program/single.lib.rs.template index 2707a57..c7a6f75 100644 --- a/cli/src/templates/program/single.lib.rs.template +++ b/cli/src/templates/program/single.lib.rs.template @@ -1,4 +1,4 @@ -use anchor_lang::prelude::*; +use bolt_lang::prelude::*; declare_id!("{program_id}"); diff --git a/cli/src/templates/workspace/Cargo.serde.toml.template b/cli/src/templates/workspace/Cargo.serde.toml.template index 1fa5200..ba1ca6f 100644 --- a/cli/src/templates/workspace/Cargo.serde.toml.template +++ b/cli/src/templates/workspace/Cargo.serde.toml.template @@ -14,13 +14,12 @@ no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] default = [] -idl-build = ["anchor-lang/idl-build"] -anchor-debug = ["anchor-lang/anchor-debug"] +idl-build = ["bolt-lang/idl-build"] +anchor-debug = ["bolt-lang/anchor-debug"] custom-heap = [] custom-panic = [] [dependencies] bolt-lang.workspace = true -anchor-lang.workspace = true -serde = {{ version = "1.0", features = ["derive"] }} \ No newline at end of file +serde = {{ version = "1.0", features = ["derive"] }} diff --git a/cli/src/templates/workspace/Cargo.toml.template b/cli/src/templates/workspace/Cargo.toml.template index 6572742..df7e76e 100644 --- a/cli/src/templates/workspace/Cargo.toml.template +++ b/cli/src/templates/workspace/Cargo.toml.template @@ -14,11 +14,10 @@ no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] default = [] -idl-build = ["anchor-lang/idl-build"] -anchor-debug = ["anchor-lang/anchor-debug"] +idl-build = ["bolt-lang/idl-build"] +anchor-debug = ["bolt-lang/anchor-debug"] custom-heap = [] custom-panic = [] [dependencies] bolt-lang.workspace = true -anchor-lang.workspace = true diff --git a/cli/src/templates/workspace/mod.rs b/cli/src/templates/workspace/mod.rs index 43368cb..cf18009 100644 --- a/cli/src/templates/workspace/mod.rs +++ b/cli/src/templates/workspace/mod.rs @@ -1,12 +1,10 @@ use crate::VERSION; use heck::ToSnakeCase; -pub const ANCHOR_VERSION: &str = anchor_cli::VERSION; pub fn workspace_manifest() -> String { format!( include_str!("workspace.toml.template"), - VERSION = VERSION, - ANCHOR_VERSION = ANCHOR_VERSION + VERSION = VERSION ) } diff --git a/cli/src/templates/workspace/workspace.toml.template b/cli/src/templates/workspace/workspace.toml.template index 811cc37..66c266b 100644 --- a/cli/src/templates/workspace/workspace.toml.template +++ b/cli/src/templates/workspace/workspace.toml.template @@ -8,7 +8,6 @@ resolver = "2" [workspace.dependencies] bolt-lang = "{VERSION}" -anchor-lang = "{ANCHOR_VERSION}" [profile.release] overflow-checks = true diff --git a/crates/bolt-lang/Cargo.toml b/crates/bolt-lang/Cargo.toml index 151ef84..05eb5dc 100644 --- a/crates/bolt-lang/Cargo.toml +++ b/crates/bolt-lang/Cargo.toml @@ -8,6 +8,10 @@ homepage = { workspace = true } license = { workspace = true } edition = { workspace = true } +[features] +anchor-debug = ["anchor-lang/anchor-debug"] +idl-build = ["anchor-lang/idl-build"] + [dependencies] anchor-lang = { workspace = true } diff --git a/crates/bolt-lang/src/lib.rs b/crates/bolt-lang/src/lib.rs index d747e35..e2dc05a 100644 --- a/crates/bolt-lang/src/lib.rs +++ b/crates/bolt-lang/src/lib.rs @@ -1,3 +1,6 @@ +pub mod prelude; + +pub use anchor_lang; pub use anchor_lang::error::ErrorCode::AccountDidNotDeserialize as AccountDidNotDeserializeErrorCode; pub use anchor_lang::prelude::*; pub use anchor_lang::{ diff --git a/crates/bolt-lang/src/prelude.rs b/crates/bolt-lang/src/prelude.rs new file mode 100644 index 0000000..ddbde75 --- /dev/null +++ b/crates/bolt-lang/src/prelude.rs @@ -0,0 +1,2 @@ +pub use anchor_lang; +pub use anchor_lang::prelude::*; \ No newline at end of file diff --git a/examples/component-position/Cargo.toml b/examples/component-position/Cargo.toml index 1bd480d..8a77a47 100644 --- a/examples/component-position/Cargo.toml +++ b/examples/component-position/Cargo.toml @@ -18,11 +18,10 @@ no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] default = [] -idl-build = ["anchor-lang/idl-build"] -anchor-debug = ["anchor-lang/anchor-debug"] +idl-build = ["bolt-lang/idl-build"] +anchor-debug = ["bolt-lang/anchor-debug"] custom-heap = [] custom-panic = [] [dependencies] -anchor-lang = { workspace = true } bolt-lang = { path = "../../crates/bolt-lang" } diff --git a/examples/component-velocity/Cargo.toml b/examples/component-velocity/Cargo.toml index 94c951d..62ccfd9 100644 --- a/examples/component-velocity/Cargo.toml +++ b/examples/component-velocity/Cargo.toml @@ -18,12 +18,11 @@ no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] default = [] -idl-build = ["anchor-lang/idl-build"] -anchor-debug = ["anchor-lang/anchor-debug"] +idl-build = ["bolt-lang/idl-build"] +anchor-debug = ["bolt-lang/anchor-debug"] custom-heap = [] custom-panic = [] [dependencies] -anchor-lang = { workspace = true } bolt-lang = { path = "../../crates/bolt-lang" } diff --git a/examples/system-apply-velocity/Cargo.toml b/examples/system-apply-velocity/Cargo.toml index 2b76b93..4dd49cc 100644 --- a/examples/system-apply-velocity/Cargo.toml +++ b/examples/system-apply-velocity/Cargo.toml @@ -18,13 +18,12 @@ no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] default = [] -idl-build = ["anchor-lang/idl-build"] -anchor-debug = ["anchor-lang/anchor-debug"] +idl-build = ["bolt-lang/idl-build"] +anchor-debug = ["bolt-lang/anchor-debug"] custom-heap = [] custom-panic = [] [dependencies] -anchor-lang = { workspace = true } anchor-spl = { workspace = true, features = ["metadata"]} bolt-lang = { path = "../../crates/bolt-lang" } velocity = { path = "../component-velocity", features = ["cpi"]} diff --git a/examples/system-fly/Cargo.toml b/examples/system-fly/Cargo.toml index 91ea6b2..3d5d8c7 100644 --- a/examples/system-fly/Cargo.toml +++ b/examples/system-fly/Cargo.toml @@ -18,13 +18,12 @@ no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] default = [] -idl-build = ["anchor-lang/idl-build"] -anchor-debug = ["anchor-lang/anchor-debug"] +idl-build = ["bolt-lang/idl-build"] +anchor-debug = ["bolt-lang/anchor-debug"] custom-heap = [] custom-panic = [] [dependencies] -anchor-lang = { workspace = true } bolt-lang = { path = "../../crates/bolt-lang" } position = { path = "../component-position", features = ["cpi"]} diff --git a/examples/system-simple-movement/Cargo.toml b/examples/system-simple-movement/Cargo.toml index 0735700..cdebf79 100644 --- a/examples/system-simple-movement/Cargo.toml +++ b/examples/system-simple-movement/Cargo.toml @@ -18,13 +18,12 @@ no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] default = [] -idl-build = ["anchor-lang/idl-build"] -anchor-debug = ["anchor-lang/anchor-debug"] +idl-build = ["bolt-lang/idl-build"] +anchor-debug = ["bolt-lang/anchor-debug"] custom-heap = [] custom-panic = [] [dependencies] -anchor-lang = { workspace = true } serde = { workspace = true } bolt-lang = { path = "../../crates/bolt-lang" } bolt-types = { version = "0.1.6", path = "../../crates/types" } From e486ab0a9d2ddcee74a21ba5d8e5076e353f3416 Mon Sep 17 00:00:00 2001 From: Danilo Guanabara Date: Fri, 6 Dec 2024 12:45:14 -0300 Subject: [PATCH 2/2] refactor: fixing lint errors --- cli/src/templates/workspace/mod.rs | 5 +---- crates/bolt-lang/src/prelude.rs | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cli/src/templates/workspace/mod.rs b/cli/src/templates/workspace/mod.rs index cf18009..e79370f 100644 --- a/cli/src/templates/workspace/mod.rs +++ b/cli/src/templates/workspace/mod.rs @@ -2,10 +2,7 @@ use crate::VERSION; use heck::ToSnakeCase; pub fn workspace_manifest() -> String { - format!( - include_str!("workspace.toml.template"), - VERSION = VERSION - ) + format!(include_str!("workspace.toml.template"), VERSION = VERSION) } pub fn package_json(jest: bool) -> String { diff --git a/crates/bolt-lang/src/prelude.rs b/crates/bolt-lang/src/prelude.rs index ddbde75..eacd997 100644 --- a/crates/bolt-lang/src/prelude.rs +++ b/crates/bolt-lang/src/prelude.rs @@ -1,2 +1,2 @@ pub use anchor_lang; -pub use anchor_lang::prelude::*; \ No newline at end of file +pub use anchor_lang::prelude::*;