bp/stl.rs
1// Bitcoin protocol core library.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Written in 2019-2024 by
6// Dr Maxim Orlovsky <orlovsky@lnp-bp.org>
7//
8// Copyright (C) 2019-2024 LNP/BP Standards Association. All rights reserved.
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21
22//! Strict types library generator methods.
23
24use dbc::LIB_NAME_BPCORE;
25use strict_types::{CompileError, LibBuilder, TypeLib};
26
27/// Strict types id for the library providing data types from [`dbc`] and
28/// [`seals`] crates.
29pub const LIB_ID_BPCORE: &str =
30 "stl:nvSE47Z1-CpbRP8D-m2tdzo3-zmE6UE9-kU~HJm~-0pTqlGo#lagoon-concept-trade";
31
32#[allow(clippy::result_large_err)]
33fn _bp_core_stl() -> Result<TypeLib, CompileError> {
34 LibBuilder::with(libname!(LIB_NAME_BPCORE), [
35 strict_types::stl::std_stl().to_dependency_types(),
36 bc::stl::bp_consensus_stl().to_dependency_types(),
37 commit_verify::stl::commit_verify_stl().to_dependency_types(),
38 ])
39 .transpile::<seals::TxoSeal>()
40 .transpile::<seals::WTxoSeal>()
41 .transpile::<seals::Anchor>()
42 .transpile::<seals::mpc::Source>()
43 .compile()
44}
45
46/// Generates strict type library providing data types from [`dbc`] and
47/// [`seals`] crates.
48pub fn bp_core_stl() -> TypeLib { _bp_core_stl().expect("invalid strict type BPCore library") }
49
50#[cfg(test)]
51mod test {
52 #![cfg_attr(coverage_nightly, coverage(off))]
53
54 use super::*;
55
56 #[test]
57 fn lib_id() {
58 let lib = bp_core_stl();
59 assert_eq!(lib.id().to_string(), LIB_ID_BPCORE);
60 }
61}