-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement profile delete functionality
- Loading branch information
Showing
23 changed files
with
429 additions
and
29 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
42 changes: 42 additions & 0 deletions
42
anchor/programs/pubkey-protocol/src/instructions/profile/profile_delete.rs
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use anchor_lang::prelude::*; | ||
|
||
use crate::constants::*; | ||
use crate::errors::*; | ||
use crate::state::*; | ||
|
||
#[derive(Accounts)] | ||
#[instruction()] | ||
pub struct ProfileDelete<'info> { | ||
#[account( | ||
mut, | ||
seeds = [ | ||
PREFIX, | ||
PROFILE, | ||
&profile.username.as_bytes() | ||
], | ||
bump = profile.bump, | ||
constraint = profile.check_if_deletable(&authority.key()) @ ProtocolError::UnableToDeleteProfile, | ||
close = fee_payer, // close account and return lamports to payer | ||
)] | ||
pub profile: Account<'info, Profile>, | ||
#[account( | ||
mut, | ||
seeds = [&Pointer::hash_seed(&IdentityProvider::Solana, &authority.key().to_string())], | ||
bump = pointer.bump, | ||
has_one = profile @ ProtocolError::UnAuthorized, | ||
close = fee_payer | ||
)] | ||
pub pointer: Account<'info, Pointer>, | ||
pub authority: Signer<'info>, | ||
pub community: Account<'info, Community>, | ||
|
||
#[account( | ||
mut, | ||
constraint = community.check_for_signer(&fee_payer.key()) @ ProtocolError::UnAuthorizedCommunitySigner, | ||
)] | ||
pub fee_payer: Signer<'info>, | ||
} | ||
|
||
pub fn profile_delete(_ctx: Context<ProfileDelete>) -> Result<()> { | ||
Ok(()) | ||
} |
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
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
Oops, something went wrong.