Skip to content

Commit

Permalink
updated Add basics/close-account/poseidon
Browse files Browse the repository at this point in the history
  • Loading branch information
ved08 committed Nov 25, 2024
1 parent 715a3b8 commit 4806a51
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions basics/close-account/poseidon/migrations/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anchor_lang::prelude::*;
declare_id!("11111111111111111111111111111111");
declare_id!("4So9Jbx672BRL9RvfB8Sux2NMVX5QJRnhmdWyij3kkFg");
#[program]
pub mod close_account {
use super::*;
Expand Down
19 changes: 8 additions & 11 deletions basics/close-account/poseidon/tests/close-account.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { CloseAccount } from "../target/types/close_account";
import { assert } from "chai";
import * as anchor from '@coral-xyz/anchor';
import { Program } from '@coral-xyz/anchor';
import { assert } from 'chai';
import { CloseAccount } from '../target/types/close_account';

describe("close-account", () => {
describe('close-account', () => {
// Configure the client to use the local cluster.
const provider = anchor.AnchorProvider.env();
anchor.setProvider(provider);

const program = anchor.workspace.CloseAccount as Program<CloseAccount>;
const user = provider.wallet;

const accountState = anchor.web3.PublicKey.findProgramAddressSync(
[anchor.utils.bytes.utf8.encode("account")],
program.programId
)[0];
const accountState = anchor.web3.PublicKey.findProgramAddressSync([anchor.utils.bytes.utf8.encode('account')], program.programId)[0];
const someData = Math.floor(Math.random() * 100);

it("Can initalize an account", async () => {
it('Can initalize an account', async () => {
await program.methods
.initalize(someData)
.accounts({
Expand All @@ -27,7 +24,7 @@ describe("close-account", () => {
const acc = await program.account.accountState.fetchNullable(accountState);
assert.notEqual(acc, null);
});
it("Can close an account", async () => {
it('Can close an account', async () => {
await program.methods
.close()
.accounts({
Expand Down
8 changes: 4 additions & 4 deletions basics/close-account/poseidon/ts-programs/closeAccounts.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Account, Pubkey, Result, u8, Signer } from "@solanaturbine/poseidon";
import { Account, Pubkey, Result, Signer, u8 } from '@solanaturbine/poseidon';

export default class CloseAccount {
static PROGRAM_ID = new Pubkey("11111111111111111111111111111111");
static PROGRAM_ID = new Pubkey('11111111111111111111111111111111');

initalize(state: AccountState, user: Signer, data: u8): Result {
state.derive(["account"]).init();
state.derive(['account']).init();
state.someData = data;
}
close(state: AccountState, user: Signer): Result {
state.derive(["account"]).close(user);
state.derive(['account']).close(user);
}
}

Expand Down

0 comments on commit 4806a51

Please sign in to comment.