-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from LNP-BP/stl
Strict type library updates
- Loading branch information
Showing
24 changed files
with
171 additions
and
148 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,67 +12,23 @@ | |
// You should have received a copy of the Apache 2.0 License along with this | ||
// software. If not, see <https://opensource.org/licenses/Apache-2.0>. | ||
|
||
#[macro_use] | ||
extern crate amplify; | ||
#[macro_use] | ||
extern crate strict_types; | ||
use commit_verify::stl; | ||
use strict_types::typelib::parse_args; | ||
|
||
use std::io::stdout; | ||
use std::{env, fs, io}; | ||
|
||
use amplify::num::u24; | ||
use commit_verify::{mpc, LIB_NAME_COMMIT_VERIFY}; | ||
use strict_encoding::{StrictEncode, StrictWriter}; | ||
use strict_types::typelib::LibBuilder; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let args: Vec<String> = env::args().collect(); | ||
|
||
let lib = LibBuilder::new(libname!(LIB_NAME_COMMIT_VERIFY)) | ||
.process::<mpc::MerkleTree>()? | ||
.process::<mpc::MerkleBlock>()? | ||
.process::<mpc::MerkleProof>()? | ||
.compile(none!())?; | ||
let id = lib.id(); | ||
|
||
let ext = match args.get(1).map(String::as_str) { | ||
Some("--stl") => "stl", | ||
Some("--asc") => "asc.stl", | ||
Some("--sty") => "sty", | ||
_ => "sty", | ||
}; | ||
let filename = args | ||
.get(2) | ||
.cloned() | ||
.unwrap_or_else(|| format!("stl/CommitVerify.{ext}")); | ||
let mut file = match args.len() { | ||
1 => Box::new(stdout()) as Box<dyn io::Write>, | ||
2 | 3 => Box::new(fs::File::create(filename)?) as Box<dyn io::Write>, | ||
_ => panic!("invalid argument count"), | ||
}; | ||
match ext { | ||
"stl" => { | ||
lib.strict_encode(StrictWriter::with(u24::MAX.into_usize(), file))?; | ||
} | ||
"asc.stl" => { | ||
writeln!(file, "{lib:X}")?; | ||
} | ||
_ => { | ||
writeln!( | ||
file, | ||
"{{- | ||
Id: {id:+} | ||
Name: CommitVerify | ||
Description: Types for client-side-validation commits and verification | ||
fn main() { | ||
let lib = stl::commit_verify_stl(); | ||
let (format, dir) = parse_args(); | ||
lib.serialize( | ||
format, | ||
dir, | ||
"0.1.0", | ||
Some( | ||
" | ||
Description: Client-side-validation deterministic commitments | ||
Author: Dr Maxim Orlovsky <[email protected]> | ||
Copyright (C) 2023 LNP/BP Standards Association. All rights reserved. | ||
License: Apache-2.0 | ||
-}} | ||
" | ||
)?; | ||
writeln!(file, "{lib}")?; | ||
} | ||
} | ||
|
||
Ok(()) | ||
License: Apache-2.0", | ||
), | ||
) | ||
.expect("unable to write to the file"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.