mod bytes;
mod serialize;
mod string;
mod to_bits;
use snarkvm_console_network::prelude::*;
use snarkvm_console_types::Field;
const TRANSITION_LEAF_VERSION: u8 = 1u8;
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct TransitionLeaf<N: Network> {
version: u8,
index: u8,
variant: u8,
id: Field<N>,
}
impl<N: Network> TransitionLeaf<N> {
pub const fn new_with_version(index: u8, variant: u8, id: Field<N>) -> Self {
Self { version: TRANSITION_LEAF_VERSION, index, variant, id }
}
pub const fn from(version: u8, index: u8, variant: u8, id: Field<N>) -> Self {
Self { version, index, variant, id }
}
pub const fn version(&self) -> u8 {
self.version
}
pub const fn index(&self) -> u8 {
self.index
}
pub const fn variant(&self) -> u8 {
self.variant
}
pub const fn id(&self) -> Field<N> {
self.id
}
}
#[cfg(test)]
mod test_helpers {
use super::*;
use snarkvm_console_network::MainnetV0;
type CurrentNetwork = MainnetV0;
pub(super) fn sample_leaf(rng: &mut TestRng) -> TransitionLeaf<CurrentNetwork> {
TransitionLeaf::new_with_version(rng.gen(), rng.gen(), Uniform::rand(rng))
}
}