Skip to content

Commit d3734fe

Browse files
author
adpthegreat
committed
updated close account program change name to userId
1 parent d5a9036 commit d3734fe

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

basics/close-account/poseidon/close_account_program/programs/close_account_program/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ declare_id!("2q4uoWExFAbZjeDe4n3miipsT9bX9vLnkSetCfZYF2VT");
33
#[program]
44
pub mod close_account {
55
use super::*;
6-
pub fn create_user(ctx: Context<CreateUserContext>, name: u8) -> Result<()> {
6+
pub fn create_user(ctx: Context<CreateUserContext>, name: u32) -> Result<()> {
77
ctx.accounts.user_account.user_bump = ctx.bumps.user_account;
88
ctx.accounts.user_account.user = ctx.accounts.user.key();
99
ctx.accounts.user_account.name = name;
@@ -39,6 +39,6 @@ pub struct CloseUserContext<'info> {
3939
#[account]
4040
pub struct UserAccount {
4141
pub user_bump: u8,
42-
pub name: u8,
42+
pub name: u32,
4343
pub user: Pubkey,
4444
}

basics/close-account/poseidon/close_account_program/tests/bankrun.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ describe("Close an account", async () => {
2727
);
2828

2929
it("Can create an account", async () => {
30+
const userId = anchor.BN(76362)
3031
await program.methods
31-
.createUser("John Doe")
32+
.createUser(userId)
3233
.accounts({
3334
user: payer.publicKey,
3435
})

basics/close-account/poseidon/close_account_program/tests/close_account_program.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ describe("Close an account", () => {
1919
);
2020

2121
it("can create an account", async () => {
22+
const userId = anchor.BN(76362)
23+
2224
await program.methods
23-
.createUser("John Doe")
25+
.createUser(userId)
2426
.accounts({
2527
user: payer.publicKey,
2628
})
@@ -38,7 +40,6 @@ describe("Close an account", () => {
3840
.closeUser()
3941
.accounts({
4042
user: payer.publicKey
41-
// userAccount: userAccountAddress,
4243
})
4344
.rpc();
4445

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { Account, Pubkey, Result, u8, Signer } from "@solanaturbine/poseidon";
1+
import { Account, Pubkey, Result, u8, Signer, u32 } from "@solanaturbine/poseidon";
22

33
export default class CloseAccount {
44
static PROGRAM_ID = new Pubkey(
55
"2q4uoWExFAbZjeDe4n3miipsT9bX9vLnkSetCfZYF2VT"
66
);
77

8-
createUser(user: Signer, userAccount: UserAccount, name: u8): Result {
8+
createUser(user: Signer, userAccount: UserAccount, userId: u32): Result {
99
userAccount.derive(["USER", user.key]).init();
1010

1111
userAccount.userBump = userAccount.getBump();
1212

1313
userAccount.user = user.key;
1414

15-
userAccount.name = name;
15+
userAccount.userId = userId;
1616
}
1717
closeUser(userAccount: UserAccount, user: Signer): Result {
1818
userAccount.derive(["USER", user.key]).close(user);
@@ -21,6 +21,6 @@ export default class CloseAccount {
2121

2222
export interface UserAccount extends Account {
2323
userBump: u8;
24-
name: u8;
24+
userId: u32;
2525
user: Pubkey;
2626
}

0 commit comments

Comments
 (0)