-
Notifications
You must be signed in to change notification settings - Fork 362
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
1 parent
c7d9c92
commit 699b6be
Showing
3 changed files
with
107 additions
and
105 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
32 changes: 16 additions & 16 deletions
32
basics/close-account/poseidon/ts-programs/src/closeAccountProgram.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,30 +1,30 @@ | ||
import { Account, Pubkey, Result, u8, Signer } from "@solanaturbine/poseidon"; | ||
|
||
export default class closeAccountProgram { | ||
static PROGRAM_ID = new Pubkey( | ||
"7U4SZvsUMjGYCwnzqGGE9enJactKhVPF2EaE7VHtBLTd", | ||
); | ||
static PROGRAM_ID = new Pubkey( | ||
"7U4SZvsUMjGYCwnzqGGE9enJactKhVPF2EaE7VHtBLTd" | ||
); | ||
|
||
// create user account | ||
// create user account | ||
|
||
create_user(user_account: closeAccountState, user: Signer): Result { | ||
user_account.derive(["user", user.key]).init(); | ||
create_user(user_account: closeAccountState, user: Signer): Result { | ||
user_account.derive(["user", user.key]).init(); | ||
|
||
// Set the initial value to the `user_account` fields | ||
user_account.user = user.key; | ||
user_account.bump = user_account.getBump(); | ||
} | ||
// Set the initial value to the `user_account` fields | ||
user_account.user = user.key; | ||
user_account.bump = user_account.getBump(); | ||
} | ||
|
||
// close user account | ||
// close user account | ||
|
||
close_user(user_account: closeAccountState, user: Signer): Result { | ||
user_account.close(user); | ||
} | ||
close_user(user_account: closeAccountState, user: Signer): Result { | ||
user_account.close(user); | ||
} | ||
} | ||
|
||
// setup the state | ||
|
||
export interface closeAccountState extends Account { | ||
user: Pubkey; // This field store the user pub key | ||
bump: u8; // bump is for PDA (program derieved account, a special type of account which controlled by program on Solana) | ||
user: Pubkey; // This field store the user pub key | ||
bump: u8; // bump is for PDA (program derieved account, a special type of account which controlled by program on Solana) | ||
} |