Skip to main content

ProgramClient

Trait ProgramClient 

Source
pub trait ProgramClient: Sized {
    const PROGRAM_ID: Pubkey;

    // Required methods
    fn build_client(
        program: Program<Arc<Keypair>>,
        keypair: Arc<Keypair>,
    ) -> Self;
    fn program(&self) -> &Program<Arc<Keypair>>;
    fn keypair(&self) -> Arc<Keypair>;

    // Provided methods
    fn new_from_keypair(
        cluster: Cluster,
        keypair: Keypair,
        config: CommitmentConfig,
    ) -> Result<Self> { ... }
    fn send_v0_transaction<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        instructions: &'life1 [Instruction],
        lookup_tables: &'life2 [AddressLookupTableAccount],
    ) -> Pin<Box<dyn Future<Output = Result<Signature>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn load_lst_registry<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(Vec<AccountMeta>, AddressLookupTableAccount)>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
    fn load_lookup_table<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 Pubkey,
    ) -> Pin<Box<dyn Future<Output = Result<AddressLookupTableAccount>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn load_multiple_lookup_tables<'life0, 'life1, 'async_trait>(
        &'life0 self,
        pubkeys: &'life1 [Pubkey],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<AddressLookupTableAccount>>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Abstracts the construction of client structs with anchor_client::Program.

Required Associated Constants§

Required Methods§

Source

fn build_client(program: Program<Arc<Keypair>>, keypair: Arc<Keypair>) -> Self

Source

fn program(&self) -> &Program<Arc<Keypair>>

Source

fn keypair(&self) -> Arc<Keypair>

Provided Methods§

Source

fn new_from_keypair( cluster: Cluster, keypair: Keypair, config: CommitmentConfig, ) -> Result<Self>

Constructs the given client with ID Self::PROGRAM_ID.

§Errors
  • Underlying Anchor program creation
Source

fn send_v0_transaction<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, instructions: &'life1 [Instruction], lookup_tables: &'life2 [AddressLookupTableAccount], ) -> Pin<Box<dyn Future<Output = Result<Signature>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Builds a versioned transaction from instructions and lookup tables.

§Errors
  • Failed to get the latest blockhash
  • Failed to compile the message
  • Failed to create the transaction
  • Failed to send the transaction
Source

fn load_lst_registry<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(Vec<AccountMeta>, AddressLookupTableAccount)>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Creates remaining_accounts array from LST registry table with all headers writable.

§Errors
  • Lookup table account doesn’t exist
  • Malformed structure (preamble cannot be split at 16)
Source

fn load_lookup_table<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 Pubkey, ) -> Pin<Box<dyn Future<Output = Result<AddressLookupTableAccount>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads an address lookup table by public key.

§Errors
  • Failed to fetch the account
  • Failed to deserialize account data
Source

fn load_multiple_lookup_tables<'life0, 'life1, 'async_trait>( &'life0 self, pubkeys: &'life1 [Pubkey], ) -> Pin<Box<dyn Future<Output = Result<Vec<AddressLookupTableAccount>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads address lookup tables at given addresses.

§Errors
  • Failed to fetch lookup table account
  • Failed to deserialize

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§