Skip to main content

hopper_migrate

Attribute Macro hopper_migrate 

Source
#[hopper_migrate]
Expand description

Declare a schema-epoch migration edge.

Decorates a function of signature fn(&mut [u8]) -> Result<(), ProgramError> that mutates an account body in-place from schema epoch from to epoch to. The macro emits the fn unchanged plus a paired <FN_NAME>_EDGE: hopper_runtime::MigrationEdge constant so the layout author can compose edges via hopper::layout_migrations!.

Closes Hopper Safety Audit innovation I4 (“Schema epoch with in-place migration helpers”). Runtime chain application and atomic-per-edge schema_epoch bump live in hopper_runtime::migrate.

§Example

#[hopper::migrate(from = 1, to = 2)]
pub fn vault_v1_to_v2(body: &mut [u8]) -> ProgramResult {
    // Reinterpret bytes to match the epoch-2 shape.
    Ok(())
}