-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
adpthegreat
committed
Nov 24, 2024
1 parent
f3ae3f5
commit 6f2d1c2
Showing
4 changed files
with
94 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 19 additions & 22 deletions
41
basics/counter/poseidon/counter_program/ts-programs/src/counter_program.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
import { Account, Pubkey, Signer, u8, u64 } from '@solanaturbine/poseidon'; | ||
|
||
export interface Counter extends Account { | ||
count: u64; | ||
bump: u8; | ||
} | ||
export interface Counter extends Account { | ||
count: u64; | ||
bump: u8; | ||
} | ||
|
||
export default class counter_program { | ||
static PROGRAM_ID = new Pubkey( | ||
"EvcknV23Y3dkbSa4afZNGw2PgoowcfxCy4qvP8Ghogwu" | ||
); | ||
export default class counter_program { | ||
static PROGRAM_ID = new Pubkey('EvcknV23Y3dkbSa4afZNGw2PgoowcfxCy4qvP8Ghogwu'); | ||
|
||
initializeCounter(counter: Counter, payer: Signer) { | ||
counter.derive(["count"]).init(); | ||
counter.count = new u64(0); | ||
} | ||
increment(counter: Counter) { | ||
counter.derive(["count"]); | ||
counter.count = counter.count.add(1); | ||
} | ||
decrement(counter: Counter) { | ||
counter.derive(["count"]); | ||
counter.count = counter.count.sub(1); | ||
} | ||
} | ||
|
||
initializeCounter(counter: Counter, payer: Signer) { | ||
counter.derive(['count']).init(); | ||
counter.count = new u64(0); | ||
} | ||
increment(counter: Counter) { | ||
counter.derive(['count']); | ||
counter.count = counter.count.add(1); | ||
} | ||
decrement(counter: Counter) { | ||
counter.derive(['count']); | ||
counter.count = counter.count.sub(1); | ||
} | ||
} |