Skip to main content

AdvancePlan

Struct AdvancePlan 

Source
pub struct AdvancePlan { /* private fields */ }
Expand description

Fully assembled but unsigned Advance instruction plan.

A plan owns the encoded CPI payload and passthrough account order, so callers cannot accidentally sign one account order and submit another.

Implementations§

Source§

impl AdvancePlan

Source

pub fn new( wallet_pda: &Address, new_root: &[u8; 32], inner_instructions: &[Instruction], ) -> Result<Self, Error>

Build an Advance plan from inner CPI instructions.

Source

pub fn wallet_pda(&self) -> &Address

Wallet PDA this plan targets.

Source

pub fn withdraw( wallet_pda: &Address, receiver: &Address, lamports: u64, new_root: &[u8; 32], ) -> Result<Self, Error>

Build a plan for the built-in lamport withdraw CPI.

Source

pub fn close( wallet_pda: &Address, receiver: &Address, new_root: &[u8; 32], ) -> Result<Self, Error>

Build a plan for the built-in close CPI, sweeping all lamports from the wallet PDA to receiver and tearing the account down.

Source

pub fn payload(&self) -> &[u8]

The raw Advance payload committed by the signature.

Source

pub fn passthrough_accounts(&self) -> &[AccountMeta]

Passthrough accounts in the exact order expected by the on-chain handler.

Source

pub fn account_addresses(&self) -> &[[u8; 32]]

Account addresses included in the Advance preimage.

Source

pub fn new_root(&self) -> &[u8; 32]

New root stored by the Advance instruction.

Source

pub fn preimage<'a>( &'a self, wallet_id: &'a [u8; 32], current_root: &'a [u8; 32], ) -> Vec<&'a [u8]>

Build the preimage parts to sign for this plan.

Source

pub fn instruction(&self, signature_bytes: &[u8; 768]) -> Instruction

Convert the plan into a signed Advance instruction.

Source

pub fn estimate_transaction_size( &self, payer: &Address, signature_bytes: &[u8; 768], ) -> Result<usize, Error>

Estimate the legacy transaction size with default Advance compute budget.

Source

pub fn validate_transaction_size( &self, payer: &Address, signature_bytes: &[u8; 768], ) -> Result<usize, Error>

Validate that the planned Advance fits in a legacy transaction.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.