mod bytes;
mod serialize;
mod string;
mod to_bits;
use snarkvm_console_network::prelude::*;
use snarkvm_console_types::Field;
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct TransactionLeaf<N: Network> {
variant: u8,
index: u16,
id: Field<N>,
}
impl<N: Network> TransactionLeaf<N> {
pub const fn new_deployment(index: u16, id: Field<N>) -> Self {
Self { variant: 0, index, id }
}
pub const fn new_execution(index: u16, id: Field<N>) -> Self {
Self { variant: 1, index, id }
}
pub const fn new_fee(index: u16, id: Field<N>) -> Self {
Self { variant: 1, index, id }
}
pub const fn from(variant: u8, index: u16, id: Field<N>) -> Self {
Self { variant, index, id }
}
pub const fn variant(&self) -> u8 {
self.variant
}
pub const fn index(&self) -> u16 {
self.index
}
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) -> TransactionLeaf<CurrentNetwork> {
TransactionLeaf::from(rng.r#gen(), rng.r#gen(), Uniform::rand(rng))
}
}