Skip to content

Commit

Permalink
update: ran checks like pnpm fix, poseidon sync etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
dorkydhruv committed Nov 26, 2024
1 parent a2824d0 commit ad5357e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 30 deletions.
2 changes: 1 addition & 1 deletion basics/counter/poseidon/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resolution = true
skip-lint = false

[programs.localnet]
counter = "EqkjKELHRgipbqzTL4x6uo9hWWoMuZ7G8vdWh6A2cpj"
counter = "GkV2QQhYjUdtodnREvNATozYWoEsTQX8ezUZs8Ncy3gm"

[registry]
url = "https://api.apr.dev"
Expand Down
2 changes: 1 addition & 1 deletion basics/counter/poseidon/programs/counter/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anchor_lang::prelude::*;
declare_id!("EqkjKELHRgipbqzTL4x6uo9hWWoMuZ7G8vdWh6A2cpj");
declare_id!("GkV2QQhYjUdtodnREvNATozYWoEsTQX8ezUZs8Ncy3gm");
#[program]
pub mod counter {
use super::*;
Expand Down
30 changes: 12 additions & 18 deletions basics/counter/poseidon/tests/counter.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import * as anchor from "@coral-xyz/anchor";
import type { Program } from "@coral-xyz/anchor";
import { assert } from "chai";
import type { Counter } from "../target/types/counter";
import * as anchor from '@coral-xyz/anchor';
import type { Program } from '@coral-xyz/anchor';
import { assert } from 'chai';
import type { Counter } from '../target/types/counter';

describe("counter_anchor", () => {
describe('counter_anchor', () => {
// Configure the client to use the local cluster.
const provider = anchor.AnchorProvider.env();
anchor.setProvider(provider);
const payer = provider.wallet as anchor.Wallet;

const program = anchor.workspace.Counter as Program<Counter>;
const [counter, _] = anchor.web3.PublicKey.findProgramAddressSync(
[Buffer.from("")],
program.programId
);
const [counter, _] = anchor.web3.PublicKey.findProgramAddressSync([Buffer.from('')], program.programId);

it("Initialize Counter", async () => {
it('Initialize Counter', async () => {
await program.methods
.initializeCounter()
.accounts({
Expand All @@ -25,25 +22,22 @@ describe("counter_anchor", () => {

const currentCount = await program.account.counterState.fetch(counter);

assert(
currentCount.count.toNumber() === 0,
"Expected initialized count to be 0"
);
assert(currentCount.count.toNumber() === 0, 'Expected initialized count to be 0');
});

it("Increment Counter", async () => {
it('Increment Counter', async () => {
await program.methods.incrementCounter().accounts({ counter }).rpc();

const currentCount = await program.account.counterState.fetch(counter);

assert(currentCount.count.toNumber() === 1, "Expected count to be 1");
assert(currentCount.count.toNumber() === 1, 'Expected count to be 1');
});

it("Increment Counter Again", async () => {
it('Increment Counter Again', async () => {
await program.methods.incrementCounter().accounts({ counter }).rpc();

const currentCount = await program.account.counterState.fetch(counter);

assert(currentCount.count.toNumber() === 2, "Expected count to be 2");
assert(currentCount.count.toNumber() === 2, 'Expected count to be 2');
});
});
14 changes: 4 additions & 10 deletions basics/counter/poseidon/ts-programs/src/counter.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import {
Account,
Pubkey,
type Result,
Signer,
u64,
} from "@solanaturbine/poseidon";
import { Account, Pubkey, type Result, Signer, u64 } from '@solanaturbine/poseidon';

export default class Counter {
static PROGRAM_ID = new Pubkey("EqkjKELHRgipbqzTL4x6uo9hWWoMuZ7G8vdWh6A2cpj");
static PROGRAM_ID = new Pubkey("GkV2QQhYjUdtodnREvNATozYWoEsTQX8ezUZs8Ncy3gm");

initializeCounter(payer: Signer, counter: CounterState): Result {
counter.derive([""]).init();
counter.derive(['']).init();
counter.count = new u64(0);
}

incrementCounter(counter: CounterState): Result {
counter.derive([""]);
counter.derive(['']);
counter.count = counter.count.add(1);
}
}
Expand Down

0 comments on commit ad5357e

Please sign in to comment.