mod bytes;
mod serialize;
mod string;
mod to_bits;
use console::{
network::prelude::*,
program::{Identifier, ProgramID},
types::Field,
};
#[derive(Clone, PartialEq, Eq)]
pub struct TransactionLeaf<N: Network> {
variant: u8,
index: u16,
program_id: ProgramID<N>,
function_name: Identifier<N>,
id: Field<N>,
}
impl<N: Network> TransactionLeaf<N> {
pub const fn new(
variant: u8,
index: u16,
program_id: ProgramID<N>,
function_name: Identifier<N>,
id: Field<N>,
) -> Self {
Self { variant, index, program_id, function_name, id }
}
pub const fn variant(&self) -> u8 {
self.variant
}
pub const fn index(&self) -> u16 {
self.index
}
pub const fn program_id(&self) -> ProgramID<N> {
self.program_id
}
pub const fn function_name(&self) -> Identifier<N> {
self.function_name
}
pub const fn id(&self) -> Field<N> {
self.id
}
}
#[cfg(test)]
mod test_helpers {
use super::*;
use console::network::Testnet3;
type CurrentNetwork = Testnet3;
pub(super) fn sample_leaf() -> TransactionLeaf<CurrentNetwork> {
let rng = &mut test_crypto_rng();
TransactionLeaf::new(
rng.gen(),
rng.gen(),
FromStr::from_str("hello.aleo").unwrap(),
FromStr::from_str("runner").unwrap(),
Uniform::rand(rng),
)
}
}