Skip to content

Commit 3fdd6f7

Browse files
committed
fix anchor errors group 2
1 parent 43d7d77 commit 3fdd6f7

File tree

10 files changed

+253
-375
lines changed

10 files changed

+253
-375
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
2-
"type": "module",
3-
"dependencies": {
4-
"@coral-xyz/anchor": "^0.30.0",
5-
"@solana/web3.js": "^1.95.2"
6-
},
7-
"devDependencies": {
8-
"anchor-bankrun": "^0.4.0",
9-
"solana-bankrun": "^0.3.0",
10-
"@types/bn.js": "^5.1.0",
11-
"@types/chai": "^4.3.0",
12-
"@types/mocha": "^9.0.0",
13-
"chai": "^4.3.4",
14-
"mocha": "^9.0.3",
15-
"ts-mocha": "^10.0.0",
16-
"typescript": "^4.3.5"
17-
}
2+
"type": "module",
3+
"dependencies": {
4+
"@coral-xyz/anchor": "0.31.1",
5+
"@solana/web3.js": "^1.95.2"
6+
},
7+
"devDependencies": {
8+
"@types/bn.js": "^5.1.0",
9+
"@types/chai": "^4.3.0",
10+
"@types/mocha": "^9.0.0",
11+
"anchor-bankrun": "^0.4.0",
12+
"chai": "^4.3.4",
13+
"mocha": "^9.0.3",
14+
"solana-bankrun": "^0.3.0",
15+
"ts-mocha": "^10.0.0",
16+
"typescript": "^4.3.5"
17+
}
1818
}

basics/pda-rent-payer/anchor/pnpm-lock.yaml

Lines changed: 21 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

basics/pda-rent-payer/anchor/tests/bankrun.test.ts

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, it } from "node:test";
22
import * as anchor from "@coral-xyz/anchor";
33
import { Keypair, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";
44
import { BankrunProvider } from "anchor-bankrun";
5+
import BN from "bn.js";
56
import { assert } from "chai";
67
import { startAnchor } from "solana-bankrun";
78
import type { PdaRentPayer } from "../target/types/pda_rent_payer";
@@ -10,57 +11,57 @@ import IDL from "../target/idl/pda_rent_payer.json" with { type: "json" };
1011
const PROGRAM_ID = new PublicKey(IDL.address);
1112

1213
describe("PDA Rent-Payer", async () => {
13-
const context = await startAnchor(
14-
"",
15-
[{ name: "pda_rent_payer", programId: PROGRAM_ID }],
16-
[],
17-
);
18-
const provider = new BankrunProvider(context);
19-
const program = new anchor.Program<PdaRentPayer>(IDL, provider);
14+
const context = await startAnchor(
15+
"",
16+
[{ name: "pda_rent_payer", programId: PROGRAM_ID }],
17+
[],
18+
);
19+
const provider = new BankrunProvider(context);
20+
const program = new anchor.Program<PdaRentPayer>(IDL, provider);
2021

21-
const wallet = provider.wallet as anchor.Wallet;
22-
const connection = provider.connection;
22+
const wallet = provider.wallet as anchor.Wallet;
23+
const connection = provider.connection;
2324

24-
// PDA for the Rent Vault
25-
const [rentVaultPDA] = PublicKey.findProgramAddressSync(
26-
[Buffer.from("rent_vault")],
27-
program.programId,
28-
);
25+
// PDA for the Rent Vault
26+
const [rentVaultPDA] = PublicKey.findProgramAddressSync(
27+
[Buffer.from("rent_vault")],
28+
program.programId,
29+
);
2930

30-
it("Initialize the Rent Vault", async () => {
31-
// 1 SOL
32-
const fundAmount = new anchor.BN(LAMPORTS_PER_SOL);
31+
it("Initialize the Rent Vault", async () => {
32+
// 1 SOL
33+
const fundAmount = new BN(LAMPORTS_PER_SOL);
3334

34-
await program.methods
35-
.initRentVault(fundAmount)
36-
.accounts({
37-
payer: wallet.publicKey,
38-
})
39-
.rpc();
35+
await program.methods
36+
.initRentVault(fundAmount)
37+
.accounts({
38+
payer: wallet.publicKey,
39+
})
40+
.rpc();
4041

41-
// Check rent vault balance
42-
const accountInfo =
43-
await program.provider.connection.getAccountInfo(rentVaultPDA);
44-
assert(accountInfo.lamports === fundAmount.toNumber());
45-
});
42+
// Check rent vault balance
43+
const accountInfo =
44+
await program.provider.connection.getAccountInfo(rentVaultPDA);
45+
assert(accountInfo.lamports === fundAmount.toNumber());
46+
});
4647

47-
it("Create a new account using the Rent Vault", async () => {
48-
// Generate a new keypair for the new account
49-
const newAccount = new Keypair();
48+
it("Create a new account using the Rent Vault", async () => {
49+
// Generate a new keypair for the new account
50+
const newAccount = new Keypair();
5051

51-
await program.methods
52-
.createNewAccount()
53-
.accounts({
54-
newAccount: newAccount.publicKey,
55-
})
56-
.signers([newAccount])
57-
.rpc();
52+
await program.methods
53+
.createNewAccount()
54+
.accounts({
55+
newAccount: newAccount.publicKey,
56+
})
57+
.signers([newAccount])
58+
.rpc();
5859

59-
// Minimum balance for rent exemption for new account
60-
const lamports = await connection.getMinimumBalanceForRentExemption(0);
60+
// Minimum balance for rent exemption for new account
61+
const lamports = await connection.getMinimumBalanceForRentExemption(0);
6162

62-
// Check that the account was created
63-
const accountInfo = await connection.getAccountInfo(newAccount.publicKey);
64-
assert(accountInfo.lamports === lamports);
65-
});
63+
// Check that the account was created
64+
const accountInfo = await connection.getAccountInfo(newAccount.publicKey);
65+
assert(accountInfo.lamports === lamports);
66+
});
6667
});

0 commit comments

Comments
 (0)