transcribed the full hsa and hsa finalizer api