Skip to content

Commit 55d896f

Browse files
author
adpthegreat
committed
fix:ran pnpm fix
1 parent d3734fe commit 55d896f

File tree

4 files changed

+37
-57
lines changed

4 files changed

+37
-57
lines changed

basics/close-account/poseidon/close_account_program/migrations/deploy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// single deploy script that's invoked from the CLI, injecting a provider
33
// configured from the workspace's Anchor.toml.
44

5-
const anchor = require("@coral-xyz/anchor");
5+
const anchor = require('@coral-xyz/anchor');
66

7-
module.exports = async function (provider) {
7+
module.exports = async (provider) => {
88
// Configure client to use the provider.
99
anchor.setProvider(provider);
1010

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

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
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 an account", async () => {
12+
describe('Close an account', async () => {
1313
// Configure the client to use the local cluster.
14-
const context = await startAnchor(
15-
"",
16-
[{ name: "close_account", programId: PROGRAM_ID }],
17-
[]
18-
);
14+
const context = await startAnchor('', [{ name: 'close_account', 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("Can create an account", async () => {
30-
const userId = anchor.BN(76362)
22+
it('Can create an account', async () => {
23+
const userId = anchor.BN(76362);
3124
await program.methods
3225
.createUser(userId)
3326
.accounts({
@@ -36,13 +29,11 @@ describe("Close an account", async () => {
3629
.rpc();
3730

3831
// Fetch the account data
39-
const userAccount = await program.account.userAccount.fetch(
40-
userAccountAddress
41-
);
42-
assert.notEqual(userAccount, null);
32+
const userAccount = await program.account.userAccount.fetch(userAccountAddress);
33+
assert.notEqual(userAccount, null);
4334
});
4435

45-
it("Can close an Account", async () => {
36+
it('Can close an Account', async () => {
4637
await program.methods
4738
.closeUser()
4839
.accounts({
@@ -52,9 +43,7 @@ describe("Close an account", async () => {
5243

5344
// The account should no longer exist, returning null.
5445
try {
55-
const userAccount = await program.account.userAccount.fetchNullable(
56-
userAccountAddress
57-
);
46+
const userAccount = await program.account.userAccount.fetchNullable(userAccountAddress);
5847
assert.equal(userAccount, null);
5948
} catch (err) {
6049
// Won't return null and will throw an error in anchor-bankrun'
Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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 type { 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 type { CloseAccountProgram } from '../target/types/close_account_program';
66

7-
describe("Close an account", () => {
7+
describe('Close an account', () => {
88
// Configure the client to use the local cluster.
99
const provider = anchor.AnchorProvider.env();
1010
anchor.setProvider(provider);
@@ -13,13 +13,10 @@ describe("Close an account", () => {
1313
const payer = provider.wallet as anchor.Wallet;
1414

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

21-
it("can create an account", async () => {
22-
const userId = anchor.BN(76362)
18+
it('can create an account', async () => {
19+
const userId = anchor.BN(76362);
2320

2421
await program.methods
2522
.createUser(userId)
@@ -29,24 +26,20 @@ describe("Close an account", () => {
2926
.rpc();
3027

3128
// Fetch the account data
32-
const userAccount = await program.account.userAccount.fetch(
33-
userAccountAddress
34-
);
35-
assert.notEqual(userAccount, null)
29+
const userAccount = await program.account.userAccount.fetch(userAccountAddress);
30+
assert.notEqual(userAccount, null);
3631
});
3732

38-
it("can close an account", async () => {
33+
it('can close an account', async () => {
3934
await program.methods
4035
.closeUser()
4136
.accounts({
42-
user: payer.publicKey
37+
user: payer.publicKey,
4338
})
4439
.rpc();
4540

4641
// The account should no longer exist, returning null.
47-
const userAccount = await program.account.userAccount.fetchNullable(
48-
userAccountAddress
49-
);
42+
const userAccount = await program.account.userAccount.fetchNullable(userAccountAddress);
5043
assert.equal(userAccount, null);
5144
});
5245
});

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

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

33
export default class CloseAccount {
4-
static PROGRAM_ID = new Pubkey(
5-
"2q4uoWExFAbZjeDe4n3miipsT9bX9vLnkSetCfZYF2VT"
6-
);
4+
static PROGRAM_ID = new Pubkey('2q4uoWExFAbZjeDe4n3miipsT9bX9vLnkSetCfZYF2VT');
75

86
createUser(user: Signer, userAccount: UserAccount, userId: u32): Result {
9-
userAccount.derive(["USER", user.key]).init();
7+
userAccount.derive(['USER', user.key]).init();
108

119
userAccount.userBump = userAccount.getBump();
1210

@@ -15,7 +13,7 @@ export default class CloseAccount {
1513
userAccount.userId = userId;
1614
}
1715
closeUser(userAccount: UserAccount, user: Signer): Result {
18-
userAccount.derive(["USER", user.key]).close(user);
16+
userAccount.derive(['USER', user.key]).close(user);
1917
}
2018
}
2119

0 commit comments

Comments
 (0)