From 2ece7e4491566058bf63a25ae65e7709e2cdbddd Mon Sep 17 00:00:00 2001 From: nickfrosty Date: Thu, 26 Oct 2023 16:13:44 -0400 Subject: [PATCH 1/4] feat: added prettier commands --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cc8c24be5..5913f5340 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,13 @@ "scripts": { "runner": "npx ts-node -r tsconfig-paths/register", "contentlayer:build": "npx contentlayer build --clearCache", - "test": "yarn contentlayer:build", "dev": "yarn contentlayer:build && next dev -p 3001", "build": "yarn contentlayer:build && next build", "start": "next start", - "lint": "next lint" + "test": "yarn contentlayer:build", + "lint": "next lint", + "prettier:check": "prettier -c .", + "prettier:fix": "prettier -cw ." }, "dependencies": { "@types/node": "20.4.2", From 4232665d8435f18a6e95e2670d99d07cae32e96d Mon Sep 17 00:00:00 2001 From: nickfrosty Date: Thu, 26 Oct 2023 16:15:15 -0400 Subject: [PATCH 2/4] feat: added formatting workflow --- .github/workflows/formatting.yml | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/formatting.yml diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml new file mode 100644 index 000000000..da1b68f64 --- /dev/null +++ b/.github/workflows/formatting.yml @@ -0,0 +1,47 @@ +name: Formatting / Lint +on: + push: + branches: [master] + pull_request: + branches: [master] +jobs: + Format: + name: Test formatting via prettier... + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Use Node.js node + uses: actions/setup-node@v2 + with: + node-version: "18" + - name: before_install + run: + echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf + && sudo sysctl -p + + - name: installing yarn + run: yarn install + - name: prettier:check + run: yarn prettier:check + stage: + name: Test linting... + needs: Format + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Use Node.js node + uses: actions/setup-node@v2 + with: + node-version: "18" + - name: before_install + run: + echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf + && sudo sysctl -p + + - name: installing yarn + run: yarn install + - name: lint + run: yarn lint From dbebec239f8061a86c7ca48a82d63a0c0f4ea64d Mon Sep 17 00:00:00 2001 From: nickfrosty Date: Thu, 26 Oct 2023 16:27:45 -0400 Subject: [PATCH 3/4] fix: master / main branch names --- .github/workflows/formatting.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index da1b68f64..4ed49b6b5 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -1,9 +1,9 @@ name: Formatting / Lint on: push: - branches: [master] + branches: [master, main] pull_request: - branches: [master] + branches: [master, main] jobs: Format: name: Test formatting via prettier... From 4f00173196652bc8ca534d3fb271d2c2f646dd2d Mon Sep 17 00:00:00 2001 From: nickfrosty Date: Fri, 27 Oct 2023 08:13:58 -0400 Subject: [PATCH 4/4] chore: prettier --- content/courses/solana-course/content/arbitrary-cpi.md | 10 ++++------ .../courses/solana-course/content/closing-accounts.md | 5 ++--- .../solana-course/content/reinitialization-attacks.md | 5 ++--- docs/learn/state-compression.md | 5 ++--- src/pages/api/nav/[group].ts | 2 +- src/pages/api/overview.ts | 2 +- src/pages/api/paths/[group].ts | 2 +- 7 files changed, 13 insertions(+), 18 deletions(-) diff --git a/content/courses/solana-course/content/arbitrary-cpi.md b/content/courses/solana-course/content/arbitrary-cpi.md index 3b0bc53d6..c9b56ade6 100644 --- a/content/courses/solana-course/content/arbitrary-cpi.md +++ b/content/courses/solana-course/content/arbitrary-cpi.md @@ -289,13 +289,11 @@ it("Insecure instructions allow attacker to win every time", async () => { fakeMetadataProgram.programId, ); - const playerOneMetadata = await metadataProgram.account.metadata.fetch( - playerOneMetadataKey, - ); + const playerOneMetadata = + await metadataProgram.account.metadata.fetch(playerOneMetadataKey); - const attackerMetadata = await fakeMetadataProgram.account.metadata.fetch( - attackerMetadataKey, - ); + const attackerMetadata = + await fakeMetadataProgram.account.metadata.fetch(attackerMetadataKey); // The regular player should have health and power between 0 and 20 expect(playerOneMetadata.health).to.be.lessThan(20); diff --git a/content/courses/solana-course/content/closing-accounts.md b/content/courses/solana-course/content/closing-accounts.md index 771172fb6..3cd691092 100644 --- a/content/courses/solana-course/content/closing-accounts.md +++ b/content/courses/solana-course/content/closing-accounts.md @@ -352,9 +352,8 @@ it("attacker can close + refund lottery acct + claim multiple rewards", async ( } const ata = await getAccount(provider.connection, attackerAta); - const lotteryEntry = await program.account.lotteryAccount.fetch( - attackerLotteryEntry, - ); + const lotteryEntry = + await program.account.lotteryAccount.fetch(attackerLotteryEntry); expect(Number(ata.amount)).to.equal( lotteryEntry.timestamp.toNumber() * 10 * 2, diff --git a/content/courses/solana-course/content/reinitialization-attacks.md b/content/courses/solana-course/content/reinitialization-attacks.md index a340fd735..350ec13c3 100644 --- a/content/courses/solana-course/content/reinitialization-attacks.md +++ b/content/courses/solana-course/content/reinitialization-attacks.md @@ -298,9 +298,8 @@ describe("initialization", () => { fromPubkey: wallet.publicKey, newAccountPubkey: userInsecure.publicKey, space: 32, - lamports: await provider.connection.getMinimumBalanceForRentExemption( - 32, - ), + lamports: + await provider.connection.getMinimumBalanceForRentExemption(32), programId: program.programId, }), ); diff --git a/docs/learn/state-compression.md b/docs/learn/state-compression.md index 993544944..5bb865e9e 100644 --- a/docs/learn/state-compression.md +++ b/docs/learn/state-compression.md @@ -286,9 +286,8 @@ const requiredSpace = getConcurrentMerkleTreeAccountSize( ); // get the cost (in lamports) to store the tree on-chain -const storageCost = await connection.getMinimumBalanceForRentExemption( - requiredSpace, -); +const storageCost = + await connection.getMinimumBalanceForRentExemption(requiredSpace); ``` ### Example costs diff --git a/src/pages/api/nav/[group].ts b/src/pages/api/nav/[group].ts index c0f64f09f..7a115a26c 100644 --- a/src/pages/api/nav/[group].ts +++ b/src/pages/api/nav/[group].ts @@ -30,7 +30,7 @@ export default function handler( return allDeveloperGuides; // case "resources": // return allDeveloperResources; - case "workshops": + case "workshops": return allDeveloperWorkshops; } })(group); diff --git a/src/pages/api/overview.ts b/src/pages/api/overview.ts index c3c9bf90b..d17456ecd 100644 --- a/src/pages/api/overview.ts +++ b/src/pages/api/overview.ts @@ -8,7 +8,7 @@ import type { NextApiRequest, NextApiResponse } from "next"; import { allDeveloperGuides, allDeveloperResources, - allDeveloperWorkshops + allDeveloperWorkshops, } from "contentlayer/generated"; import { extractFeaturedRecords, simplifyRecords } from "@/utils/parsers"; diff --git a/src/pages/api/paths/[group].ts b/src/pages/api/paths/[group].ts index e85f262c5..769b4bc23 100644 --- a/src/pages/api/paths/[group].ts +++ b/src/pages/api/paths/[group].ts @@ -10,7 +10,7 @@ import { allDeveloperGuides, allDeveloperResources, allSolanaDocs, - allDeveloperWorkshops + allDeveloperWorkshops, } from "contentlayer/generated"; export default function handler(