瀏覽代碼

:adhesive_bandage: Explicit Default in components to allow custom defaults (#32)

* :adhesive_bandage: Explicit Defualt in components to allow custom defaults

* :construction_worker: Update Rust toolkit version

* :construction_worker: Update CI/CD

* :construction_worker: Use global rust version

* :construction_worker: Use rust version

* :construction_worker: Update Solana cli

* :bug: Fix component derive template
Gabriele Picco 1 年之前
父節點
當前提交
12f5f89c86

+ 1 - 1
.github/workflows/run-tests.yml

@@ -6,7 +6,7 @@ on:
   pull_request:
 
 env:
-  solana_version: v1.18.1
+  solana_version: v1.18.8
   anchor_version: 0.29.0
 
 jobs:

+ 1 - 0
cli/src/rust_template.rs

@@ -50,6 +50,7 @@ fn create_component_template_simple(name: &str, program_path: &Path) -> Files {
 declare_id!("{}");
 
 #[component]
+#[derive(Default)]
 pub struct {} {{
     pub x: i64,
     pub y: i64,

+ 1 - 1
crates/bolt-lang/attribute/component/src/lib.rs

@@ -55,7 +55,7 @@ pub fn component(attr: TokenStream, item: TokenStream) -> TokenStream {
     let component_id_value = component_id_value.unwrap_or_else(|| "".to_string());
 
     let additional_macro: Attribute = parse_quote! { #[account] };
-    let additional_derives: Attribute = parse_quote! { #[derive(InitSpace, Default)] };
+    let additional_derives: Attribute = parse_quote! { #[derive(InitSpace)] };
     input.attrs.push(additional_derives);
 
     add_bolt_metadata(&mut input);

+ 1 - 1
examples/component-position/src/lib.rs

@@ -3,7 +3,7 @@ use bolt_lang::*;
 declare_id!("Fn1JzzEdyb55fsyduWS94mYHizGhJZuhvjX6DVvrmGbQ");
 
 #[component]
-#[derive(Copy)]
+#[derive(Copy, Default)]
 pub struct Position {
     pub x: i64,
     pub y: i64,

+ 1 - 0
examples/component-velocity/src/lib.rs

@@ -3,6 +3,7 @@ use bolt_lang::*;
 declare_id!("CbHEFbSQdRN4Wnoby9r16umnJ1zWbULBHg4yqzGQonU1");
 
 #[component(component_id = "component-velocity")]
+#[derive(Default)]
 pub struct Velocity {
     pub x: i64,
     pub y: i64,