-
Notifications
You must be signed in to change notification settings - Fork 300
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
Showing
3 changed files
with
54 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,42 @@ | ||
import { Account, Pubkey, Signer, u64, type Result } from "@solanaturbine/poseidon"; | ||
|
||
import { Account, Pubkey, type Result, Signer, u64 } from '@solanaturbine/poseidon'; | ||
|
||
export default class Counter { | ||
static PROGRAM_ID = new Pubkey("GnL9WWgvnFbhvNedx6LTdPt4QeWXM4XdAtnRE4uToXdV"); | ||
static PROGRAM_ID = new Pubkey('GnL9WWgvnFbhvNedx6LTdPt4QeWXM4XdAtnRE4uToXdV'); | ||
|
||
// Initialize Counter instruction | ||
initializeCounter( | ||
// ACCOUNTS | ||
// Initialize Counter instruction | ||
initializeCounter( | ||
// ACCOUNTS | ||
|
||
payer: Signer, // user paying for the counter account creation | ||
counter: CounterAccount, | ||
): Result { | ||
// CONTEXT | ||
payer: Signer, // user paying for the counter account creation | ||
counter: CounterAccount, | ||
): Result { | ||
// CONTEXT | ||
|
||
// .derive([<seeds>]) ensures that account is a PDA with the <seeds> as the parameters | ||
// .init() ensures that the account will have the init constraint when transpiled | ||
counter.derive(["counter"]).init(); | ||
// .derive([<seeds>]) ensures that account is a PDA with the <seeds> as the parameters | ||
// .init() ensures that the account will have the init constraint when transpiled | ||
counter.derive(['counter']).init(); | ||
|
||
// Assign the initial value of the counter to 0 | ||
counter.count = new u64(0); | ||
} | ||
// Assign the initial value of the counter to 0 | ||
counter.count = new u64(0); | ||
} | ||
|
||
// Increment Counter Instruction | ||
incrementCounter( | ||
// ACCOUNTS | ||
// Increment Counter Instruction | ||
incrementCounter( | ||
// ACCOUNTS | ||
|
||
payer: Signer, // user payingfor incrementing the counter account | ||
counter: CounterAccount, | ||
): Result { | ||
// CONTEXT | ||
payer: Signer, // user payingfor incrementing the counter account | ||
counter: CounterAccount, | ||
): Result { | ||
// CONTEXT | ||
|
||
counter.derive(["counter"]); | ||
counter.derive(['counter']); | ||
|
||
// Increment the counter by 1 | ||
counter.count = counter.count.add(1); | ||
} | ||
// Increment the counter by 1 | ||
counter.count = counter.count.add(1); | ||
} | ||
} | ||
|
||
// STATE | ||
export interface CounterAccount extends Account { | ||
count: u64 | ||
} | ||
count: u64; | ||
} |