-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
solana: separate token accounts (#22)
Co-authored-by: A5 Pickle <a5-pickle@users.noreply.github.com>
- Loading branch information
Showing
65 changed files
with
6,217 additions
and
6,246 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
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,23 +1,41 @@ | ||
use crate::admin::OwnerAssistant; | ||
use anchor_lang::prelude::*; | ||
|
||
pub fn only_owner_assistant<A>(acct: &Account<A>, owner_assistant: &Pubkey) -> bool | ||
pub fn only_owner_assistant<A>( | ||
acct: &Account<A>, | ||
owner_assistant: &Signer, | ||
custom_error: Error, | ||
) -> Result<bool> | ||
where | ||
A: OwnerAssistant + Clone + AccountSerialize + AccountDeserialize, | ||
{ | ||
acct.owner_assistant() == owner_assistant | ||
if acct.owner_assistant() == &owner_assistant.key() { | ||
Ok(true) | ||
} else { | ||
Err(custom_error.with_pubkeys((*acct.owner_assistant(), owner_assistant.key()))) | ||
} | ||
} | ||
|
||
pub fn only_authorized<A>(acct: &Account<A>, owner_or_assistant: &Pubkey) -> bool | ||
pub fn only_authorized<A>( | ||
acct: &Account<A>, | ||
owner_or_assistant: &Signer, | ||
custom_error: Error, | ||
) -> Result<bool> | ||
where | ||
A: OwnerAssistant + Clone + AccountSerialize + AccountDeserialize, | ||
{ | ||
acct.owner() == owner_or_assistant || acct.owner_assistant() == owner_or_assistant | ||
if acct.owner() == &owner_or_assistant.key() | ||
|| acct.owner_assistant() == &owner_or_assistant.key() | ||
{ | ||
Ok(true) | ||
} else { | ||
Err(custom_error) | ||
} | ||
} | ||
|
||
pub fn transfer_owner_assistant<A>(acct: &mut Account<A>, new_assistant: &Pubkey) | ||
pub fn transfer_owner_assistant<A>(acct: &mut Account<A>, new_assistant: &AccountInfo) | ||
where | ||
A: OwnerAssistant + Clone + AccountSerialize + AccountDeserialize, | ||
{ | ||
*acct.owner_assistant_mut() = *new_assistant; | ||
*acct.owner_assistant_mut() = new_assistant.key(); | ||
} |
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,16 +1,20 @@ | ||
use crate::admin::Ownable; | ||
use anchor_lang::prelude::*; | ||
|
||
pub fn only_owner<A>(acct: &Account<A>, owner: &Pubkey) -> bool | ||
pub fn only_owner<A>(acct: &Account<A>, owner: &Signer, custom_error: Error) -> Result<bool> | ||
where | ||
A: Ownable + Clone + AccountSerialize + AccountDeserialize, | ||
{ | ||
*acct.owner() == *owner | ||
if acct.owner() == &owner.key() { | ||
Ok(true) | ||
} else { | ||
Err(custom_error.with_pubkeys((*acct.owner(), owner.key()))) | ||
} | ||
} | ||
|
||
pub fn transfer_ownership<A>(acct: &mut Account<A>, new_owner: &Pubkey) | ||
pub fn transfer_ownership<A>(acct: &mut Account<A>, new_owner: &AccountInfo) | ||
where | ||
A: Ownable + Clone + AccountSerialize + AccountDeserialize, | ||
{ | ||
*acct.owner_mut() = *new_owner; | ||
*acct.owner_mut() = new_owner.key(); | ||
} |
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.