Browse Source

Initialize vault and load it with 1029$

Nitish-bot 11 months ago
parent
commit
c5c56f17eb

+ 1 - 0
basics/pda-rent-payer/steel/Cargo.toml

@@ -14,6 +14,7 @@ keywords = ["solana"]
 
 [workspace.dependencies]
 pda-rent-payer-api = { path = "./api", version = "0.1.0" }
+borsh = "1.5"
 bytemuck = "1.14"
 num_enum = "0.7"
 solana-program = "1.18"

+ 3 - 3
basics/pda-rent-payer/steel/README.md

@@ -1,11 +1,11 @@
-# Steel
+# PDA Rent Payer
 
-**Steel** is a ...
+**PDA Rent Payer** is a program that uses a PDA to pay the rent
+for the creation of a system program by simply transferring lamports to it
         
 ## API
 - [`Consts`](api/src/consts.rs) – Program constants.
 - [`Error`](api/src/error.rs) – Custom program errors.
-- [`Event`](api/src/event.rs) – Custom program events.
 - [`Instruction`](api/src/instruction.rs) – Declared instructions.
 
 ## Instructions

+ 1 - 0
basics/pda-rent-payer/steel/api/Cargo.toml

@@ -11,6 +11,7 @@ readme.workspace = true
 keywords.workspace = true
 
 [dependencies]
+borsh.workspace = true
 bytemuck.workspace = true
 num_enum.workspace = true
 solana-program.workspace = true

+ 2 - 1
basics/pda-rent-payer/steel/api/src/instruction.rs

@@ -1,3 +1,4 @@
+use borsh::{ BorshDeserialize, BorshSerialize };
 use steel::*;
 
 #[repr(u8)]
@@ -8,7 +9,7 @@ pub enum PdaRentPayerInstruction {
 }
 
 #[repr(C)]
-#[derive(Clone, Copy, Debug, Pod, Zeroable)]
+#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, Pod, Zeroable)]
 pub struct InitializeRentVault {
     pub amount: u64,
 }

+ 1 - 1
basics/pda-rent-payer/steel/api/src/lib.rs

@@ -15,4 +15,4 @@ pub mod prelude {
 use steel::*;
 
 // TODO Set program id
-declare_id!("H8ocBhDZmzxRvWnT1yu5EQyLN3D9AYZv9qsePcx8pidg");
+declare_id!("HK5TuboXztZv7anSa3GptyCZ5wMYiqbY8kNSVEtqWDuD");

+ 2 - 6
basics/pda-rent-payer/steel/api/src/sdk.rs

@@ -2,7 +2,7 @@ use steel::*;
 
 use crate::prelude::*;
 
-pub fn init_rent_vault(signer_info: Pubkey, system_program: Pubkey, data: &[u8]) -> Instruction {
+pub fn init_rent_vault(signer_info: Pubkey, system_program: Pubkey, amount: u64) -> Instruction {
     Instruction {
         program_id: crate::ID,
         accounts: vec![
@@ -10,10 +10,7 @@ pub fn init_rent_vault(signer_info: Pubkey, system_program: Pubkey, data: &[u8])
             AccountMeta::new(rent_vault_pda().0, false),
             AccountMeta::new_readonly(system_program, false),
         ],
-        data: InitializeRentVault {
-            amount: u64::from_be_bytes(data[..8].try_into().unwrap()),
-        }
-        .to_bytes(),
+        data: InitializeRentVault { amount }.to_bytes(),
     }
 }
 
@@ -23,7 +20,6 @@ pub fn create_new_account(rent_vault: Pubkey, new_account: Pubkey) -> Instructio
         accounts: vec![
             AccountMeta::new(rent_vault, false),
             AccountMeta::new(new_account, true),
-            AccountMeta::new_readonly(system_program::ID, false),
         ],
         data: CreateNewAccount {}.to_bytes(),
     }

+ 3 - 3
basics/pda-rent-payer/steel/api/src/state/accounts.rs

@@ -1,4 +1,4 @@
-use super::PdaRentPayerAccount;
+use super::PdaRentPayerAccountDiscriminator;
 use steel::*;
 
 /// This empty struct represents the payer vault account
@@ -12,5 +12,5 @@ pub struct RentVault {}
 #[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
 pub struct NewAccount {}
 
-account!(PdaRentPayerAccount, RentVault);
-account!(PdaRentPayerAccount, NewAccount);
+account!(PdaRentPayerAccountDiscriminator, RentVault);
+account!(PdaRentPayerAccountDiscriminator, NewAccount);

+ 1 - 6
basics/pda-rent-payer/steel/api/src/state/mod.rs

@@ -8,7 +8,7 @@ use steel::*;
 /// accounts this program can interact with
 #[repr(u8)]
 #[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
-pub enum PdaRentPayerAccount {
+pub enum PdaRentPayerAccountDiscriminator {
     RentVault = 0,
     NewAccount = 1,
 }
@@ -17,8 +17,3 @@ pub enum PdaRentPayerAccount {
 pub fn rent_vault_pda() -> (Pubkey, u8) {
     Pubkey::find_program_address(&[RENT_VAULT], &crate::id())
 }
-
-// Fetch PDA of the newly_created account.
-// pub fn new_account_pda() -> (Pubkey, u8) {
-//     Pubkey::find_program_address(&[NEW_ACCOUNT], &crate::id())
-// }

+ 26 - 0
basics/pda-rent-payer/steel/cicd.sh

@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# Buld and deploy this program with ease using a single command
+# Run this script with "bash cicd.sh" or "./cicd.sh"
+# Note: Try running "chmod +x cicd.sh" if you face any issues.
+
+# Check if cargo is installed
+if ! command -v cargo &> /dev/null
+then
+    echo "Cargo could not be found. Please install Rust."
+    exit 1
+fi
+
+# Check if solana CLI is installed
+if ! command -v solana &> /dev/null
+then
+    echo "Solana CLI could not be found. Please install Solana."
+    exit 1
+fi
+
+
+# Build
+cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so
+
+# Deploy
+solana program deploy ./program/target/so/pda_rent_payer_program.so

+ 5 - 6
basics/pda-rent-payer/steel/package.json

@@ -4,14 +4,12 @@
   "type": "module",
   "description": "Use a PDA to pay the rent for the creation of a new account.",
   "scripts": {
-    "test": "pnpm ts-mocha -p ./tsconfig.json -t 1000000 ./tests/test.ts",
+    "test": "pnpm ts-mocha -p ./tsconfig.json -t 1000000 ./tests/*.test.ts",
     "build-and-test": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures && pnpm test",
     "build": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so",
     "deploy": "solana program deploy ./program/target/so/pda_rent_payer_program.so"
   },
-  "keywords": [
-    "solana"
-  ],
+  "keywords": ["solana"],
   "author": "",
   "license": "MIT",
   "dependencies": {
@@ -20,9 +18,10 @@
   "devDependencies": {
     "@types/chai": "^4.3.20",
     "@types/mocha": "^10.0.9",
-    "@types/node": "^22.8.2",
+    "@types/node": "^22.8.5",
+    "borsh": "^2.0.0",
     "chai": "^4.5.0",
-    "mocha": "^10.7.3",
+    "mocha": "^10.8.2",
     "solana-bankrun": "^0.4.0",
     "ts-mocha": "^10.0.0",
     "typescript": "^5.6.3"

+ 24 - 16
basics/pda-rent-payer/steel/pnpm-lock.yaml

@@ -19,20 +19,23 @@ importers:
         specifier: ^10.0.9
         version: 10.0.9
       '@types/node':
-        specifier: ^22.8.2
-        version: 22.8.2
+        specifier: ^22.8.5
+        version: 22.8.5
+      borsh:
+        specifier: ^2.0.0
+        version: 2.0.0
       chai:
         specifier: ^4.5.0
         version: 4.5.0
       mocha:
-        specifier: ^10.7.3
-        version: 10.7.3
+        specifier: ^10.8.2
+        version: 10.8.2
       solana-bankrun:
         specifier: ^0.4.0
         version: 0.4.0(bufferutil@4.0.8)(utf-8-validate@5.0.10)
       ts-mocha:
         specifier: ^10.0.0
-        version: 10.0.0(mocha@10.7.3)
+        version: 10.0.0(mocha@10.8.2)
       typescript:
         specifier: ^5.6.3
         version: 5.6.3
@@ -76,8 +79,8 @@ packages:
   '@types/node@12.20.55':
     resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==}
 
-  '@types/node@22.8.2':
-    resolution: {integrity: sha512-NzaRNFV+FZkvK/KLCsNdTvID0SThyrs5SHB6tsD/lajr22FGC73N2QeDPM2wHtVde8mgcXuSsHQkH5cX1pbPLw==}
+  '@types/node@22.8.5':
+    resolution: {integrity: sha512-5iYk6AMPtsMbkZqCO1UGF9W5L38twq11S2pYWkybGHH2ogPUvXWNlQqJBzuEZWKj/WRH+QTeiv6ySWqJtvIEgA==}
 
   '@types/uuid@8.3.4':
     resolution: {integrity: sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==}
@@ -148,6 +151,9 @@ packages:
   borsh@0.7.0:
     resolution: {integrity: sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==}
 
+  borsh@2.0.0:
+    resolution: {integrity: sha512-kc9+BgR3zz9+cjbwM8ODoUB4fs3X3I5A/HtX7LZKxCLaMrEeDFoBpnhZY//DTS1VZBSs6S5v46RZRbZjRFspEg==}
+
   brace-expansion@2.0.1:
     resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==}
 
@@ -397,8 +403,8 @@ packages:
     resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==}
     hasBin: true
 
-  mocha@10.7.3:
-    resolution: {integrity: sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A==}
+  mocha@10.8.2:
+    resolution: {integrity: sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==}
     engines: {node: '>= 14.0.0'}
     hasBin: true
 
@@ -696,7 +702,7 @@ snapshots:
 
   '@types/connect@3.4.38':
     dependencies:
-      '@types/node': 22.8.2
+      '@types/node': 22.8.5
 
   '@types/json5@0.0.29':
     optional: true
@@ -705,7 +711,7 @@ snapshots:
 
   '@types/node@12.20.55': {}
 
-  '@types/node@22.8.2':
+  '@types/node@22.8.5':
     dependencies:
       undici-types: 6.19.8
 
@@ -713,11 +719,11 @@ snapshots:
 
   '@types/ws@7.4.7':
     dependencies:
-      '@types/node': 22.8.2
+      '@types/node': 22.8.5
 
   '@types/ws@8.5.12':
     dependencies:
-      '@types/node': 22.8.2
+      '@types/node': 22.8.5
 
   JSONStream@1.3.5:
     dependencies:
@@ -773,6 +779,8 @@ snapshots:
       bs58: 4.0.1
       text-encoding-utf-8: 1.0.2
 
+  borsh@2.0.0: {}
+
   brace-expansion@2.0.1:
     dependencies:
       balanced-match: 1.0.2
@@ -1011,7 +1019,7 @@ snapshots:
     dependencies:
       minimist: 1.2.8
 
-  mocha@10.7.3:
+  mocha@10.8.2:
     dependencies:
       ansi-colors: 4.1.3
       browser-stdout: 1.3.1
@@ -1166,9 +1174,9 @@ snapshots:
 
   tr46@0.0.3: {}
 
-  ts-mocha@10.0.0(mocha@10.7.3):
+  ts-mocha@10.0.0(mocha@10.8.2):
     dependencies:
-      mocha: 10.7.3
+      mocha: 10.8.2
       ts-node: 7.0.1
     optionalDependencies:
       tsconfig-paths: 3.15.0

+ 1 - 0
basics/pda-rent-payer/steel/program/Cargo.toml

@@ -14,6 +14,7 @@ keywords.workspace = true
 crate-type = ["cdylib", "lib"]
 
 [dependencies]
+borsh.workspace = true
 pda-rent-payer-api.workspace = true
 solana-program.workspace = true
 steel.workspace = true

+ 25 - 10
basics/pda-rent-payer/steel/program/src/create_new_account.rs

@@ -1,23 +1,38 @@
 use pda_rent_payer_api::prelude::*;
+use solana_program::msg;
+use steel::sysvar::rent::Rent;
 use steel::*;
 
-pub fn process_create_account(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult {
-    // // Parse args.
-    // let args = Add::try_from_bytes(data)?;
-    // let amount = u64::from_le_bytes(args.amount);
-
-    // Load and validate accounts.
-    let [payer_info, new_account_info] = accounts else {
+pub fn process_create_account(accounts: &[AccountInfo<'_>]) -> ProgramResult {
+    // Load accounts
+    let [rent_vault_info, new_account_info, system_program] = accounts else {
         return Err(ProgramError::NotEnoughAccountKeys);
     };
+
+    // Validate accounts
     new_account_info.is_signer()?.is_empty()?.is_writable()?;
-    payer_info
+    rent_vault_info
         .is_writable()?
         .has_seeds(&[RENT_VAULT], &pda_rent_payer_api::ID)?;
+    system_program.is_program(&system_program::ID)?;
+
+    let vault_balance = rent_vault_info.lamports();
 
-    // Create new account by simply sending a
+    msg!("Vault balance: {}", vault_balance);
+    // First we get the lamports required for rent
+    // assuming this account has no inner data
+    let lamports_required_for_rent = (Rent::get()?).minimum_balance(0);
+    
+    if vault_balance < lamports_required_for_rent {
+        return Err(ProgramError::InsufficientFunds);
+    }
+
+    // Then we create a new account by simply sending a
     // token amount to the new account.
-    payer_info.send(100, new_account_info);
+    rent_vault_info.send(lamports_required_for_rent, new_account_info);
+
+    msg!("Created new account.");
+    msg!("New account: {:?}", new_account_info.key);
 
     Ok(())
 }

+ 28 - 7
basics/pda-rent-payer/steel/program/src/init_rent_vault.rs

@@ -1,11 +1,11 @@
+use borsh::BorshDeserialize;
 use pda_rent_payer_api::prelude::*;
 use solana_program::msg;
 use steel::*;
 
 pub fn process_initialize_vault(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
     // Parse args
-    let args = data[..8].try_into().expect("Error parsing args");
-    let amount = u64::from_le_bytes(args);
+    let args = InitializeRentVault::try_from_slice(data)?;
 
     // Load and validate accounts.
     let [payer_info, rent_vault_info, system_program] = accounts else {
@@ -27,11 +27,32 @@ pub fn process_initialize_vault(accounts: &[AccountInfo<'_>], data: &[u8]) -> Pr
         &[RENT_VAULT],
     )?;
 
-    payer_info.send(amount, rent_vault_info);
-
-    rent_vault_info.collect(amount, payer_info)?;
-
-    let _ = rent_vault_info.as_account_mut::<RentVault>(&pda_rent_payer_api::ID)?;
+    let (_, bump) = rent_vault_pda();
+
+    // Get account to see if it's created
+    let _vault = rent_vault_info.as_account_mut::<RentVault>(&pda_rent_payer_api::ID)?;
+
+    let transfer = solana_program::program::invoke_signed(
+        &solana_program::system_instruction::transfer(
+            payer_info.key,
+            rent_vault_info.key,
+            args.amount,
+        ),
+        &[
+            payer_info.clone(),
+            rent_vault_info.clone(),
+            system_program.clone(),
+        ],
+        &[&[RENT_VAULT, &[bump]]],
+    );
+
+    let vault_balance = rent_vault_info.lamports();
+    msg!("Updated vault balance: {}", vault_balance);
+
+    match transfer {
+        Ok(_) => (),
+        Err(e) => return Err(e.into()),
+    }
 
     msg!("Initialized rent vault.");
     msg!("PDA: {:?}", rent_vault_info.key);

+ 3 - 3
basics/pda-rent-payer/steel/program/src/lib.rs

@@ -12,13 +12,13 @@ pub fn process_instruction(
     accounts: &[AccountInfo],
     data: &[u8],
 ) -> ProgramResult {
-    /// Parse instruction automatically detects which instruction is being called
-    /// based on the discriminator and returns the instruction and the data
+    // Parse instruction automatically detects which instruction is being called
+    // based on the discriminator and returns the instruction and the data
     let (ix, data) = parse_instruction(&pda_rent_payer_api::ID, program_id, data)?;
 
     match ix {
         PdaRentPayerInstruction::InitializeRentVault => process_initialize_vault(accounts, data)?,
-        PdaRentPayerInstruction::CreateNewAccount => process_create_account(accounts, data)?,
+        PdaRentPayerInstruction::CreateNewAccount => process_create_account(accounts)?,
     }
 
     Ok(())

+ 122 - 0
basics/pda-rent-payer/steel/tests/main.test.ts

@@ -0,0 +1,122 @@
+import { type Blockhash, Keypair, LAMPORTS_PER_SOL, PublicKey, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js';
+import * as borsh from 'borsh';
+import { before, describe, it } from 'mocha';
+import { type BanksClient, type ProgramTestContext, start } from 'solana-bankrun';
+
+// Constants
+const PROGRAM_ID = new PublicKey('HK5TuboXztZv7anSa3GptyCZ5wMYiqbY8kNSVEtqWDuD');
+const VAULT_SEED = Buffer.from('rent_vault');
+const LOAD_LAMPORTS = 1 * LAMPORTS_PER_SOL; // 1 SOL
+
+const instructionDiscriminators = {
+  InitializeRentVault: 0,
+  CreateNewAccount: 1,
+};
+
+describe('Pay the rent for an account using a PDA', () => {
+  // Helper classes and methods to serialize instruction data
+  class Assignable {
+    constructor(properties) {
+      for (const [key, value] of Object.entries(properties)) {
+        this[key] = value;
+      }
+    }
+  }
+
+  class InitializeRentVault extends Assignable {
+    toBuffer() {
+      return Buffer.from(borsh.serialize(InitRentVaultSchema, this));
+    }
+  }
+  const InitRentVaultSchema = {
+    struct: {
+      instruction: 'u8',
+      fund_lamports: 'u64',
+    },
+  };
+
+  class CreateNewAccount extends Assignable {
+    toBuffer() {
+      return Buffer.from(borsh.serialize(CreateNewAccountSchema, this));
+    }
+  }
+  const CreateNewAccountSchema = {
+    struct: {
+      instruction: 'u8',
+    },
+  };
+
+  const [vault_pda, _] = PublicKey.findProgramAddressSync([VAULT_SEED], PROGRAM_ID);
+
+  let context: ProgramTestContext;
+  let client: BanksClient;
+  let payer: Keypair;
+
+  before(async () => {
+    context = await start([{ name: 'pda_rent_payer_program', programId: PROGRAM_ID }], []);
+    client = context.banksClient;
+    payer = context.payer;
+  });
+
+  it('should initialize rent vault PDA', async () => {
+    const ixdata = new InitializeRentVault({
+      instruction: instructionDiscriminators.InitializeRentVault,
+      fund_lamports: BigInt(LOAD_LAMPORTS),
+    });
+    const data = ixdata.toBuffer();
+
+    const Createix = new TransactionInstruction({
+      keys: [
+        { pubkey: payer.publicKey, isSigner: true, isWritable: false },
+        { pubkey: vault_pda, isSigner: false, isWritable: true },
+        { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
+      ],
+      programId: PROGRAM_ID,
+      data,
+    });
+
+    // const Fundix = SystemProgram.transfer({
+    //   fromPubkey: payer.publicKey,
+    //   toPubkey: vault_pda,
+    //   lamports: LOAD_LAMPORTS,
+    // });
+
+    const tx = new Transaction();
+    tx.recentBlockhash = context.lastBlockhash;
+    tx.add(Createix).sign(payer);
+
+    // Process Transaction with all the instructions
+    await client.processTransaction(tx);
+  });
+
+  it('should create new account using rent vault', async () => {
+    const newAccount = Keypair.generate();
+
+    const data = new CreateNewAccount({
+      instruction: instructionDiscriminators.CreateNewAccount,
+    }).toBuffer();
+
+    const ix = new TransactionInstruction({
+      keys: [
+        { pubkey: vault_pda, isSigner: false, isWritable: true },
+        { pubkey: newAccount.publicKey, isSigner: true, isWritable: true },
+        { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
+      ],
+      programId: PROGRAM_ID,
+      data,
+    });
+
+    const tx = new Transaction();
+    tx.recentBlockhash = context.lastBlockhash;
+    tx.add(ix).sign(newAccount);
+
+    // Process Transaction with all the instructions
+    await client.processTransaction(tx);
+
+    // assert(
+    // transaction.logMessages[3].startsWith(
+    //     "Program log: Created new account!",
+    // ),
+    // );
+  });
+});

+ 0 - 100
basics/pda-rent-payer/steel/tests/test.ts

@@ -1,100 +0,0 @@
-import {
-    type Blockhash,
-    Keypair,
-    LAMPORTS_PER_SOL,
-    PublicKey,
-    SystemProgram,
-    Transaction,
-    TransactionInstruction,
-} from "@solana/web3.js";
-import { assert } from "chai";
-import { before, describe, it } from "mocha";
-import {
-  type BanksClient,
-  type ProgramTestContext,
-  start,
-} from "solana-bankrun";
-  
-// Constants
-const PROGRAM_ID = new PublicKey(
-  "H8ocBhDZmzxRvWnT1yu5EQyLN3D9AYZv9qsePcx8pidg",
-);
-const VAULT_SEED = Buffer.from("rent_vault");
-const LOAD_LAMPORTS = LAMPORTS_PER_SOL; // 1 SOL
-
-const instructionDiscriminators = {
-    InitializeRentVault: Buffer.from([0]),
-    CreateNewAccount: Buffer.from([1]),
-}
-
-describe("Pay the rent for an account using a PDA", () => {
-  let context: ProgramTestContext;
-  let client: BanksClient;
-  let payer: Keypair;
-  
-  const [vault_pda, _] = PublicKey.findProgramAddressSync(
-    [VAULT_SEED],
-    PROGRAM_ID,
-  );
-
-  before(async () => {
-    context = await start(
-      [{ name: "pda_rent_payer_program", programId: PROGRAM_ID }],
-      [],
-    );
-    client = context.banksClient;
-    payer = context.payer;
-    
-  });
-
-  it("should initialize rent vault PDA", async () => {
-    const amount = Buffer.alloc(8);
-    amount.writeBigInt64BE(BigInt(LOAD_LAMPORTS), 0);
-    const data = Buffer.concat([instructionDiscriminators.InitializeRentVault, amount]);
-    
-    const ix = new TransactionInstruction({
-      keys: [
-        { pubkey: payer.publicKey, isSigner: true, isWritable: false },
-        { pubkey: vault_pda, isSigner: false, isWritable: true },
-        { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
-      ],
-      programId: PROGRAM_ID,
-      data,
-    });
-
-    const tx = new Transaction();
-    tx.recentBlockhash = context.lastBlockhash;
-    tx.add(ix).sign(payer);
-
-    // Process Transaction with all the instructions
-    await client.processTransaction(tx);
-  });
-
-  it("should create new account using rent vault", async () => {
-    const new_account = Keypair.generate();
-
-    const data = Buffer.concat([instructionDiscriminators.CreateNewAccount]);
-
-    const ix = new TransactionInstruction({
-    keys: [
-        { pubkey: vault_pda, isSigner: false, isWritable: true },
-        { pubkey: new_account.publicKey, isSigner: true, isWritable: true },
-    ],
-    programId: PROGRAM_ID,
-    data,
-    });
-
-    const tx = new Transaction();
-    tx.recentBlockhash = context.lastBlockhash;
-    tx.add(ix).sign(new_account);
-
-    // Process Transaction with all the instructions
-    const transaction = await client.processTransaction(tx);
-
-    // assert(
-    // transaction.logMessages[3].startsWith(
-    //     "Program log: Created new account!",
-    // ),
-    // );
-  });
-});

+ 13 - 13
basics/pda-rent-payer/steel/tsconfig.json

@@ -1,15 +1,15 @@
 {
-    "compilerOptions": {
-      "types": ["mocha", "chai", "node"],
-      "typeRoots": ["./node_modules/@types"],
-      "lib": ["es2015"],
-      "module": "commonjs",
-      "target": "es6",
-      "moduleResolution": "node",
-      "esModuleInterop": true,
-      "strict": true,
-      "sourceMap": true,
-      "outDir": "./dist",
-      "baseUrl": "."
-    }
+  "compilerOptions": {
+    "types": ["mocha", "chai", "node"],
+    "typeRoots": ["./node_modules/@types"],
+    "lib": ["es2015"],
+    "module": "commonjs",
+    "target": "es6",
+    "moduleResolution": "node",
+    "esModuleInterop": true,
+    "strict": true,
+    "sourceMap": true,
+    "outDir": "./dist",
+    "baseUrl": "."
+  }
 }