Skip to main content

hopper_core/accounts/
validate.rs

1//! Standalone validation helpers for the Account DSL.
2//!
3//! These complement the existing `check` module with hopper-native-native
4//! signatures matching the Account DSL's conventions.
5
6use hopper_runtime::error::ProgramError;
7use hopper_runtime::{AccountView, Address};
8
9/// Require that the account is a signer.
10#[inline]
11pub fn require_signer(account: &AccountView) -> Result<(), ProgramError> {
12    crate::check::check_signer(account)
13}
14
15/// Require that the account is writable.
16#[inline]
17pub fn require_writable(account: &AccountView) -> Result<(), ProgramError> {
18    crate::check::check_writable(account)
19}
20
21/// Require that the account is owned by the given address.
22#[inline]
23pub fn require_owner(account: &AccountView, owner: &Address) -> Result<(), ProgramError> {
24    crate::check::check_owner(account, owner)
25}
26
27/// Require that the account is executable (for program references).
28#[inline]
29pub fn require_executable(account: &AccountView) -> Result<(), ProgramError> {
30    crate::check::check_executable(account)
31}
32
33/// Verify a PDA matches expected seeds + bump + program.
34#[inline]
35pub fn require_pda(
36    account: &AccountView,
37    seeds: &[&[u8]],
38    bump: u8,
39    program_id: &Address,
40) -> Result<(), ProgramError> {
41    crate::check::verify_pda(account, seeds, bump, program_id)
42}