pub fn require_token_authority(
token_account: &AccountView,
authority: &AccountView,
) -> ProgramResultExpand description
Verify an SPL Token account’s owner field matches authority.key().
SPL TokenAccount layout: bytes [32..64] are the owner pubkey
(the authority allowed to move tokens out of this account). The
SPL Token program checks this on every transfer/approve/burn, but
Hopper’s pre-check surfaces a Hopper-branded error before the CPI
so a misconfigured invocation fails with IncorrectAuthority
instead of an opaque CPI failure.
This is the load-bearing helper behind the
#[hopper::program(enforce_token_checks = true)] contract: the
macro emits HOPPER_PROGRAM_POLICY.enforce_token_checks = true,
and handlers opt into the strict invoke paths
(TransferChecked::invoke_strict etc.) to get this check
auto-injected. Handlers can also call it directly when they reach
outside the typed-context envelope.
Returns Err(ProgramError::AccountDataTooSmall) if the token
account’s data buffer is too short (not a valid SPL TokenAccount).