pub struct MintPlan<'a> { /* private fields */ }Expand description
Validated, allocation-free mint creation plan.
new rejects duplicate extensions, invalid nullable addresses and fee rates,
and extensions on the legacy program. space includes Token-2022 padding
and TLV headers. There is no arbitrary spare capacity: Token-2022 requires
the allocation to equal the initialized extension set’s canonical size.
Implementations§
Source§impl<'a> MintPlan<'a>
impl<'a> MintPlan<'a>
pub fn new( program: MintProgram, config: MintConfig<'a>, extensions: &'a [MintExtension<'a>], ) -> Result<Self, ProgramError>
pub const fn space(&self) -> usize
Sourcepub fn check_space(&self, space: usize) -> ProgramResult
pub fn check_space(&self, space: usize) -> ProgramResult
Check an explicitly supplied allocation before paying rent or invoking CPI.
Sourcepub fn initialize(&self, mint: &AccountView<'_>) -> ProgramResult
pub fn initialize(&self, mint: &AccountView<'_>) -> ProgramResult
Initialize an already allocated, rent-exempt, entirely zeroed mint. Include the selected executable token program in the outer instruction. Propagate errors: if a later CPI fails, the enclosing instruction must fail to roll back earlier extension initialization.
Sourcepub fn create(
&self,
payer: &AccountView<'_>,
mint: &AccountView<'_>,
signers: &[Signer<'_, '_>],
) -> ProgramResult
pub fn create( &self, payer: &AccountView<'_>, mint: &AccountView<'_>, signers: &[Signer<'_, '_>], ) -> ProgramResult
Allocate a fresh System-owned mint, initialize extensions, then the base mint. Prefunding is supported; only the live rent shortfall is charged.
Include the System and selected token programs in the outer instruction.
The mint and payer must sign, directly or through signers. As with any
sequence of CPIs, propagate errors to preserve transaction atomicity.
Uses System CreateAccountAllowPrefund; the target cluster must enable it.