pub struct RegisteredAddress {
pub key: Pubkey,
pub role: AddressRole,
}Expand description
Registered address with role information
Fields§
§key: PubkeyThe address.
role: AddressRoleThe address’s function within the program.
Implementations§
Source§impl RegisteredAddress
impl RegisteredAddress
Sourcepub fn new(address: Pubkey, role: AddressRole) -> RegisteredAddress
pub fn new(address: Pubkey, role: AddressRole) -> RegisteredAddress
Creates a new registered address with the specified role
§Arguments
address- The public key to registerrole- The role that defines the address’s purpose
§Example
use anchor_lang::prelude::*;
use solana_address_book::{RegisteredAddress, AddressRole};
let address = Pubkey::new_unique();
let registered = RegisteredAddress::new(address, AddressRole::Wallet);Sourcepub fn wallet(address: Pubkey) -> RegisteredAddress
pub fn wallet(address: Pubkey) -> RegisteredAddress
Sourcepub fn mint(address: Pubkey) -> RegisteredAddress
pub fn mint(address: Pubkey) -> RegisteredAddress
Sourcepub fn ata(address: Pubkey, mint: Pubkey, owner: Pubkey) -> RegisteredAddress
pub fn ata(address: Pubkey, mint: Pubkey, owner: Pubkey) -> RegisteredAddress
Creates an Associated Token Account (ATA) registered address
§Arguments
address- The ATA’s public keymint- The token mint public keyowner- The owner’s public key
§Example
use anchor_lang::prelude::*;
use solana_address_book::RegisteredAddress;
let ata = Pubkey::new_unique();
let mint = Pubkey::new_unique();
let owner = Pubkey::new_unique();
let registered = RegisteredAddress::ata(ata, mint, owner);Sourcepub fn custom(address: Pubkey, custom_role: &str) -> RegisteredAddress
pub fn custom(address: Pubkey, custom_role: &str) -> RegisteredAddress
Creates a custom-role registered address
§Arguments
address- The address’s public keycustom_role- A custom string describing the address’s role
§Example
use anchor_lang::prelude::*;
use solana_address_book::RegisteredAddress;
let address = Pubkey::new_unique();
let registered = RegisteredAddress::custom(address, "governance");Sourcepub fn program(address: Pubkey) -> RegisteredAddress
pub fn program(address: Pubkey) -> RegisteredAddress
Sourcepub fn pda(
seeds: &[&[u8]],
program_id: &Pubkey,
) -> (Pubkey, u8, RegisteredAddress)
pub fn pda( seeds: &[&[u8]], program_id: &Pubkey, ) -> (Pubkey, u8, RegisteredAddress)
Creates a PDA registered address by finding the program address
§Arguments
seeds- The seeds used to derive the PDAprogram_id- The program that owns the PDA
§Returns
A tuple containing:
- The derived PDA public key
- The bump seed
- The registered address
§Example
use anchor_lang::prelude::*;
use solana_address_book::RegisteredAddress;
let program_id = Pubkey::new_unique();
let user = Pubkey::new_unique();
let (pda_key, bump, registered) = RegisteredAddress::pda(&[b"vault", user.as_ref()], &program_id);Sourcepub fn pda_from_parts(
pubkey: Pubkey,
seeds: Vec<String>,
program_id: Pubkey,
bump: u8,
) -> RegisteredAddress
pub fn pda_from_parts( pubkey: Pubkey, seeds: Vec<String>, program_id: Pubkey, bump: u8, ) -> RegisteredAddress
Creates a PDA registered address from existing PDA information
§Arguments
pubkey- The PDA’s public keyseeds- The string representations of seeds usedprogram_id- The program that owns the PDAbump- The bump seed
§Example
use anchor_lang::prelude::*;
use solana_address_book::RegisteredAddress;
let pda = Pubkey::new_unique();
let program_id = Pubkey::new_unique();
let seeds = vec!["vault".to_string(), "v1".to_string()];
let registered = RegisteredAddress::pda_from_parts(pda, seeds, program_id, 255);Trait Implementations§
Source§impl Clone for RegisteredAddress
impl Clone for RegisteredAddress
Source§fn clone(&self) -> RegisteredAddress
fn clone(&self) -> RegisteredAddress
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RegisteredAddress
impl Debug for RegisteredAddress
Source§impl Display for RegisteredAddress
impl Display for RegisteredAddress
Source§impl Hash for RegisteredAddress
impl Hash for RegisteredAddress
Source§impl PartialEq for RegisteredAddress
impl PartialEq for RegisteredAddress
impl Eq for RegisteredAddress
impl StructuralPartialEq for RegisteredAddress
Auto Trait Implementations§
impl Freeze for RegisteredAddress
impl RefUnwindSafe for RegisteredAddress
impl Send for RegisteredAddress
impl Sync for RegisteredAddress
impl Unpin for RegisteredAddress
impl UnwindSafe for RegisteredAddress
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more