Browse Source

lint fix biome

Ayush 9 months ago
parent
commit
478eee7ad8
40 changed files with 391 additions and 497 deletions
  1. 1 1
      basics/checking-accounts/poseidon/package.json
  2. 11 18
      basics/checking-accounts/poseidon/tests/checking-accounts.ts
  3. 6 14
      basics/checking-accounts/poseidon/ts-programs/src/checkingAccounts.ts
  4. 1 1
      basics/close-account/steel/tests/close-account.test.ts
  5. 1 1
      basics/close-account/steel/ts/instructions/close.ts
  6. 3 3
      basics/close-account/steel/ts/instructions/create.ts
  7. 1 1
      basics/counter/poseidon/counter-program/migrations/deploy.ts
  8. 18 27
      basics/counter/poseidon/counter-program/tests/counter-program.test.ts
  9. 8 9
      basics/counter/poseidon/counter-program/tests/tsconfig.test.json
  10. 4 13
      basics/counter/poseidon/counter-program/ts-programs/src/counter-program.ts
  11. 15 14
      basics/favorites/native/program/src/instructions/create_pda.rs
  12. 18 15
      basics/favorites/native/program/src/instructions/get_pda.rs
  13. 1 4
      basics/favorites/native/program/src/lib.rs
  14. 2 6
      basics/favorites/native/program/src/processor.rs
  15. 2 4
      basics/favorites/native/program/src/state.rs
  16. 95 81
      basics/favorites/native/tests/test.ts
  17. 2 2
      basics/hello-solana/poseidon/hello-solana/migrations/deploy.ts
  18. 20 20
      basics/hello-solana/poseidon/hello-solana/package.json
  19. 11 19
      basics/hello-solana/poseidon/hello-solana/tests/bankrun.test.ts
  20. 7 8
      basics/hello-solana/poseidon/hello-solana/tests/test.ts
  21. 3 5
      basics/hello-solana/poseidon/hello-solana/ts-programs/src/hello-solana.ts
  22. 9 10
      basics/hello-solana/poseidon/hello-solana/tsconfig.json
  23. 11 20
      basics/transfer-sol/poseidon/tests/transferSol.ts
  24. 3 12
      basics/transfer-sol/poseidon/ts-programs/src/transferSol.ts
  25. 2 2
      tokens/escrow/poseidon/escrow/migrations/deploy.ts
  26. 20 20
      tokens/escrow/poseidon/escrow/package.json
  27. 20 24
      tokens/escrow/poseidon/escrow/tests/bankrun.test.ts
  28. 14 22
      tokens/escrow/poseidon/escrow/tests/escrow.ts
  29. 18 31
      tokens/escrow/poseidon/escrow/ts-programs/src/escrow.ts
  30. 9 10
      tokens/escrow/poseidon/escrow/tsconfig.json
  31. 6 6
      tokens/escrow/steel/tests/bankrun.test.ts
  32. 4 4
      tokens/escrow/steel/tests/utils.ts
  33. 1 1
      tokens/external-delegate-token-master/anchor/package.json
  34. 16 20
      tokens/external-delegate-token-master/anchor/tests/external-delegate-token-master.test.ts
  35. 0 17
      tokens/external-delegate-token-master/anchor/tests/types.js
  36. 16 0
      tokens/external-delegate-token-master/anchor/tests/types.ts
  37. 7 27
      tokens/external-delegate-token-master/anchor/tsconfig.json
  38. 1 1
      tokens/spl-token-minter/poseidon/ts-programs/src/splTokenMinter.ts
  39. 2 2
      tokens/token-swap/steel/tests/create_pool_and_swap.test.ts
  40. 2 2
      tokens/token-swap/steel/tests/create_pool_and_withdraw_all_liquid.test.ts

+ 1 - 1
basics/checking-accounts/poseidon/package.json

@@ -1,5 +1,5 @@
 {
-  "license": "ISC",  
+  "license": "ISC",
   "scripts": {
     "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
     "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"

+ 11 - 18
basics/checking-accounts/poseidon/tests/checking-accounts.ts

@@ -1,16 +1,15 @@
-import * as anchor from "@coral-xyz/anchor";
-import { Program } from "@coral-xyz/anchor";
-import { CheckingAccounts } from "../target/types/checking_accounts";
-import { Keypair, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";
-import { BN } from "bn.js";
+import * as anchor from '@coral-xyz/anchor';
+import { Program } from '@coral-xyz/anchor';
+import { Keypair, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js';
+import { BN } from 'bn.js';
+import { CheckingAccounts } from '../target/types/checking_accounts';
 
-describe("checking-accounts", () => {
+describe('checking-accounts', () => {
   // Configure the client to use the local cluster.
   const provider = anchor.AnchorProvider.env();
   anchor.setProvider(provider);
 
-  const program = anchor.workspace
-    .CheckingAccounts as Program<CheckingAccounts>;
+  const program = anchor.workspace.CheckingAccounts as Program<CheckingAccounts>;
 
   // Generate new user keypairs for testing
   const user = Keypair.generate();
@@ -22,10 +21,7 @@ describe("checking-accounts", () => {
     const latestBlockHash = await provider.connection.getLatestBlockhash();
 
     // Airdrop 1 SOL to the user
-    const airdropUser = await provider.connection.requestAirdrop(
-      user.publicKey,
-      1 * LAMPORTS_PER_SOL
-    );
+    const airdropUser = await provider.connection.requestAirdrop(user.publicKey, 1 * LAMPORTS_PER_SOL);
     await provider.connection.confirmTransaction({
       blockhash: latestBlockHash.blockhash,
       lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
@@ -33,13 +29,10 @@ describe("checking-accounts", () => {
     });
 
     // Derive PDA for the user account
-    [userAccount, userAccountBump] = await PublicKey.findProgramAddressSync(
-      [Buffer.from("program")],
-      program.programId
-    );
+    [userAccount, userAccountBump] = await PublicKey.findProgramAddressSync([Buffer.from('program')], program.programId);
   });
 
-  it("Initialize User Account", async () => {
+  it('Initialize User Account', async () => {
     // Initialize user account instruction invoked from the program
     await program.methods
       .initialize(new BN(1))
@@ -51,7 +44,7 @@ describe("checking-accounts", () => {
       .rpc();
   });
 
-  it("Updates the User Account data", async () => {
+  it('Updates the User Account data', async () => {
     // Update user account instruction invoked from the program
     await program.methods
       .update(new BN(2))

+ 6 - 14
basics/checking-accounts/poseidon/ts-programs/src/checkingAccounts.ts

@@ -1,28 +1,20 @@
-import {
-  Account,
-  Pubkey,
-  type Result,
-  Signer,
-  u64,
-} from "@solanaturbine/poseidon";
+import { Account, Pubkey, type Result, Signer, u64 } from '@solanaturbine/poseidon';
 
 export default class CheckingAccounts {
   // Check 1: The program ID check is automatically handled by Anchor
-  static PROGRAM_ID = new Pubkey(
-    "8MWRHcfRvyUJpou8nD5oG7DmZ2Bmg99qBP8q5fZ5xJpg"
-  );
+  static PROGRAM_ID = new Pubkey('8MWRHcfRvyUJpou8nD5oG7DmZ2Bmg99qBP8q5fZ5xJpg');
 
   // Initialize user_account Instruction
   initialize(
     // ACCOUNTS
     payer: Signer, // Check: Signer account verification
     user_account: UserAccountState,
-    data: u64
+    data: u64,
   ): Result {
     // CONTEXT
 
     // Check 2: Account initialization state is handled by Anchor's init constraint
-    user_account.derive(["program"]).init();
+    user_account.derive(['program']).init();
 
     user_account.user_data = data;
     user_account.authority = payer.key;
@@ -33,13 +25,13 @@ export default class CheckingAccounts {
     // ACCOUNTS
     authority: Signer,
     user_account: UserAccountState,
-    new_data: u64
+    new_data: u64,
   ): Result {
     // CONTEXT
 
     // Check 3: Ensures PDA matches the expected seeds
     // Check 4: Validates that the stored authority matches the signer
-    user_account.derive(["program"]).has([authority]).constraints([]);
+    user_account.derive(['program']).has([authority]).constraints([]);
 
     user_account.user_data = new_data;
   }

+ 1 - 1
basics/close-account/steel/tests/close-account.test.ts

@@ -1,7 +1,7 @@
 import { describe, test } from 'node:test';
 import { PublicKey, Transaction } from '@solana/web3.js';
 import { start } from 'solana-bankrun';
-import { createCreateUserInstruction, createCloseUserInstruction } from '../ts';
+import { createCloseUserInstruction, createCreateUserInstruction } from '../ts';
 
 describe('Close Account!', async () => {
   const PROGRAM_ID = new PublicKey('z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35');

+ 1 - 1
basics/close-account/steel/ts/instructions/close.ts

@@ -1,6 +1,6 @@
 import { Buffer } from 'node:buffer';
 import { type PublicKey, SystemProgram, TransactionInstruction } from '@solana/web3.js';
-import { closeAccountSchema, MyInstruction } from '.';
+import { MyInstruction, closeAccountSchema } from '.';
 
 export class Close {
   instruction: MyInstruction;

+ 3 - 3
basics/close-account/steel/ts/instructions/create.ts

@@ -1,10 +1,10 @@
 import { Buffer } from 'node:buffer';
 import { PublicKey, SystemProgram, TransactionInstruction } from '@solana/web3.js';
-import { closeAccountSchema, MyInstruction } from '.';
+import { MyInstruction, closeAccountSchema } from '.';
 
 export class Create {
   instruction: MyInstruction;
-  name: String;
+  name: string;
 
   constructor(props: { instruction: MyInstruction; name: string }) {
     this.instruction = props.instruction;
@@ -13,7 +13,7 @@ export class Create {
 
   toBuffer() {
     const textBuffer = Buffer.alloc(64);
-    let buffer = Buffer.alloc(1000);
+    const buffer = Buffer.alloc(1000);
 
     textBuffer.write('foobarbaz', 0, 'utf-8');
 

+ 1 - 1
basics/counter/poseidon/counter-program/migrations/deploy.ts

@@ -2,7 +2,7 @@
 // single deploy script that's invoked from the CLI, injecting a provider
 // configured from the workspace's Anchor.toml.
 
-const anchor = require("@coral-xyz/anchor");
+const anchor = require('@coral-xyz/anchor');
 
 module.exports = async (provider) => {
   // Configure client to use the provider.

+ 18 - 27
basics/counter/poseidon/counter-program/tests/counter-program.test.ts

@@ -1,48 +1,39 @@
-import { describe, it } from "node:test";
-import * as anchor from "@coral-xyz/anchor";
-import { Keypair, PublicKey } from "@solana/web3.js";
-import { BankrunProvider } from "anchor-bankrun";
-import { startAnchor } from "solana-bankrun";
-import type { CounterProgram } from "../target/types/counter_program";
-import { expect } from "chai";
+import { describe, it } from 'node:test';
+import * as anchor from '@coral-xyz/anchor';
+import { Keypair, PublicKey } from '@solana/web3.js';
+import { BankrunProvider } from 'anchor-bankrun';
+import { expect } from 'chai';
+import { startAnchor } from 'solana-bankrun';
+import type { CounterProgram } from '../target/types/counter_program';
 
-const IDL = require("../target/idl/counter_program.json");
+const IDL = require('../target/idl/counter_program.json');
 const PROGRAM_ID = new PublicKey(IDL.address);
 
-describe("counter_program", async () => {
-  const context = await startAnchor(
-    "",
-    [{ name: "counter_program", programId: PROGRAM_ID }],
-    []
-  );
+describe('counter_program', async () => {
+  const context = await startAnchor('', [{ name: 'counter_program', programId: PROGRAM_ID }], []);
   const provider = new BankrunProvider(context);
   const payer = provider.wallet as anchor.Wallet;
   const program = new anchor.Program<CounterProgram>(IDL, provider);
 
-  const [stateAccount, _] = anchor.web3.PublicKey.findProgramAddressSync(
-    [anchor.utils.bytes.utf8.encode("count")],
-    program.programId
-  );
+  const [stateAccount, _] = anchor.web3.PublicKey.findProgramAddressSync([anchor.utils.bytes.utf8.encode('count')], program.programId);
 
-  it("Initialize the counter", async () => {
+  it('Initialize the counter', async () => {
     await program.methods
       .initialize()
       .accounts({
         state: stateAccount as PublicKey,
         user: payer.publicKey,
       })
-      .signers([
-        { publicKey: payer.publicKey, secretKey: payer.payer.secretKey },
-      ])
+      .signers([{ publicKey: payer.publicKey, secretKey: payer.payer.secretKey }])
       .rpc();
 
     const account = await program.account.counterState.fetch(stateAccount);
-    console.log("Counter after initialization:", account.count.toString());
+    console.log('Counter after initialization:', account.count.toString());
     // Expecting the count to be 0
-    expect(account.count.toString()).to.equal("0");
+    expect(account.count.toString()).to.equal('0');
   });
 
-  it("Increment the counter", async () => {
+  it('Increment the counter', async () => {
     await program.methods
       .increment()
       .accounts({
@@ -51,7 +42,7 @@ describe("counter_program", async () => {
       .rpc();
 
     const account = await program.account.counterState.fetch(stateAccount);
-    console.log("Counter after increment:", account.count.toString());
-    expect(account.count.toString()).to.equal("1");
+    console.log('Counter after increment:', account.count.toString());
+    expect(account.count.toString()).to.equal('1');
   });
 });

+ 8 - 9
basics/counter/poseidon/counter-program/tests/tsconfig.test.json

@@ -1,11 +1,10 @@
 {
-    "compilerOptions": {
-      "types": ["mocha", "chai"],
-      "typeRoots": ["./node_modules/@types"],
-      "lib": ["es2015"],
-      "module": "commonjs",
-      "target": "es6",
-      "esModuleInterop": true
-    }
+  "compilerOptions": {
+    "types": ["mocha", "chai"],
+    "typeRoots": ["./node_modules/@types"],
+    "lib": ["es2015"],
+    "module": "commonjs",
+    "target": "es6",
+    "esModuleInterop": true
   }
-  
+}

+ 4 - 13
basics/counter/poseidon/counter-program/ts-programs/src/counter-program.ts

@@ -1,11 +1,4 @@
-import {
-  Account,
-  Pubkey,
-  Result,
-  u64,
-  u8,
-  Signer,
-} from "@solanaturbine/poseidon";
+import { Account, Pubkey, Result, Signer, u8, u64 } from '@solanaturbine/poseidon';
 
 // Interface representing the state of the counter
 export interface CounterState extends Account {
@@ -15,20 +8,18 @@ export interface CounterState extends Account {
 
 export default class CounterProgram {
   // The program ID for the CounterProgram
-  static PROGRAM_ID = new Pubkey(
-    "DMATyR7jooijeJ2aJYWiyYPf3eoUouumaaLw1JbG3TYF"
-  );
+  static PROGRAM_ID = new Pubkey('DMATyR7jooijeJ2aJYWiyYPf3eoUouumaaLw1JbG3TYF');
 
   // Method to initialize the counter state
   initialize(state: CounterState, user: Signer): Result {
-    state.derive(["count"]).init(); // Derive and initialize the count field
+    state.derive(['count']).init(); // Derive and initialize the count field
     state.count = new u64(0); // Set the initial count to 0
     return { success: true }; // Return a success result
   }
 
   // Method to increment the counter state
   increment(state: CounterState): Result {
-    state.derive(["count"]); // Derive the count field
+    state.derive(['count']); // Derive the count field
     state.count = state.count.add(1); // Increment the count by 1
     return { success: true }; // Return a success result
   }

+ 15 - 14
basics/favorites/native/program/src/instructions/create_pda.rs

@@ -1,29 +1,26 @@
+use crate::state::Favorites;
 use borsh::BorshSerialize;
 use solana_program::{
     account_info::{next_account_info, AccountInfo},
-    pubkey::Pubkey,
-    program_error::ProgramError,
     entrypoint::ProgramResult,
-    system_instruction,
     msg,
     program::invoke_signed,
+    program_error::ProgramError,
+    pubkey::Pubkey,
     rent::Rent,
-    sysvar::Sysvar
+    system_instruction,
+    sysvar::Sysvar,
 };
-use crate::state::Favorites;
 
-pub fn create_pda(
-    program_id: &Pubkey,
-    accounts: &[AccountInfo],
-    data: Favorites
-) -> ProgramResult {
+pub fn create_pda(program_id: &Pubkey, accounts: &[AccountInfo], data: Favorites) -> ProgramResult {
     let account_iter = &mut accounts.iter();
     let user = next_account_info(account_iter)?; // the user who's signing the transaction
     let favorite_account = next_account_info(account_iter)?; // The target account that will be created in the process
     let system_program = next_account_info(account_iter)?;
 
-    // deriving the favorite pda 
-    let (favorite_pda, favorite_bump) = Pubkey::find_program_address(&[b"favorite", user.key.as_ref()], program_id);
+    // deriving the favorite pda
+    let (favorite_pda, favorite_bump) =
+        Pubkey::find_program_address(&[b"favorite", user.key.as_ref()], program_id);
 
     // Checking if the favorite account is same as the derived favorite pda
     if favorite_account.key != &favorite_pda {
@@ -46,13 +43,17 @@ pub fn create_pda(
 
         invoke_signed(
             &ix,
-            &[user.clone(), favorite_account.clone(), system_program.clone()],
+            &[
+                user.clone(),
+                favorite_account.clone(),
+                system_program.clone(),
+            ],
             &[&[b"favorite", user.key.as_ref(), &[favorite_bump]]],
         )?;
 
         // Serialize and store the data
         data.serialize(&mut &mut favorite_account.data.borrow_mut()[..])?;
-        msg!("{:#?}",data);
+        msg!("{:#?}", data);
     } else {
         return Err(ProgramError::AccountAlreadyInitialized.into());
     }

+ 18 - 15
basics/favorites/native/program/src/instructions/get_pda.rs

@@ -1,32 +1,35 @@
+use crate::state::Favorites;
+use borsh::BorshDeserialize;
 use solana_program::{
+    account_info::{next_account_info, AccountInfo},
     entrypoint::ProgramResult,
-    account_info::{ AccountInfo, next_account_info},
     msg,
+    program_error::ProgramError,
     pubkey::Pubkey,
-    program_error::ProgramError
 };
-use borsh::BorshDeserialize;
-use crate::state::Favorites;
-
 
-pub fn get_pda(
-    program_id: &Pubkey,   
-    accounts: &[AccountInfo],
-) -> ProgramResult {
+pub fn get_pda(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
     let account_iter = &mut accounts.iter();
     let user = next_account_info(account_iter)?;
     let favorite_account = next_account_info(account_iter)?;
 
-    // deriving the favorite pda 
-    let (favorite_pda, _) = Pubkey::find_program_address(&[b"favorite", user.key.as_ref()], program_id);
+    // deriving the favorite pda
+    let (favorite_pda, _) =
+        Pubkey::find_program_address(&[b"favorite", user.key.as_ref()], program_id);
 
     // Checking if the favorite account is same as the derived favorite pda
     if favorite_account.key != &favorite_pda {
-      return Err(ProgramError::IncorrectProgramId);
+        return Err(ProgramError::IncorrectProgramId);
     };
-  
+
     let favorites = Favorites::try_from_slice(&favorite_account.data.borrow())?;
 
-    msg!("User {}'s favorite number is {}, favorite color is: {}, and their hobbies are {:#?}", user.key, favorites.number, favorites.color, favorites.hobbies);
+    msg!(
+        "User {}'s favorite number is {}, favorite color is: {}, and their hobbies are {:#?}",
+        user.key,
+        favorites.number,
+        favorites.color,
+        favorites.hobbies
+    );
     Ok(())
-}
+}

+ 1 - 4
basics/favorites/native/program/src/lib.rs

@@ -1,12 +1,9 @@
 use solana_program::entrypoint;
 
-pub mod state;
 pub mod instructions;
 pub mod processor;
+pub mod state;
 
 use processor::process_instruction;
 
 entrypoint!(process_instruction);
-
-
-

+ 2 - 6
basics/favorites/native/program/src/processor.rs

@@ -1,8 +1,4 @@
-use solana_program::{
-    account_info::AccountInfo, 
-    entrypoint::ProgramResult, 
-    pubkey::Pubkey,
-};
+use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey};
 
 use crate::instructions::{create_pda::*, get_pda::*};
 use crate::state::Favorites;
@@ -23,7 +19,7 @@ pub fn process_instruction(
 
     match instruction {
         FavoritesInstruction::CreatePda(data) => create_pda(program_id, accounts, data),
-        FavoritesInstruction::GetPda => get_pda(program_id,accounts),
+        FavoritesInstruction::GetPda => get_pda(program_id, accounts),
     }?;
 
     Ok(())

+ 2 - 4
basics/favorites/native/program/src/state.rs

@@ -4,10 +4,8 @@ use borsh::{BorshDeserialize, BorshSerialize};
 pub struct Favorites {
     pub number: u64,
     pub color: String,
-    pub hobbies: Vec<String>
+    pub hobbies: Vec<String>,
 }
 
 #[derive(BorshDeserialize, BorshSerialize)]
-pub struct GetFavorites {
-}
-
+pub struct GetFavorites {}

+ 95 - 81
basics/favorites/native/tests/test.ts

@@ -1,9 +1,9 @@
-import { describe, test } from 'mocha';
-import { assert, expect } from 'chai';
 import { Blockhash, Keypair, PublicKey, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js';
-import { BanksClient, ProgramTestContext, Rent, start , } from 'solana-bankrun';
 import { BN } from 'bn.js';
-import * as borsh from "borsh"
+import * as borsh from 'borsh';
+import { assert, expect } from 'chai';
+import { describe, test } from 'mocha';
+import { BanksClient, ProgramTestContext, Rent, start } from 'solana-bankrun';
 
 // This is a helper class to assign properties to the class
 class Assignable {
@@ -20,7 +20,6 @@ enum MyInstruction {
 }
 
 class CreateFav extends Assignable {
-
   number: number;
   instruction: MyInstruction;
   color: string;
@@ -31,30 +30,34 @@ class CreateFav extends Assignable {
   }
 
   static fromBuffer(buffer: Buffer): CreateFav {
-    return borsh.deserialize({
-      struct: {
-        number: "u64",
-        color: "string",
-        hobbies: {
-          array: {
-            type: "string"
-          }
-        }
-      }}, buffer) as CreateFav;
+    return borsh.deserialize(
+      {
+        struct: {
+          number: 'u64',
+          color: 'string',
+          hobbies: {
+            array: {
+              type: 'string',
+            },
+          },
+        },
+      },
+      buffer,
+    ) as CreateFav;
   }
 }
 const CreateNewAccountSchema = {
-  "struct": {
-    instruction: "u8",
-    number: "u64",
-    color: "string",
+  struct: {
+    instruction: 'u8',
+    number: 'u64',
+    color: 'string',
     hobbies: {
       array: {
-        type: "string"
-      }
-    }
-  }
-}
+        type: 'string',
+      },
+    },
+  },
+};
 
 class GetFav extends Assignable {
   toBuffer() {
@@ -62,35 +65,39 @@ class GetFav extends Assignable {
   }
 }
 const GetFavSchema = {
-  "struct": {
-    instruction: "u8"
-  }
-}
+  struct: {
+    instruction: 'u8',
+  },
+};
+
+describe('Favorites Solana Native', () => {
+  // Randomly generate the program keypair and load the program to solana-bankrun
+  const programId = PublicKey.unique();
+
+  let context: ProgramTestContext;
+  let client: BanksClient;
+  let payer: Keypair;
+  let blockhash: Blockhash;
+
+  beforeEach(async () => {
+    context = await start([{ name: 'favorites_native', programId }], []);
+    client = context.banksClient;
+    // Get the payer keypair from the context, this will be used to sign transactions with enough lamports
+    payer = context.payer;
+    blockhash = context.lastBlockhash;
+  });
 
-describe('Favorites Solana Native',  () => {
-  
-// Randomly generate the program keypair and load the program to solana-bankrun
-const programId = PublicKey.unique();
-
-let context: ProgramTestContext, client:BanksClient, payer: Keypair, blockhash: Blockhash; 
-beforeEach(async () => {
-  context = await start([{ name: 'favorites_native', programId }], []);
-  client = context.banksClient;
-  // Get the payer keypair from the context, this will be used to sign transactions with enough lamports
-  payer = context.payer;
-  blockhash = context.lastBlockhash;
-})
-  
-test('Set the favorite pda and cross-check the updated data', async () => {
-    const favoritesPda = PublicKey.findProgramAddressSync([Buffer.from("favorite"), payer.publicKey.toBuffer()], programId)[0];
-    const favData = {instruction: MyInstruction.CreateFav, number: 42, color: "blue", hobbies: ["coding", "reading", "traveling"]}
+  test('Set the favorite pda and cross-check the updated data', async () => {
+    const favoritesPda = PublicKey.findProgramAddressSync([Buffer.from('favorite'), payer.publicKey.toBuffer()], programId)[0];
+    const favData = { instruction: MyInstruction.CreateFav, number: 42, color: 'blue', hobbies: ['coding', 'reading', 'traveling'] };
     const favorites = new CreateFav(favData);
 
     const ix = new TransactionInstruction({
       keys: [
-        {pubkey: payer.publicKey, isSigner: true, isWritable: true}, 
-        {pubkey: favoritesPda, isSigner: false, isWritable: true}, 
-        {pubkey: SystemProgram.programId, isSigner: false, isWritable: false}],
+        { pubkey: payer.publicKey, isSigner: true, isWritable: true },
+        { pubkey: favoritesPda, isSigner: false, isWritable: true },
+        { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
+      ],
       programId,
       data: favorites.toBuffer(),
     });
@@ -98,8 +105,8 @@ test('Set the favorite pda and cross-check the updated data', async () => {
     const tx = new Transaction().add(ix);
 
     tx.feePayer = payer.publicKey;
-    tx.recentBlockhash = blockhash
-    tx.sign(payer)
+    tx.recentBlockhash = blockhash;
+    tx.sign(payer);
     tx.recentBlockhash = blockhash;
     await client.processTransaction(tx);
 
@@ -108,21 +115,25 @@ test('Set the favorite pda and cross-check the updated data', async () => {
 
     const favoritesData = CreateFav.fromBuffer(data);
 
-    console.log("Deserialized data:", favoritesData);
+    console.log('Deserialized data:', favoritesData);
 
     expect(new BN(favoritesData.number as any, 'le').toNumber()).to.equal(favData.number);
     expect(favoritesData.color).to.equal(favData.color);
     expect(favoritesData.hobbies).to.deep.equal(favData.hobbies);
   });
 
-  test('Check if the test fails if the pda seeds aren\'t same', async () => {
+  test("Check if the test fails if the pda seeds aren't same", async () => {
     // We put the wrong seeds knowingly to see if the test fails because of checks
-    const favoritesPda = PublicKey.findProgramAddressSync([Buffer.from("favorite"), payer.publicKey.toBuffer()], programId)[0];
-    const favData = {instruction: MyInstruction.CreateFav, number: 42, color: "blue", hobbies: ["coding", "reading", "traveling"]}
+    const favoritesPda = PublicKey.findProgramAddressSync([Buffer.from('favorite'), payer.publicKey.toBuffer()], programId)[0];
+    const favData = { instruction: MyInstruction.CreateFav, number: 42, color: 'blue', hobbies: ['coding', 'reading', 'traveling'] };
     const favorites = new CreateFav(favData);
 
     const ix = new TransactionInstruction({
-      keys: [{pubkey: payer.publicKey, isSigner: true, isWritable: true}, {pubkey: favoritesPda, isSigner: false, isWritable: true}, {pubkey: SystemProgram.programId, isSigner: false, isWritable: false}],
+      keys: [
+        { pubkey: payer.publicKey, isSigner: true, isWritable: true },
+        { pubkey: favoritesPda, isSigner: false, isWritable: true },
+        { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
+      ],
       programId,
       data: favorites.toBuffer(),
     });
@@ -130,57 +141,60 @@ test('Set the favorite pda and cross-check the updated data', async () => {
     const tx = new Transaction().add(ix);
 
     tx.feePayer = payer.publicKey;
-    tx.recentBlockhash = blockhash
-    tx.sign(payer)
+    tx.recentBlockhash = blockhash;
+    tx.sign(payer);
     tx.recentBlockhash = blockhash;
     try {
-      await client.processTransaction(tx)
-      console.error("Expected the test to fail")
-    } catch(err) {
-      assert(true)
+      await client.processTransaction(tx);
+      console.error('Expected the test to fail');
+    } catch (err) {
+      assert(true);
     }
   });
 
   test('Get the favorite pda and cross-check the data', async () => {
     // Creating a new account with payer's pubkey
-    const favoritesPda = PublicKey.findProgramAddressSync([Buffer.from("favorite"), payer.publicKey.toBuffer()], programId)[0];
-    const favData = {instruction: MyInstruction.CreateFav, number: 42, color: "hazel", hobbies: ["singing", "dancing", "skydiving"]}
+    const favoritesPda = PublicKey.findProgramAddressSync([Buffer.from('favorite'), payer.publicKey.toBuffer()], programId)[0];
+    const favData = { instruction: MyInstruction.CreateFav, number: 42, color: 'hazel', hobbies: ['singing', 'dancing', 'skydiving'] };
     const favorites = new CreateFav(favData);
-    
+
     const ix = new TransactionInstruction({
       keys: [
-        {pubkey: payer.publicKey, isSigner: true, isWritable: true}, 
-        {pubkey: favoritesPda, isSigner: false, isWritable: true}, 
-        {pubkey: SystemProgram.programId, isSigner: false, isWritable: false}],
+        { pubkey: payer.publicKey, isSigner: true, isWritable: true },
+        { pubkey: favoritesPda, isSigner: false, isWritable: true },
+        { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
+      ],
       programId,
       data: favorites.toBuffer(),
     });
 
     const tx1 = new Transaction().add(ix);
-    
+
     tx1.feePayer = payer.publicKey;
-    tx1.recentBlockhash = blockhash
-    tx1.sign(payer)
     tx1.recentBlockhash = blockhash;
-    await client.processTransaction(tx1)
-
+    tx1.sign(payer);
+    tx1.recentBlockhash = blockhash;
+    await client.processTransaction(tx1);
 
     // Getting the user's data through the get_pda instruction
-    const getfavData = {instruction: MyInstruction.GetFav}
+    const getfavData = { instruction: MyInstruction.GetFav };
     const getfavorites = new GetFav(getfavData);
-    
+
     const ix2 = new TransactionInstruction({
-      keys: [{pubkey: payer.publicKey, isSigner: true, isWritable: true}, {pubkey: favoritesPda, isSigner: false, isWritable: false}],
+      keys: [
+        { pubkey: payer.publicKey, isSigner: true, isWritable: true },
+        { pubkey: favoritesPda, isSigner: false, isWritable: false },
+      ],
       programId,
-      data:getfavorites.toBuffer(),
-    }); 
+      data: getfavorites.toBuffer(),
+    });
 
     const tx = new Transaction().add(ix2);
 
     tx.feePayer = payer.publicKey;
-    tx.recentBlockhash = blockhash
-    tx.sign(payer)
+    tx.recentBlockhash = blockhash;
+    tx.sign(payer);
     tx.recentBlockhash = blockhash;
     await client.processTransaction(tx);
-  })
-})
+  });
+});

+ 2 - 2
basics/hello-solana/poseidon/hello-solana/migrations/deploy.ts

@@ -2,9 +2,9 @@
 // single deploy script that's invoked from the CLI, injecting a provider
 // configured from the workspace's Anchor.toml.
 
-const anchor = require("@coral-xyz/anchor");
+const anchor = require('@coral-xyz/anchor');
 
-module.exports = async function (provider) {
+module.exports = async (provider) => {
   // Configure client to use the provider.
   anchor.setProvider(provider);
 

+ 20 - 20
basics/hello-solana/poseidon/hello-solana/package.json

@@ -1,22 +1,22 @@
 {
-    "scripts": {
-        "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
-        "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
-    },
-    "dependencies": {
-        "@coral-xyz/anchor": "^0.29.0",
-        "@solanaturbine/poseidon": "^0.0.4",
-        "anchor-bankrun": "^0.5.0",
-        "solana-bankrun": "^0.4.0"
-    },
-    "devDependencies": {
-        "@types/bn.js": "^5.1.0",
-        "@types/chai": "^4.3.0",
-        "@types/mocha": "^9.0.0",
-        "chai": "^4.3.4",
-        "mocha": "^9.0.3",
-        "prettier": "^2.6.2",
-        "ts-mocha": "^10.0.0",
-        "typescript": "^4.3.5"
-    }
+  "scripts": {
+    "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
+    "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
+  },
+  "dependencies": {
+    "@coral-xyz/anchor": "^0.29.0",
+    "@solanaturbine/poseidon": "^0.0.4",
+    "anchor-bankrun": "^0.5.0",
+    "solana-bankrun": "^0.4.0"
+  },
+  "devDependencies": {
+    "@types/bn.js": "^5.1.0",
+    "@types/chai": "^4.3.0",
+    "@types/mocha": "^9.0.0",
+    "chai": "^4.3.4",
+    "mocha": "^9.0.3",
+    "prettier": "^2.6.2",
+    "ts-mocha": "^10.0.0",
+    "typescript": "^4.3.5"
+  }
 }

+ 11 - 19
basics/hello-solana/poseidon/hello-solana/tests/bankrun.test.ts

@@ -1,32 +1,24 @@
-import * as anchor from "@coral-xyz/anchor";
-import { PublicKey } from "@solana/web3.js";
-import { BankrunProvider } from "anchor-bankrun";
-import { assert } from "chai";
-import { startAnchor } from "solana-bankrun";
-import { HelloSolanaProgram } from "../target/types/hello_solana_program"; // Assuming this path
+import * as anchor from '@coral-xyz/anchor';
+import { PublicKey } from '@solana/web3.js';
+import { BankrunProvider } from 'anchor-bankrun';
+import { assert } from 'chai';
+import { startAnchor } from 'solana-bankrun';
+import { HelloSolanaProgram } from '../target/types/hello_solana_program'; // Assuming this path
 
-const IDL = require("../target/idl/hello_solana_program.json");
+const IDL = require('../target/idl/hello_solana_program.json');
 const PROGRAM_ID = new PublicKey(IDL.metadata.address);
 
-describe("hello_solana_program (Bankrun)", async () => {
-  const context = await startAnchor(
-    "",
-    [{ name: "hello_solana_program", programId: PROGRAM_ID }],
-    []
-  );
+describe('hello_solana_program (Bankrun)', async () => {
+  const context = await startAnchor('', [{ name: 'hello_solana_program', programId: PROGRAM_ID }], []);
 
   const provider = new BankrunProvider(context);
 
-  const program = new anchor.Program<HelloSolanaProgram>(
-    IDL,
-    PROGRAM_ID,
-    provider
-  );
+  const program = new anchor.Program<HelloSolanaProgram>(IDL, PROGRAM_ID, provider);
 
   it("Executes 'hello' successfully", async () => {
     const tx = await program.methods.hello().rpc();
 
     // Chai assert to ensure no error occurred and transaction completed successfully
-    assert.isOk(tx, "Transaction should complete without errors");
+    assert.isOk(tx, 'Transaction should complete without errors');
   });
 });

+ 7 - 8
basics/hello-solana/poseidon/hello-solana/tests/test.ts

@@ -1,20 +1,19 @@
-import * as anchor from "@coral-xyz/anchor";
-import { Program } from "@coral-xyz/anchor";
-import { assert } from "chai";
-import { HelloSolanaProgram } from "../target/types/hello_solana_program"; // Assuming this path
+import * as anchor from '@coral-xyz/anchor';
+import { Program } from '@coral-xyz/anchor';
+import { assert } from 'chai';
+import { HelloSolanaProgram } from '../target/types/hello_solana_program'; // Assuming this path
 
-describe("hello_solana_program", () => {
+describe('hello_solana_program', () => {
   // Configure the client to use the local cluster.
   const provider = anchor.AnchorProvider.env();
   anchor.setProvider(provider);
 
-  const program = anchor.workspace
-    .HelloSolanaProgram as Program<HelloSolanaProgram>;
+  const program = anchor.workspace.HelloSolanaProgram as Program<HelloSolanaProgram>;
 
   it("Executes 'hello' successfully", async () => {
     const tx = await program.methods.hello().rpc();
 
     // Chai assert to ensure no error occurred and transaction completed successfully
-    assert.isOk(tx, "Transaction should complete without errors");
+    assert.isOk(tx, 'Transaction should complete without errors');
   });
 });

+ 3 - 5
basics/hello-solana/poseidon/hello-solana/ts-programs/src/hello-solana.ts

@@ -1,12 +1,10 @@
-import { Pubkey, Result } from "@solanaturbine/poseidon";
+import { Pubkey, Result } from '@solanaturbine/poseidon';
 
 export default class HelloSolanaProgram {
-  static PROGRAM_ID = new Pubkey(
-    "2phbC62wekpw95XuBk4i1KX4uA8zBUWmYbiTMhicSuBV"
-  );
+  static PROGRAM_ID = new Pubkey('2phbC62wekpw95XuBk4i1KX4uA8zBUWmYbiTMhicSuBV');
 
   hello(): Result {
-    console.log("Hello, Solana!");
+    console.log('Hello, Solana!');
 
     console.log(`Our program's Program ID: ${HelloSolanaProgram.PROGRAM_ID}`);
   }

+ 9 - 10
basics/hello-solana/poseidon/hello-solana/tsconfig.json

@@ -1,11 +1,10 @@
 {
-            "compilerOptions": {
-              "types": ["mocha", "chai"],
-              "typeRoots": ["./node_modules/@types"],
-              "lib": ["es2015"],
-              "module": "commonjs",
-              "target": "es6",
-              "esModuleInterop": true
-            }
-          }
-          
+  "compilerOptions": {
+    "types": ["mocha", "chai"],
+    "typeRoots": ["./node_modules/@types"],
+    "lib": ["es2015"],
+    "module": "commonjs",
+    "target": "es6",
+    "esModuleInterop": true
+  }
+}

+ 11 - 20
basics/transfer-sol/poseidon/tests/transferSol.ts

@@ -1,8 +1,8 @@
-import * as anchor from "@coral-xyz/anchor";
-import { Program } from "@coral-xyz/anchor";
-import { TransferSol } from "../target/types/transfer_sol";
-import { Keypair, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";
-describe("transfer-sol", () => {
+import * as anchor from '@coral-xyz/anchor';
+import { Program } from '@coral-xyz/anchor';
+import { Keypair, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js';
+import { TransferSol } from '../target/types/transfer_sol';
+describe('transfer-sol', () => {
   // Configure the client to use the local cluster.
   const provider = anchor.AnchorProvider.env();
   anchor.setProvider(provider);
@@ -15,18 +15,15 @@ describe("transfer-sol", () => {
   before(async () => {
     const latestBlockHash = await provider.connection.getLatestBlockhash();
     // Airdrop 5 SOL to the user that will send SOL to the other user
-    const airdropUser = await provider.connection.requestAirdrop(
-      user.publicKey,
-      5 * LAMPORTS_PER_SOL
-    );
+    const airdropUser = await provider.connection.requestAirdrop(user.publicKey, 5 * LAMPORTS_PER_SOL);
     await provider.connection.confirmTransaction({
       blockhash: latestBlockHash.blockhash,
       lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
       signature: airdropUser,
     });
   });
-  it("Transfer SOL with CPI", async () => {
-    await getBalances(user.publicKey, receiver.publicKey, "\n Beginning");
+  it('Transfer SOL with CPI', async () => {
+    await getBalances(user.publicKey, receiver.publicKey, '\n Beginning');
     // Transfer SOL instruction invoked from the program
     await program.methods
       .transferSolWithCpi(new anchor.BN(transferAmount))
@@ -36,18 +33,12 @@ describe("transfer-sol", () => {
       })
       .signers([user])
       .rpc();
-    await getBalances(user.publicKey, receiver.publicKey, "\n Resulting");
+    await getBalances(user.publicKey, receiver.publicKey, '\n Resulting');
   });
   // Helper function to display balance of the accounts
-  async function getBalances(
-    payerPubkey: PublicKey,
-    recipientPubkey: PublicKey,
-    timeframe: string
-  ) {
+  async function getBalances(payerPubkey: PublicKey, recipientPubkey: PublicKey, timeframe: string) {
     const payerBalance = await provider.connection.getBalance(payerPubkey);
-    const recipientBalance = await provider.connection.getBalance(
-      recipientPubkey
-    );
+    const recipientBalance = await provider.connection.getBalance(recipientPubkey);
     console.log(`${timeframe} balances:`);
     console.log(`   Payer: ${payerBalance / LAMPORTS_PER_SOL}`);
     console.log(`   Recipient: ${recipientBalance / LAMPORTS_PER_SOL}`);

+ 3 - 12
basics/transfer-sol/poseidon/ts-programs/src/transferSol.ts

@@ -1,22 +1,13 @@
-import {
-  Pubkey,
-  SystemAccount,
-  Signer,
-  SystemProgram,
-  u64,
-  type Result,
-} from "@solanaturbine/poseidon";
+import { Pubkey, type Result, Signer, SystemAccount, SystemProgram, u64 } from '@solanaturbine/poseidon';
 
 export default class TransferSol {
-  static PROGRAM_ID = new Pubkey(
-    "BLiyCbPDx54vqpNPQG6A7YAqEM1vRHiFfvReMKC4FFk5"
-  );
+  static PROGRAM_ID = new Pubkey('BLiyCbPDx54vqpNPQG6A7YAqEM1vRHiFfvReMKC4FFk5');
 
   // Transferring of SOL using CPI
   transferSolWithCPI(
     payer: Signer, // sender of the SOL
     recipient: SystemAccount, // receiver of transferred SOL
-    amount: u64 // amount to be transferred
+    amount: u64, // amount to be transferred
   ): Result {
     // Invoke the SystemProgram's Transfer instruction
     // Parameters: from, to, amount

+ 2 - 2
tokens/escrow/poseidon/escrow/migrations/deploy.ts

@@ -2,9 +2,9 @@
 // single deploy script that's invoked from the CLI, injecting a provider
 // configured from the workspace's Anchor.toml.
 
-const anchor = require("@coral-xyz/anchor");
+const anchor = require('@coral-xyz/anchor');
 
-module.exports = async function (provider) {
+module.exports = async (provider) => {
   // Configure client to use the provider.
   anchor.setProvider(provider);
 

+ 20 - 20
tokens/escrow/poseidon/escrow/package.json

@@ -1,22 +1,22 @@
 {
-    "scripts": {
-        "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
-        "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
-    },
-    "dependencies": {
-        "@coral-xyz/anchor": "^0.29.0",
-        "@solanaturbine/poseidon": "^0.0.4",
-        "anchor-bankrun": "^0.5.0",
-        "solana-bankrun": "^0.4.0"
-    },
-    "devDependencies": {
-        "@types/bn.js": "^5.1.0",
-        "@types/chai": "^4.3.0",
-        "@types/mocha": "^9.0.0",
-        "chai": "^4.3.4",
-        "mocha": "^9.0.3",
-        "prettier": "^2.6.2",
-        "ts-mocha": "^10.0.0",
-        "typescript": "^4.3.5"
-    }
+  "scripts": {
+    "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
+    "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
+  },
+  "dependencies": {
+    "@coral-xyz/anchor": "^0.29.0",
+    "@solanaturbine/poseidon": "^0.0.4",
+    "anchor-bankrun": "^0.5.0",
+    "solana-bankrun": "^0.4.0"
+  },
+  "devDependencies": {
+    "@types/bn.js": "^5.1.0",
+    "@types/chai": "^4.3.0",
+    "@types/mocha": "^9.0.0",
+    "chai": "^4.3.4",
+    "mocha": "^9.0.3",
+    "prettier": "^2.6.2",
+    "ts-mocha": "^10.0.0",
+    "typescript": "^4.3.5"
+  }
 }

+ 20 - 24
tokens/escrow/poseidon/escrow/tests/bankrun.test.ts

@@ -1,19 +1,16 @@
-import * as anchor from "@coral-xyz/anchor";
-import { PublicKey, Keypair, SystemProgram } from "@solana/web3.js";
-import { BankrunProvider } from "anchor-bankrun";
-import { assert } from "chai";
-import { startAnchor } from "solana-bankrun";
-import { EscrowProgram } from "../target/types/escrow_program";
+import { describe, it } from 'node:test';
+import * as anchor from '@coral-xyz/anchor';
+import { Keypair, PublicKey, SystemProgram } from '@solana/web3.js';
+import { BankrunProvider } from 'anchor-bankrun';
+import { assert } from 'chai';
+import { startAnchor } from 'solana-bankrun';
+import { EscrowProgram } from '../target/types/escrow_program';
 
-const IDL = require("../target/idl/escrow_program.json");
+const IDL = require('../target/idl/escrow_program.json');
 const PROGRAM_ID = new PublicKey(IDL.address);
 
-describe("escrow_program (Bankrun)", async () => {
-  const context = await startAnchor(
-    "",
-    [{ name: "escrow_program", programId: PROGRAM_ID }],
-    []
-  );
+describe('escrow_program (Bankrun)', async () => {
+  const context = await startAnchor('', [{ name: 'escrow_program', programId: PROGRAM_ID }], []);
   const provider = new BankrunProvider(context);
 
   const payer = provider.wallet as anchor.Wallet;
@@ -25,9 +22,12 @@ describe("escrow_program (Bankrun)", async () => {
   const escrowKeypair = new Keypair();
 
   const mint = new Keypair(); // Mint account for SPL tokens
-  let makerATA, takerATA, escrowVault, escrowState;
+  let makerATA: PublicKey;
+  let takerATA: PublicKey;
+  let escrowVault: PublicKey;
+  let escrowState: anchor.IdlAccounts<EscrowProgram>['escrowState'] | null;
 
-  it("Make Escrow", async () => {
+  it('Make Escrow', async () => {
     await program.methods
       .make(new anchor.BN(100), new anchor.BN(50), new anchor.BN(12345)) // deposit_amount, offer_amount, seed
       .accounts({
@@ -46,14 +46,12 @@ describe("escrow_program (Bankrun)", async () => {
       .rpc();
 
     // Fetch and verify the state of the escrow
-    escrowState = await program.account.escrowState.fetch(
-      escrowKeypair.publicKey
-    );
+    escrowState = await program.account.escrowState.fetch(escrowKeypair.publicKey);
     assert.equal(escrowState.maker.toString(), maker.publicKey.toString());
     assert.equal(escrowState.amount.toNumber(), 50);
   });
 
-  it("Refund Escrow", async () => {
+  it('Refund Escrow', async () => {
     await program.methods
       .refund()
       .accounts({
@@ -68,13 +66,11 @@ describe("escrow_program (Bankrun)", async () => {
       .rpc();
 
     // Assert that escrow is closed or funds refunded
-    escrowState = await program.account.escrowState
-      .fetch(escrowKeypair.publicKey)
-      .catch(() => null);
-    assert.isNull(escrowState, "Escrow state should be closed after refund");
+    escrowState = await program.account.escrowState.fetch(escrowKeypair.publicKey).catch(() => null);
+    assert.isNull(escrowState, 'Escrow state should be closed after refund');
   });
 
-  it("Take Escrow", async () => {
+  it('Take Escrow', async () => {
     await program.methods
       .take()
       .accounts({

+ 14 - 22
tokens/escrow/poseidon/escrow/tests/escrow.ts

@@ -1,10 +1,10 @@
-import * as anchor from "@coral-xyz/anchor";
-import { Program } from "@coral-xyz/anchor";
-import { assert } from "chai";
-import { PublicKey, SystemProgram } from "@solana/web3.js";
-import { EscrowProgram } from "../target/types/escrow_program";
+import * as anchor from '@coral-xyz/anchor';
+import { Program } from '@coral-xyz/anchor';
+import { PublicKey, SystemProgram } from '@solana/web3.js';
+import { assert } from 'chai';
+import { EscrowProgram } from '../target/types/escrow_program';
 
-describe("escrow_program", () => {
+describe('escrow_program', () => {
   // Configure the client to use the local cluster.
   const provider = anchor.AnchorProvider.env();
   anchor.setProvider(provider);
@@ -15,7 +15,7 @@ describe("escrow_program", () => {
   let vaultAccount: PublicKey;
   let escrowAccount: PublicKey;
 
-  it("Creates a new escrow", async () => {
+  it('Creates a new escrow', async () => {
     // Generate a keypair for escrow
     escrowAccount = anchor.web3.Keypair.generate().publicKey;
 
@@ -43,19 +43,11 @@ describe("escrow_program", () => {
 
     // Assert escrow account was created
     const escrowState = await program.account.escrowState.fetch(escrowAccount);
-    assert.equal(
-      escrowState.amount.toString(),
-      offerAmount.toString(),
-      "Escrow amount is incorrect"
-    );
-    assert.equal(
-      escrowState.seed.toString(),
-      seed.toString(),
-      "Escrow seed is incorrect"
-    );
+    assert.equal(escrowState.amount.toString(), offerAmount.toString(), 'Escrow amount is incorrect');
+    assert.equal(escrowState.seed.toString(), seed.toString(), 'Escrow seed is incorrect');
   });
 
-  it("Refunds from the vault", async () => {
+  it('Refunds from the vault', async () => {
     await program.methods
       .refund()
       .accounts({
@@ -73,13 +65,13 @@ describe("escrow_program", () => {
     // Assert that the escrow account was closed
     try {
       await program.account.escrowState.fetch(escrowAccount);
-      assert.fail("Escrow account should be closed");
+      assert.fail('Escrow account should be closed');
     } catch (err) {
-      assert.ok("Escrow account was closed");
+      assert.ok('Escrow account was closed');
     }
   });
 
-  it("Transfers tokens to taker", async () => {
+  it('Transfers tokens to taker', async () => {
     const taker = anchor.web3.Keypair.generate();
     const takerAta = anchor.web3.Keypair.generate();
     const takerReceiveAta = anchor.web3.Keypair.generate();
@@ -102,6 +94,6 @@ describe("escrow_program", () => {
 
     // Assert the transfer occurred
     const escrowState = await program.account.escrowState.fetch(escrowAccount);
-    assert.isNotNull(escrowState, "Escrow state should be updated");
+    assert.isNotNull(escrowState, 'Escrow state should be updated');
   });
 });

+ 18 - 31
tokens/escrow/poseidon/escrow/ts-programs/src/escrow.ts

@@ -9,12 +9,12 @@ import {
   TokenAccount,
   TokenProgram,
   UncheckedAccount,
-  u64,
   u8,
-} from "@solanaturbine/poseidon";
+  u64,
+} from '@solanaturbine/poseidon';
 
 export default class EscrowProgram {
-  static PROGRAM_ID = new Pubkey("11111111111111111111111111111111");
+  static PROGRAM_ID = new Pubkey('11111111111111111111111111111111');
 
   make(
     maker: Signer,
@@ -26,18 +26,18 @@ export default class EscrowProgram {
     vault: TokenAccount,
     depositAmount: u64,
     offerAmount: u64,
-    seed: u64
+    seed: u64,
   ) {
     makerAta.derive(makerMint, maker.key);
 
-    auth.derive(["auth"]);
+    auth.derive(['auth']);
 
     // Here like we mentioned in counter we are deriving a PDA for TokenAccount
     // <TokenAccount>.derive([...], <mint of the token acc>, <authority of the token acc>)
-    vault.derive(["vault", escrow.key], makerMint, auth.key).init();
+    vault.derive(['vault', escrow.key], makerMint, auth.key).init();
 
     // here we can see that we are deriving using seed(u64), so we would do change it to bytes by <arg>.toBytes() which makes it consumable for derive
-    escrow.derive(["escrow", maker.key, seed.toBytes()]).init();
+    escrow.derive(['escrow', maker.key, seed.toBytes()]).init();
 
     escrow.authBump = auth.getBump();
     escrow.vaultBump = vault.getBump();
@@ -53,33 +53,20 @@ export default class EscrowProgram {
       makerAta, // from
       vault, // to
       maker, // authority
-      depositAmount // amount to transfered
+      depositAmount, // amount to transfered
     );
   }
 
-  refund(
-    maker: Signer,
-    makerAta: AssociatedTokenAccount,
-    makerMint: Mint,
-    auth: UncheckedAccount,
-    vault: TokenAccount,
-    escrow: EscrowState
-  ) {
+  refund(maker: Signer, makerAta: AssociatedTokenAccount, makerMint: Mint, auth: UncheckedAccount, vault: TokenAccount, escrow: EscrowState) {
     makerAta.derive(makerMint, maker.key);
-    escrow
-      .derive(["escrow", maker.key, escrow.seed.toBytes()])
-      .has([maker])
-      .close(maker);
+    escrow.derive(['escrow', maker.key, escrow.seed.toBytes()]).has([maker]).close(maker);
 
-    auth.derive(["auth"]);
+    auth.derive(['auth']);
 
-    vault.derive(["vault", escrow.key], makerMint, auth.key);
+    vault.derive(['vault', escrow.key], makerMint, auth.key);
 
     // similar to system program transfer, we are using seeds as the last arguement as we are tranfering from a PDA
-    TokenProgram.transfer(vault, makerAta, auth, escrow.amount, [
-      "auth",
-      escrow.authBump.toBytes(),
-    ]);
+    TokenProgram.transfer(vault, makerAta, auth, escrow.amount, ['auth', escrow.authBump.toBytes()]);
   }
 
   take(
@@ -92,7 +79,7 @@ export default class EscrowProgram {
     takerMint: Mint,
     auth: UncheckedAccount,
     vault: TokenAccount,
-    escrow: EscrowState
+    escrow: EscrowState,
   ) {
     // for AssociatedTokenAccount(takerAta) since its associated with a pubkey there is no need to pass the seeds list. we can just pass the mint and authority
     // <AssociatedTokenAccount>.derive(<mint of the token acc>, <authority of the token acc>)
@@ -103,17 +90,17 @@ export default class EscrowProgram {
     makerAta.derive(makerMint, maker.key);
 
     escrow
-      .derive(["escrow", maker.key, escrow.seed.toBytes()])
+      .derive(['escrow', maker.key, escrow.seed.toBytes()])
       .has([maker, makerMint, takerMint]) // has method makes sure that all the pubkeys in the list which is the Custom_Acc(escrow) holds is same as Acc's pubkey in the function(in this case `take`) arguements
       .close(maker);
 
-    auth.derive(["auth"]);
+    auth.derive(['auth']);
 
-    vault.derive(["vault", escrow.key], makerMint, auth.key);
+    vault.derive(['vault', escrow.key], makerMint, auth.key);
 
     TokenProgram.transfer(takerAta, makerAta, taker, escrow.amount);
 
-    let seeds: Seeds = ["auth", escrow.authBump.toBytes()];
+    const seeds: Seeds = ['auth', escrow.authBump.toBytes()];
 
     TokenProgram.transfer(vault, takerReceiveAta, auth, escrow.amount, seeds);
   }

+ 9 - 10
tokens/escrow/poseidon/escrow/tsconfig.json

@@ -1,11 +1,10 @@
 {
-            "compilerOptions": {
-              "types": ["mocha", "chai"],
-              "typeRoots": ["./node_modules/@types"],
-              "lib": ["es2015"],
-              "module": "commonjs",
-              "target": "es6",
-              "esModuleInterop": true
-            }
-          }
-          
+  "compilerOptions": {
+    "types": ["mocha", "chai"],
+    "typeRoots": ["./node_modules/@types"],
+    "lib": ["es2015"],
+    "module": "commonjs",
+    "target": "es6",
+    "esModuleInterop": true
+  }
+}

+ 6 - 6
tokens/escrow/steel/tests/bankrun.test.ts

@@ -1,8 +1,8 @@
-import { PublicKey, Keypair, SystemProgram, Transaction, TransactionInstruction, LAMPORTS_PER_SOL } from '@solana/web3.js';
-import { ProgramTestContext, BanksClient, start } from 'solana-bankrun';
-import { createAMint, deserializeOfferAccount, encodeBigint, getMakeOfferInstructionData, getTakeOfferInstructionData, mintTo } from './utils';
-import { AccountLayout, ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID } from '@solana/spl-token';
+import { ASSOCIATED_TOKEN_PROGRAM_ID, AccountLayout, TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync } from '@solana/spl-token';
+import { Keypair, LAMPORTS_PER_SOL, PublicKey, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js';
 import { assert } from 'chai';
+import { BanksClient, ProgramTestContext, start } from 'solana-bankrun';
+import { createAMint, deserializeOfferAccount, encodeBigint, getMakeOfferInstructionData, getTakeOfferInstructionData, mintTo } from './utils';
 
 const PROGRAM_ID = new PublicKey('z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35');
 
@@ -10,8 +10,8 @@ describe('Escrow Program', () => {
   let context: ProgramTestContext;
   let client: BanksClient;
   let payer: Keypair;
-  let maker = Keypair.generate();
-  let taker = Keypair.generate();
+  const maker = Keypair.generate();
+  const taker = Keypair.generate();
 
   const mint_a = Keypair.generate();
   const mint_b = Keypair.generate();

+ 4 - 4
tokens/escrow/steel/tests/utils.ts

@@ -1,14 +1,14 @@
 import {
   MINT_SIZE,
   TOKEN_PROGRAM_ID,
-  createInitializeMint2Instruction,
-  getAssociatedTokenAddressSync,
   createAssociatedTokenAccountInstruction,
+  createInitializeMint2Instruction,
   createMintToInstruction,
+  getAssociatedTokenAddressSync,
 } from '@solana/spl-token';
-import { Keypair, Transaction, SystemProgram, PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js';
-import { ProgramTestContext } from 'solana-bankrun';
+import { Keypair, LAMPORTS_PER_SOL, PublicKey, SystemProgram, Transaction } from '@solana/web3.js';
 import * as borsh from 'borsh';
+import { ProgramTestContext } from 'solana-bankrun';
 
 export const instructionDiscriminators = {
   MakeOffer: Buffer.from([0]),

+ 1 - 1
tokens/external-delegate-token-master/anchor/package.json

@@ -31,4 +31,4 @@
     "typescript": "^4.9.5",
     "@testing-library/jest-dom": "^6.1.6"
   }
-}
+}

+ 16 - 20
tokens/external-delegate-token-master/anchor/tests/external-delegate-token-master.test.ts

@@ -1,7 +1,7 @@
-import { start } from 'solana-bankrun';
-import { expect } from 'chai';
-import { PublicKey, SystemProgram, Keypair, Connection } from '@solana/web3.js';
 import { TOKEN_PROGRAM_ID, createMint, getOrCreateAssociatedTokenAccount, mintTo } from '@solana/spl-token';
+import { Connection, Keypair, PublicKey, SystemProgram } from '@solana/web3.js';
+import { expect } from 'chai';
+import { start } from 'solana-bankrun';
 
 jest.setTimeout(30000); // Set timeout to 30 seconds
 
@@ -12,7 +12,7 @@ async function retryWithBackoff(fn: () => Promise<any>, retries = 5, delay = 500
     return await fn();
   } catch (err) {
     if (retries === 0) throw err;
-    await new Promise(resolve => setTimeout(resolve, delay));
+    await new Promise((resolve) => setTimeout(resolve, delay));
     return retryWithBackoff(fn, retries - 1, delay * 2);
   }
 }
@@ -34,15 +34,15 @@ describe('External Delegate Token Master Tests', () => {
 
     const programs = [
       {
-        name: "external_delegate_token_master",
-        programId: new PublicKey("FYPkt5VWMvtyWZDMGCwoKFkE3wXTzphicTpnNGuHWVbD"),
-        program: "target/deploy/external_delegate_token_master.so",
+        name: 'external_delegate_token_master',
+        programId: new PublicKey('FYPkt5VWMvtyWZDMGCwoKFkE3wXTzphicTpnNGuHWVbD'),
+        program: 'target/deploy/external_delegate_token_master.so',
       },
     ];
 
     context = await retryWithBackoff(async () => await start(programs, []));
 
-    const connection = new Connection("https://api.devnet.solana.com", "confirmed");
+    const connection = new Connection('https://api.devnet.solana.com', 'confirmed');
     context.connection = connection;
 
     // Airdrop SOL to authority with retry logic
@@ -51,28 +51,24 @@ describe('External Delegate Token Master Tests', () => {
     });
 
     // Create mint with retry logic
-    mint = await retryWithBackoff(async () =>
-      await createMint(connection, authority, authority.publicKey, null, 6)
-    );
+    mint = await retryWithBackoff(async () => await createMint(connection, authority, authority.publicKey, null, 6));
 
-    const userTokenAccountInfo = await retryWithBackoff(async () =>
-      await getOrCreateAssociatedTokenAccount(connection, authority, mint, authority.publicKey)
+    const userTokenAccountInfo = await retryWithBackoff(
+      async () => await getOrCreateAssociatedTokenAccount(connection, authority, mint, authority.publicKey),
     );
     userTokenAccount = userTokenAccountInfo.address;
 
-    const recipientTokenAccountInfo = await retryWithBackoff(async () =>
-      await getOrCreateAssociatedTokenAccount(connection, authority, mint, Keypair.generate().publicKey)
+    const recipientTokenAccountInfo = await retryWithBackoff(
+      async () => await getOrCreateAssociatedTokenAccount(connection, authority, mint, Keypair.generate().publicKey),
     );
     recipientTokenAccount = recipientTokenAccountInfo.address;
 
     // Mint tokens to the user's account
-    await retryWithBackoff(async () =>
-      await mintTo(connection, authority, mint, userTokenAccount, authority, 1000000000)
-    );
+    await retryWithBackoff(async () => await mintTo(connection, authority, mint, userTokenAccount, authority, 1000000000));
 
     // Find program-derived address (PDA)
-    [userPda, bumpSeed] = await retryWithBackoff(async () =>
-      await PublicKey.findProgramAddress([userAccount.publicKey.toBuffer()], context.program.programId)
+    [userPda, bumpSeed] = await retryWithBackoff(
+      async () => await PublicKey.findProgramAddress([userAccount.publicKey.toBuffer()], context.program.programId),
     );
   });
 

+ 0 - 17
tokens/external-delegate-token-master/anchor/tests/types.js

@@ -1,17 +0,0 @@
-// tests/types.ts
-import { PublicKey } from '@solana/web3.js';
-
-export interface ProgramTestContext {
-    connection: any;
-    programs: {
-        programId: PublicKey;
-        program: string;
-    }[];
-    grantLamports: (address: PublicKey, amount: number) => Promise<void>;
-    terminate: () => Promise<void>;
-}
-
-export interface UserAccount {
-    authority: PublicKey;
-    ethereumAddress: number[];
-}

+ 16 - 0
tokens/external-delegate-token-master/anchor/tests/types.ts

@@ -0,0 +1,16 @@
+import { PublicKey } from '@solana/web3.js';
+
+export interface ProgramTestContext {
+  connection: any;
+  programs: {
+    programId: PublicKey;
+    program: string;
+  }[];
+  grantLamports: (address: PublicKey, amount: number) => Promise<void>;
+  terminate: () => Promise<void>;
+}
+
+export interface UserAccount {
+  authority: PublicKey;
+  ethereumAddress: number[];
+}

+ 7 - 27
tokens/external-delegate-token-master/anchor/tsconfig.json

@@ -1,19 +1,8 @@
 {
   "compilerOptions": {
-    "types": [
-      "jest",
-      "node"
-    ],
-    "typeRoots": [
-      "./node_modules/@types"
-    ],
-    "lib": [
-      "es2015",
-      "dom",
-      "es6",
-      "es2017",
-      "esnext.asynciterable"
-    ],
+    "types": ["jest", "node"],
+    "typeRoots": ["./node_modules/@types"],
+    "lib": ["es2015", "dom", "es6", "es2017", "esnext.asynciterable"],
     "module": "commonjs",
     "target": "es6",
     "esModuleInterop": true,
@@ -30,19 +19,10 @@
     "forceConsistentCasingInFileNames": true,
     "baseUrl": ".",
     "paths": {
-      "@/*": [
-        "src/*"
-      ]
+      "@/*": ["src/*"]
     },
     "outDir": "dist"
   },
-  "include": [
-    "tests/**/*",
-    "programs/**/*",
-    "jest.setup.js",
-    "jest.config.js"
-  ],
-  "exclude": [
-    "node_modules"
-  ]
-}
+  "include": ["tests/**/*", "programs/**/*", "jest.setup.js", "jest.config.js"],
+  "exclude": ["node_modules"]
+}

+ 1 - 1
tokens/spl-token-minter/poseidon/ts-programs/src/splTokenMinter.ts

@@ -13,7 +13,7 @@ import { AssociatedTokenAccount, Mint, Pubkey, type Result, Signer, TokenProgram
 // under "to_account" & "mint_account" under "MintContext"
 
 export default class SplTokenMinter {
-  static PROGRAM_ID = new Pubkey("HFKNWrbYAfKsrWJu88RtUVHgVBNz1uJ6u2tNx1YCmAMZ");
+  static PROGRAM_ID = new Pubkey('HFKNWrbYAfKsrWJu88RtUVHgVBNz1uJ6u2tNx1YCmAMZ');
 
   createToken(mint: Mint, decimals: u8, payer: Signer, freezeAuthority: Pubkey): Result {
     mint.initIfNeeded();

+ 2 - 2
tokens/token-swap/steel/tests/create_pool_and_swap.test.ts

@@ -1,5 +1,5 @@
-import { Connection, Keypair, PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js';
-import { AccountLayout, ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, MintLayout, TOKEN_PROGRAM_ID } from '@solana/spl-token';
+import { ASSOCIATED_TOKEN_PROGRAM_ID, AccountLayout, MintLayout, TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync } from '@solana/spl-token';
+import { Connection, Keypair, PublicKey, SYSVAR_RENT_PUBKEY, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js';
 import { assert } from 'chai';
 import { describe, it } from 'mocha';
 import { BanksClient, ProgramTestContext, start } from 'solana-bankrun';

+ 2 - 2
tokens/token-swap/steel/tests/create_pool_and_withdraw_all_liquid.test.ts

@@ -1,5 +1,5 @@
-import { Connection, Keypair, PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js';
-import { AccountLayout, ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, MintLayout, TOKEN_PROGRAM_ID } from '@solana/spl-token';
+import { ASSOCIATED_TOKEN_PROGRAM_ID, AccountLayout, MintLayout, TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync } from '@solana/spl-token';
+import { Connection, Keypair, PublicKey, SYSVAR_RENT_PUBKEY, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js';
 import { assert } from 'chai';
 import { describe, it } from 'mocha';
 import { BanksClient, ProgramTestContext, start } from 'solana-bankrun';