You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: basics/close-account/anchor/README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
# Close Account
2
2
3
-
Two [instruction handlers](https://solana.com/docs/terminology#instruction-handler): `create_user` initializes a [PDA](https://solana.com/docs/terminology#program-derived-address-pda)`UserState`[account](https://solana.com/docs/terminology#account), and `close_user` closes it and returns the [rent](https://solana.com/docs/terminology#rent) to the user.
3
+
Two [instruction handlers](https://solana.com/docs/terminology#instruction-handler): `create_user` initializes a [PDA](https://solana.com/docs/terminology#program-derived-address-pda)`User`[account](https://solana.com/docs/terminology#account), and `close_user` closes it and returns the [rent](https://solana.com/docs/terminology#rent) to the user.
4
4
5
5
1.`create_user` initializes the PDA with [Anchor](https://solana.com/docs/terminology#anchor)'s `init` constraint:
6
6
7
7
```rust
8
8
#[account(
9
9
init,
10
10
payer = user,
11
-
space =UserState::DISCRIMINATOR.len() +UserState::INIT_SPACE,
11
+
space =User::DISCRIMINATOR.len() +User::INIT_SPACE,
12
12
seeds = [b"USER", user.key().as_ref()],
13
13
bump,
14
14
)]
15
-
pubuser_account:Account<'info, UserState>,
15
+
pubuser_account:Account<'info, User>,
16
16
```
17
17
18
18
See [`programs/close-account/src/instructions/create_user.rs`](programs/close-account/src/instructions/create_user.rs).
@@ -26,7 +26,7 @@ Two [instruction handlers](https://solana.com/docs/terminology#instruction-handl
26
26
bump=user_account.bump,
27
27
close=user, // close account and return lamports to user
28
28
)]
29
-
pubuser_account:Account<'info, UserState>,
29
+
pubuser_account:Account<'info, User>,
30
30
```
31
31
32
32
See [`programs/close-account/src/instructions/close_user.rs`](programs/close-account/src/instructions/close_user.rs).
0 commit comments