Skip to main content

willow_core/
lib.rs

1//! willow: A collection of utilities for building Solana programs with pinocchio
2//!
3//! This crate provides utilities for:
4//! - Account management with automatic serialization/deserialization
5//! - Context validation
6//! - Program Derived Address (PDA) creation
7//! - Associated Token Account (ATA) creation
8//!
9//! ## Example
10//!
11//! ```ignore
12//! use willow::prelude::*;
13//!
14//! #[derive(WillowAccount)]
15//! pub struct Vault {
16//!     pub owner: Pubkey,
17//!     pub total_assets: u64,
18//!     pub bump: u8,
19//! }
20//!
21//! impl Vault {
22//!     pub fn initialize(&mut self, owner: Pubkey, bump: u8) -> ProgramResult {
23//!         self.owner = owner;
24//!         self.total_assets = 0;
25//!         self.bump = bump;
26//!         Ok(())
27//!     }
28//! }
29//! ```
30
31pub mod account;
32pub mod context;
33pub mod pda;
34pub mod ata;
35pub mod cpi;
36pub mod prelude;
37pub mod serialization_tests;
38#[cfg(feature = "build")]
39pub mod build;
40
41#[macro_export]
42macro_rules! include_generated {
43    () => {
44        #[allow(dead_code)]
45        mod __willow_auto_pda {
46            include!(concat!(env!("OUT_DIR"), "/__willow_auto_pda.rs"));
47        }
48        #[allow(dead_code)]
49        mod __willow_args {
50            include!(concat!(env!("OUT_DIR"), "/__willow_args.rs"));
51        }
52    };
53}
54
55// Conditional compilation for derive macro
56#[cfg(feature = "derive")]
57pub use willow_derive::PinoAccount;
58#[cfg(feature = "derive")]
59pub use willow_derive::WillowAccount;
60#[cfg(feature = "derive")]
61pub use willow_derive::pino_account;
62#[cfg(feature = "derive")]
63pub use willow_derive::pino_instruction;
64#[cfg(feature = "derive")]
65pub use willow_derive::pino_accounts;
66#[cfg(feature = "derive")]
67pub use willow_derive::willow_account;
68#[cfg(feature = "derive")]
69pub use willow_derive::willow_instruction;
70#[cfg(feature = "derive")]
71pub use willow_derive::willow_accounts;
72#[cfg(feature = "derive")]
73pub use willow_derive::willow_cpi_args;
74
75// Re-export the PinoAccount trait and related items
76pub use account::{PinoAccount, WillowAccount, AccountInfoExt, SerializationHelper};
77pub use context::PinoContext;
78pub use ata::AtaBuilder;
79pub use account::{FixedString, FixedBytes};