Skip to content

Commit

Permalink
update favourite example
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrinathNR committed Nov 29, 2024
1 parent fb79d76 commit dab3fcc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions examples/favorites/rust/favorites.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anchor_lang::prelude::*;
declare_id!("11111111111111111111111111111111");
#[program]
pub mod testoor {
pub mod favorites_program {
use super::*;
pub fn set_favorites(
ctx: Context<SetFavoritesContext>,
Expand All @@ -17,8 +17,6 @@ pub mod testoor {
}
#[derive(Accounts)]
pub struct SetFavoritesContext<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(
init_if_needed,
payer = owner,
Expand All @@ -28,9 +26,10 @@ pub struct SetFavoritesContext<'info> {
bump,
)]
pub favorites: Account<'info, Favorites>,
#[account(mut)]
pub owner: Signer<'info>,
pub system_program: Program<'info, System>,
}

#[account]
pub struct Favorites {
pub number: u64,
Expand Down
12 changes: 6 additions & 6 deletions examples/favorites/typescript/favorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
u64,
Signer,
Vec,
String,
Str,
} from "@solanaturbine/poseidon";

export default class FavoritesProgram {
Expand All @@ -14,8 +14,8 @@ export default class FavoritesProgram {
setFavorites(
owner: Signer,
number: u64,
color: String<50>,
hobbies: Vec<String<50>, 5>,
color: Str<50>,
hobbies: Vec<Str<50>, 5>,
favorites: Favorites,
): Result {
favorites.derive(["favorites", owner.key]).initIfNeeded(owner);
Expand All @@ -28,6 +28,6 @@ export default class FavoritesProgram {

export interface Favorites extends Account {
number: u64;
color: String<50>;
hobbies: Vec<String<50>, 5>;
}
color: Str<50>;
hobbies: Vec<Str<50>, 5>;
}

0 comments on commit dab3fcc

Please sign in to comment.