Skip to main content

Module dyn_cpi

Module dyn_cpi 

Source
Expand description

Stack-allocated variable-length CPI builder.

The hopper_runtime::cpi::invoke_signed::<N> family is const-generic over the account count and serves CPI shapes known at compile time. DynCpi covers shapes whose account count or data length is determined while the instruction is being built, including:

  • Aggregators that invoke the same program with a runtime- decided account count (fanout fee routers, batch settlement cranks).
  • Forwarders that pass through the caller’s remaining accounts after splicing in a known prefix.
  • Generic instruction builders that construct the data buffer byte-by-byte from user input (priority-fee overrides, optional bump seeds) and do not know the final length until build time.

The builder has compile-time capacities, MAX_ACCTS and MAX_DATA, and stores both buffers inline. DynCpi::push_account and DynCpi::push_data return ProgramError::InvalidArgument before a write that would exceed those capacities. Account insertion preserves the ordered meta list while maintaining a pubkey-deduplicated account-info projection. DynCpi::invoke_signed accepts Hopper’s typed Signer values for PDA signer seeds.

Structs§

DynCpi
Variable-length CPI builder with compile-time stack capacity.