pub use aluvm::stl::aluvm_stl;
use bitcoin::Txid;
use strict_types::stl::{bitcoin_stl, std_stl, strict_types_stl};
use strict_types::typelib::LibBuilder;
use strict_types::TypeLib;
use crate::commit_verify::{mpc, MerkleHash, MerkleNode, StrictHash, LIB_NAME_COMMIT_VERIFY};
use crate::dbc::{self, LIB_NAME_BPCORE};
use crate::txout::{self, TxPtr};
use crate::validation::DbcProof;
use crate::vm::GlobalOrd;
use crate::{
seals, BundleId, ContractId, Genesis, OpCommitment, Schema, TransitionBundle,
LIB_NAME_RGB_COMMIT, LIB_NAME_RGB_LOGIC,
};
pub const LIB_ID_COMMIT_VERIFY: &str =
"stl:scauscFb-HraEd6t-pq~qoBw-mBZNtjA-_4KqtNF-niQxr5Y#thermos-elastic-george";
pub const LIB_ID_BPCORE: &str =
"stl:FZVwlcEJ-p0LhCJg-CU6awvX-9RTo2ST-3G5hYEa-gEJCjUA#cigar-master-style";
pub const LIB_ID_RGB_COMMIT: &str =
"stl:fHPvkmm2-jnlIdf8-44fradm-~EbYYk2-OqkiKYl-Rohkac4#domain-numeric-actor";
pub const LIB_ID_RGB_LOGIC: &str =
"stl:dC6XWoqx-WCGR78B-~OSC3eP-Ux7Z4cZ-Xe4Re56-zJrwaDs#loyal-respect-tourist";
pub fn commit_verify_stl() -> TypeLib {
LibBuilder::with(libname!(LIB_NAME_COMMIT_VERIFY), [
strict_types::stl::std_stl().to_dependency_types()
])
.transpile::<MerkleHash>()
.transpile::<MerkleNode>()
.transpile::<StrictHash>()
.transpile::<mpc::Commitment>()
.transpile::<mpc::Leaf>()
.transpile::<mpc::MerkleBlock>()
.transpile::<mpc::MerkleConcealed>()
.transpile::<mpc::MerkleProof>()
.transpile::<mpc::MerkleTree>()
.compile()
.unwrap()
}
pub fn bp_core_stl() -> TypeLib {
LibBuilder::with(libname!(LIB_NAME_BPCORE), [
bitcoin_stl().to_dependency_types(),
commit_verify_stl().to_dependency_types(),
])
.transpile::<dbc::Anchor<dbc::opret::OpretProof>>()
.transpile::<dbc::Anchor<dbc::tapret::TapretProof>>()
.transpile::<seals::SecretSeal>()
.transpile::<txout::BlindSeal<TxPtr>>()
.transpile::<txout::BlindSeal<Txid>>()
.transpile::<txout::ExplicitSeal<TxPtr>>()
.transpile::<txout::ExplicitSeal<Txid>>()
.compile()
.unwrap()
}
pub fn rgb_commit_stl() -> TypeLib {
LibBuilder::with(libname!(LIB_NAME_RGB_COMMIT), [
std_stl().to_dependency_types(),
strict_types_stl().to_dependency_types(),
commit_verify_stl().to_dependency_types(),
bitcoin_stl().to_dependency_types(),
bp_core_stl().to_dependency_types(),
aluvm_stl().to_dependency_types(),
])
.transpile::<BundleId>()
.transpile::<Genesis>()
.transpile::<OpCommitment>()
.transpile::<Schema>()
.transpile::<TransitionBundle>()
.transpile::<Txid>()
.compile()
.unwrap()
}
pub fn rgb_contract_id_stl() -> TypeLib {
LibBuilder::with(libname!(LIB_NAME_RGB_COMMIT), [])
.transpile::<ContractId>()
.compile()
.unwrap()
}
pub fn rgb_logic_stl() -> TypeLib {
LibBuilder::with(libname!(LIB_NAME_RGB_LOGIC), [
bitcoin_stl().to_dependency_types(),
bp_core_stl().to_dependency_types(),
rgb_commit_stl().to_dependency_types(),
])
.transpile::<DbcProof>()
.transpile::<GlobalOrd>()
.compile()
.unwrap()
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn commit_verify_lib_id() {
let lib = commit_verify_stl();
assert_eq!(lib.id().to_string(), LIB_ID_COMMIT_VERIFY);
}
#[test]
fn bp_core_lib_id() {
let lib = bp_core_stl();
assert_eq!(lib.id().to_string(), LIB_ID_BPCORE);
}
#[test]
fn commit_lib_id() {
let lib = rgb_commit_stl();
assert_eq!(lib.id().to_string(), LIB_ID_RGB_COMMIT);
}
#[test]
fn logic_lib_id() {
let lib = rgb_logic_stl();
assert_eq!(lib.id().to_string(), LIB_ID_RGB_LOGIC);
}
}