#![cfg_attr(not(feature = "host"), no_std)]
#![deny(missing_docs)]
#![deny(clippy::all)]
#![feature(const_fn_floating_point_arithmetic)]
#[cfg(all(feature = "host", feature = "abi"))]
compile_error!("features \"host\" and \"abi\" are mutually exclusive");
extern crate alloc;
mod types;
pub use types::*;
mod abi;
pub use abi::*;
#[cfg(feature = "host")]
mod host;
#[cfg(feature = "host")]
pub use host::*;
pub mod dusk;
#[doc(hidden)]
pub mod hash;
use hash::Hasher;
pub use piecrust_uplink::*;
use dusk_bls12_381::BlsScalar;
use dusk_bytes::DeserializableSlice;
pub const POSEIDON_TREE_DEPTH: usize = 17;
pub const TRANSCRIPT_LABEL: &[u8] = b"dusk-network";
pub const TRANSFER_CONTRACT: ContractId = reserved(0x1);
pub const STAKE_CONTRACT: ContractId = reserved(0x2);
pub const LICENSE_CONTRACT: ContractId = reserved(0x3);
#[inline]
const fn reserved(b: u8) -> ContractId {
let mut bytes = [0u8; CONTRACT_ID_BYTES];
bytes[0] = b;
ContractId::from_bytes(bytes)
}
pub fn gen_contract_id(bytes: &[u8]) -> ContractId {
let mut hasher = Hasher::new();
hasher.update(bytes);
ContractId::from_bytes(hasher.output())
}
pub fn contract_to_scalar(module_id: &ContractId) -> BlsScalar {
BlsScalar::from_slice(module_id.as_bytes())
.expect("Something went REALLY wrong if a contract id is not a scalar")
}