Attribute Macro pbc_contract_codegen::zk_on_attestation_complete
source · #[zk_on_attestation_complete]
Expand description
Data-attestation complete zero-knowledge contract annotation
OPTIONAL HOOK: This is an optional hook, and is not required for a well-formed zero-knowledge contract. The default behaviour is to do nothing.
If the annotated function panics changes to the contract state will be rolled back.
Annotated function is automatically called when the contract is informed of the availability of
signatures for attested data. This can only happen after the use of
ZkStateChange::Attest
. This hook is
exclusively called by the blockchain itself, and cannot be called manually from the dashboard,
nor from another contract.
Allows the contract to automatically react to data-attestations.
Annotated function must have a signature of following format:
#[zk_on_attestation_complete]
pub fn zk_on_attestation_complete(
context: ContractContext,
state: ContractState,
zk_state: ZkState<Metadata>,
attestation_id: AttestationId,
) -> (ContractState, Vec<EventGroup>, Vec<ZkStateChange>)
Where ZkState
can be further accessed to determine signatures, etc.