Browse Source

:recycle: Code Refactor

Gabriele Picco 11 months ago
parent
commit
afd4fcaccc
2 changed files with 37 additions and 40 deletions
  1. 36 40
      cli/src/templates/workspace.rs
  2. 1 0
      programs/world/src/lib.rs

+ 36 - 40
cli/src/templates/workspace.rs

@@ -24,50 +24,47 @@ codegen-units = 1
 
 pub fn package_json(jest: bool) -> String {
     if jest {
-        format!(
-            r#"{{
-        "scripts": {{
-            "lint:fix": "node_modules/.bin/prettier */*.js \"*/**/*{{.js,.ts}}\" -w",
-            "lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
-        }},
-        "devDependencies": {{
+        r#"{
+        "scripts": {
+            "lint:fix": "node_modules/.bin/prettier */*.js \"*/**/*{.js,.ts}\" -w",
+            "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
+        },
+        "devDependencies": {
             "jest": "^29.0.3",
             "prettier": "^2.6.2",
             "@magicblock-labs/bolt-sdk": "latest"
-        }}
-    }}
+        }
+    }
     "#
-        )
+        .to_string()
     } else {
-        format!(
-            r#"{{
-    "scripts": {{
-        "lint:fix": "node_modules/.bin/prettier */*.js \"*/**/*{{.js,.ts}}\" -w",
-        "lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
-    }},
-    "devDependencies": {{
+        r#"{
+    "scripts": {
+        "lint:fix": "node_modules/.bin/prettier */*.js \"*/**/*{.js,.ts}\" -w",
+        "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
+    },
+    "devDependencies": {
         "chai": "^4.3.4",
         "mocha": "^9.0.3",
         "prettier": "^2.6.2",
         "@metaplex-foundation/beet": "^0.7.1",
         "@metaplex-foundation/beet-solana": "^0.4.0",
         "@magicblock-labs/bolt-sdk": "latest"
-    }}
-}}
+    }
+}
 "#
-        )
+        .to_string()
     }
 }
 
 pub fn ts_package_json(jest: bool) -> String {
     if jest {
-        format!(
-            r#"{{
-        "scripts": {{
-            "lint:fix": "node_modules/.bin/prettier */*.js \"*/**/*{{.js,.ts}}\" -w",
-            "lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
-        }},
-        "devDependencies": {{
+        r#"{
+        "scripts": {
+            "lint:fix": "node_modules/.bin/prettier */*.js \"*/**/*{.js,.ts}\" -w",
+            "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
+        },
+        "devDependencies": {
             "@types/bn.js": "^5.1.0",
             "@types/jest": "^29.0.3",
             "jest": "^29.0.3",
@@ -77,18 +74,17 @@ pub fn ts_package_json(jest: bool) -> String {
             "@metaplex-foundation/beet": "^0.7.1",
             "@metaplex-foundation/beet-solana": "^0.4.0",
             "@magicblock-labs/bolt-sdk": "latest"
-        }}
-    }}
+        }
+    }
     "#
-        )
+        .to_string()
     } else {
-        format!(
-            r#"{{
-    "scripts": {{
-        "lint:fix": "node_modules/.bin/prettier */*.js \"*/**/*{{.js,.ts}}\" -w",
-        "lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
-    }},
-    "devDependencies": {{
+        r#"{
+    "scripts": {
+        "lint:fix": "node_modules/.bin/prettier */*.js \"*/**/*{.js,.ts}\" -w",
+        "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
+    },
+    "devDependencies": {
         "chai": "^4.3.4",
         "mocha": "^9.0.3",
         "ts-mocha": "^10.0.0",
@@ -100,10 +96,10 @@ pub fn ts_package_json(jest: bool) -> String {
         "@metaplex-foundation/beet": "^0.7.1",
         "@metaplex-foundation/beet-solana": "^0.4.0",
         "@magicblock-labs/bolt-sdk": "latest"
-    }}
-}}
+    }
+}
 "#
-        )
+        .to_string()
     }
 }
 

+ 1 - 0
programs/world/src/lib.rs

@@ -1,3 +1,4 @@
+#![allow(clippy::manual_unwrap_or_default)]
 use anchor_lang::prelude::*;
 use bolt_helpers_world_apply::apply_system;
 use std::collections::BTreeSet;