Skip to content

Commit e23e9f6

Browse files
committed
update format
1 parent 699b6be commit e23e9f6

File tree

4 files changed

+32
-58
lines changed

4 files changed

+32
-58
lines changed
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
2-
"scripts": {
3-
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
4-
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check",
5-
"ts-mocha": "ts-mocha --project tsconfig.json"
6-
},
2+
"scripts": {},
73
"dependencies": {
84
"@coral-xyz/anchor": "^0.30.0",
95
"@solana/web3.js": "^1.95.2"
@@ -18,6 +14,5 @@
1814
"mocha": "^9.0.3",
1915
"ts-mocha": "^10.0.0",
2016
"typescript": "^4.3.5"
21-
2217
}
23-
}
18+
}

basics/close-account/poseidon/tests/bankrun.test.ts

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
1-
import assert from "node:assert";
2-
import { describe, it } from "node:test";
3-
import * as anchor from "@coral-xyz/anchor";
4-
import { PublicKey } from "@solana/web3.js";
5-
import { BankrunProvider } from "anchor-bankrun";
6-
import { startAnchor } from "solana-bankrun";
7-
import type { CloseAccountProgram } from "../target/types/close_account_program";
1+
import assert from 'node:assert';
2+
import { describe, it } from 'node:test';
3+
import * as anchor from '@coral-xyz/anchor';
4+
import { PublicKey } from '@solana/web3.js';
5+
import { BankrunProvider } from 'anchor-bankrun';
6+
import { startAnchor } from 'solana-bankrun';
7+
import type { CloseAccountProgram } from '../target/types/close_account_program';
88

9-
const IDL = require("../target/idl/close_account_program.json");
9+
const IDL = require('../target/idl/close_account_program.json');
1010
const PROGRAM_ID = new PublicKey(IDL.address);
1111

12-
describe("close-account", async () => {
12+
describe('close-account', async () => {
1313
// Configure the client to use the local cluster.
14-
const context = await startAnchor(
15-
"",
16-
[{ name: "close_account_program", programId: PROGRAM_ID }],
17-
[]
18-
);
14+
const context = await startAnchor('', [{ name: 'close_account_program', programId: PROGRAM_ID }], []);
1915
const provider = new BankrunProvider(context);
2016

2117
const payer = provider.wallet as anchor.Wallet;
2218
const program = new anchor.Program<CloseAccountProgram>(IDL, provider);
2319
// Derive the PDA for the user's account.
24-
const [userAccountAddress] = PublicKey.findProgramAddressSync(
25-
[Buffer.from("user"), payer.publicKey.toBuffer()],
26-
program.programId
27-
);
20+
const [userAccountAddress] = PublicKey.findProgramAddressSync([Buffer.from('user'), payer.publicKey.toBuffer()], program.programId);
2821

29-
it("Create Account", async () => {
22+
it('Create Account', async () => {
3023
await program.methods
3124
.createUser()
3225
.accounts({
@@ -35,13 +28,11 @@ describe("close-account", async () => {
3528
.rpc();
3629

3730
// Fetch the account data
38-
const userAccount = await program.account.closeAccountState.fetch(
39-
userAccountAddress
40-
);
31+
const userAccount = await program.account.closeAccountState.fetch(userAccountAddress);
4132
assert.equal(userAccount.user.toBase58(), payer.publicKey.toBase58());
4233
});
4334

44-
it("Close Account", async () => {
35+
it('Close Account', async () => {
4536
await program.methods
4637
.closeUser()
4738
.accounts({
@@ -51,9 +42,7 @@ describe("close-account", async () => {
5142

5243
// The account should no longer exist, returning null.
5344
try {
54-
const userAccount = await program.account.closeAccountState.fetchNullable(
55-
userAccountAddress
56-
);
45+
const userAccount = await program.account.closeAccountState.fetchNullable(userAccountAddress);
5746
assert.equal(userAccount, null);
5847
} catch (err) {
5948
// Won't return null and will throw an error in anchor-bankrun'
Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
import assert from "node:assert";
2-
import * as anchor from "@coral-xyz/anchor";
3-
import type { Program } from "@coral-xyz/anchor";
4-
import { PublicKey } from "@solana/web3.js";
5-
import { CloseAccountProgram } from "../target/types/close_account_program";
1+
import assert from 'node:assert';
2+
import * as anchor from '@coral-xyz/anchor';
3+
import type { Program } from '@coral-xyz/anchor';
4+
import { PublicKey } from '@solana/web3.js';
5+
import { CloseAccountProgram } from '../target/types/close_account_program';
66

7-
describe("close_account", () => {
7+
describe('close_account', () => {
88
// Configure the client to use the local cluster.
99

1010
const provider = anchor.AnchorProvider.env();
1111
anchor.setProvider(provider);
1212

13-
const program = anchor.workspace
14-
.CloseAccountProgram as Program<CloseAccountProgram>;
13+
const program = anchor.workspace.CloseAccountProgram as Program<CloseAccountProgram>;
1514
const payer = provider.wallet as anchor.Wallet;
1615

1716
// Derive the PDA for the user's account.
18-
const [userAccountAddress] = PublicKey.findProgramAddressSync(
19-
[Buffer.from("user"), payer.publicKey.toBuffer()],
20-
program.programId
21-
);
17+
const [userAccountAddress] = PublicKey.findProgramAddressSync([Buffer.from('user'), payer.publicKey.toBuffer()], program.programId);
2218

23-
it("Create Account", async () => {
19+
it('Create Account', async () => {
2420
await program.methods
2521
.createUser()
2622
.accounts({
@@ -30,13 +26,11 @@ describe("close_account", () => {
3026
.rpc();
3127

3228
// Fetch the account data
33-
const userAccount = await program.account.closeAccountState.fetch(
34-
userAccountAddress
35-
);
29+
const userAccount = await program.account.closeAccountState.fetch(userAccountAddress);
3630
assert.equal(userAccount.user.toBase58(), payer.publicKey.toBase58());
3731
});
3832

39-
it("Close Account", async () => {
33+
it('Close Account', async () => {
4034
await program.methods
4135
.closeUser()
4236
.accounts({
@@ -46,9 +40,7 @@ describe("close_account", () => {
4640
.rpc();
4741

4842
// The account should no longer exist, returning null.
49-
const userAccount = await program.account.closeAccountState.fetchNullable(
50-
userAccountAddress
51-
);
43+
const userAccount = await program.account.closeAccountState.fetchNullable(userAccountAddress);
5244
assert.equal(userAccount, null);
5345
});
5446
});

basics/close-account/poseidon/ts-programs/src/closeAccountProgram.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { Account, Pubkey, Result, u8, Signer } from "@solanaturbine/poseidon";
1+
import { Account, Pubkey, Result, Signer, u8 } from '@solanaturbine/poseidon';
22

33
export default class closeAccountProgram {
4-
static PROGRAM_ID = new Pubkey(
5-
"7U4SZvsUMjGYCwnzqGGE9enJactKhVPF2EaE7VHtBLTd"
6-
);
4+
static PROGRAM_ID = new Pubkey('7U4SZvsUMjGYCwnzqGGE9enJactKhVPF2EaE7VHtBLTd');
75

86
// create user account
97

108
create_user(user_account: closeAccountState, user: Signer): Result {
11-
user_account.derive(["user", user.key]).init();
9+
user_account.derive(['user', user.key]).init();
1210

1311
// Set the initial value to the `user_account` fields
1412
user_account.user = user.key;

0 commit comments

Comments
 (0)