|
12 | 12 | // You should have received a copy of the Apache 2.0 License along with this |
13 | 13 | // software. If not, see <https://opensource.org/licenses/Apache-2.0>. |
14 | 14 |
|
15 | | -#[macro_use] |
16 | | -extern crate amplify; |
17 | | -#[macro_use] |
18 | | -extern crate strict_types; |
| 15 | +use commit_verify::stl; |
| 16 | +use strict_types::typelib::parse_args; |
19 | 17 |
|
20 | | -use std::io::stdout; |
21 | | -use std::{env, fs, io}; |
22 | | - |
23 | | -use amplify::num::u24; |
24 | | -use commit_verify::{mpc, LIB_NAME_COMMIT_VERIFY}; |
25 | | -use strict_encoding::{StrictEncode, StrictWriter}; |
26 | | -use strict_types::typelib::LibBuilder; |
27 | | - |
28 | | -fn main() -> Result<(), Box<dyn std::error::Error>> { |
29 | | - let args: Vec<String> = env::args().collect(); |
30 | | - |
31 | | - let lib = LibBuilder::new(libname!(LIB_NAME_COMMIT_VERIFY)) |
32 | | - .process::<mpc::MerkleTree>()? |
33 | | - .process::<mpc::MerkleBlock>()? |
34 | | - .process::<mpc::MerkleProof>()? |
35 | | - .compile(none!())?; |
36 | | - let id = lib.id(); |
37 | | - |
38 | | - let ext = match args.get(1).map(String::as_str) { |
39 | | - Some("--stl") => "stl", |
40 | | - Some("--asc") => "asc.stl", |
41 | | - Some("--sty") => "sty", |
42 | | - _ => "sty", |
43 | | - }; |
44 | | - let filename = args |
45 | | - .get(2) |
46 | | - .cloned() |
47 | | - .unwrap_or_else(|| format!("stl/CommitVerify.{ext}")); |
48 | | - let mut file = match args.len() { |
49 | | - 1 => Box::new(stdout()) as Box<dyn io::Write>, |
50 | | - 2 | 3 => Box::new(fs::File::create(filename)?) as Box<dyn io::Write>, |
51 | | - _ => panic!("invalid argument count"), |
52 | | - }; |
53 | | - match ext { |
54 | | - "stl" => { |
55 | | - lib.strict_encode(StrictWriter::with(u24::MAX.into_usize(), file))?; |
56 | | - } |
57 | | - "asc.stl" => { |
58 | | - writeln!(file, "{lib:X}")?; |
59 | | - } |
60 | | - _ => { |
61 | | - writeln!( |
62 | | - file, |
63 | | - "{{- |
64 | | - Id: {id:+} |
65 | | - Name: CommitVerify |
66 | | - Description: Types for client-side-validation commits and verification |
| 18 | +fn main() { |
| 19 | + let lib = stl::commit_verify_stl(); |
| 20 | + let (format, dir) = parse_args(); |
| 21 | + lib.serialize( |
| 22 | + format, |
| 23 | + dir, |
| 24 | + "0.1.0", |
| 25 | + Some( |
| 26 | + " |
| 27 | + Description: Client-side-validation deterministic commitments |
67 | 28 | Author: Dr Maxim Orlovsky <[email protected]> |
68 | 29 | Copyright (C) 2023 LNP/BP Standards Association. All rights reserved. |
69 | | - License: Apache-2.0 |
70 | | --}} |
71 | | -" |
72 | | - )?; |
73 | | - writeln!(file, "{lib}")?; |
74 | | - } |
75 | | - } |
76 | | - |
77 | | - Ok(()) |
| 30 | + License: Apache-2.0", |
| 31 | + ), |
| 32 | + ) |
| 33 | + .expect("unable to write to the file"); |
78 | 34 | } |
0 commit comments