From afd4fcaccc398eda6b8b798814eeb0b423931136 Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Tue, 5 Nov 2024 09:41:35 +0100 Subject: [PATCH] :recycle: Code Refactor --- cli/src/templates/workspace.rs | 76 ++++++++++++++++------------------ programs/world/src/lib.rs | 1 + 2 files changed, 37 insertions(+), 40 deletions(-) diff --git a/cli/src/templates/workspace.rs b/cli/src/templates/workspace.rs index 2b33bc3..ebd25cc 100644 --- a/cli/src/templates/workspace.rs +++ b/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() } } diff --git a/programs/world/src/lib.rs b/programs/world/src/lib.rs index b97f4a9..2082917 100644 --- a/programs/world/src/lib.rs +++ b/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;