Skip to main content

TransferChecked

Struct TransferChecked 

Source
pub struct TransferChecked<'a> {
    pub from: &'a AccountView,
    pub mint: &'a AccountView,
    pub to: &'a AccountView,
    pub authority: &'a AccountView,
    pub amount: u64,
    pub decimals: u8,
}
Expand description

Builder for SPL Token TransferChecked (instruction index 12).

Adds mint + decimals validation over [Transfer]. Required for accounts that participate in Token-2022 extension flows.

Fields§

§from: &'a AccountView§mint: &'a AccountView§to: &'a AccountView§authority: &'a AccountView§amount: u64§decimals: u8

Implementations§

Source§

impl TransferChecked<'_>

Source

pub fn invoke(&self) -> ProgramResult

Invoke with a transaction-signed authority. Fails fast with MissingRequiredSignature before the CPI if the authority is not a signer.

Source

pub fn invoke_strict(&self) -> ProgramResult

Strict invoke: signer pre-check plus token-account ownership verification. Auto-injects the check that #[hopper::program(enforce_token_checks = true)] promises so a handler inside such a program can write TransferChecked { ... }.invoke_strict()? and know that the attacker-passes-correct-pubkey-but-wrong-signer exploit class is closed before the CPI.

Verifies self.from’s owner field (SPL TokenAccount bytes [32..64]) matches self.authority.address(). Returns ProgramError::IncorrectAuthority on mismatch.

Source

pub fn invoke_signed(&self, signers: &[Signer<'_, '_>]) -> ProgramResult

Invoke with explicit PDA signer seeds. The SPL token program validates mint + decimals regardless of the signer source.

Source

pub fn invoke_signed_strict(&self, signers: &[Signer<'_, '_>]) -> ProgramResult

Strict PDA-signed invoke: ownership pre-check (the SPL token program revalidates, but Hopper surfaces a branded error first) then CPI with the supplied signer seeds.

Auto Trait Implementations§

§

impl<'a> Freeze for TransferChecked<'a>

§

impl<'a> RefUnwindSafe for TransferChecked<'a>

§

impl<'a> Send for TransferChecked<'a>

§

impl<'a> Sync for TransferChecked<'a>

§

impl<'a> Unpin for TransferChecked<'a>

§

impl<'a> UnsafeUnpin for TransferChecked<'a>

§

impl<'a> UnwindSafe for TransferChecked<'a>

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, 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.