@@ -2,7 +2,7 @@ use base64::display::Base64Display;
22use base64:: engine:: general_purpose:: STANDARD ;
33use clap:: { Arg , ArgAction , Command } ;
44
5- use simplicityhl:: { Arguments , CompiledProgram } ;
5+ use simplicityhl:: { AbiMeta , Arguments , CompiledProgram } ;
66use std:: { env, fmt} ;
77
88#[ cfg_attr( feature = "serde" , derive( serde:: Serialize ) ) ]
@@ -12,6 +12,9 @@ struct Output {
1212 program : String ,
1313 /// Simplicity witness result, base64 encoded, if the .wit file was provided.
1414 witness : Option < String > ,
15+ /// Simplicity program ABI metadata to the program which the user provides.
16+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
17+ abi_meta : Option < AbiMeta > ,
1518}
1619
1720impl fmt:: Display for Output {
@@ -20,6 +23,9 @@ impl fmt::Display for Output {
2023 if let Some ( witness) = & self . witness {
2124 writeln ! ( f, "Witness:\n {}" , witness) ?;
2225 }
26+ if let Some ( witness) = & self . abi_meta {
27+ writeln ! ( f, "ABI meta:\n {:?}" , witness) ?;
28+ }
2329 Ok ( ( ) )
2430 }
2531}
@@ -59,6 +65,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
5965 . action ( ArgAction :: SetTrue )
6066 . help ( "Output in JSON" ) ,
6167 )
68+ . arg (
69+ Arg :: new ( "abi" )
70+ . long ( "abi" )
71+ . action ( ArgAction :: SetTrue )
72+ . help ( "Additional ABI .simf contract types" ) ,
73+ )
6274 } ;
6375
6476 let matches = command. get_matches ( ) ;
@@ -68,6 +80,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6880 let prog_text = std:: fs:: read_to_string ( prog_path) . map_err ( |e| e. to_string ( ) ) ?;
6981 let include_debug_symbols = matches. get_flag ( "debug" ) ;
7082 let output_json = matches. get_flag ( "json" ) ;
83+ let abi_param = matches. get_flag ( "abi" ) ;
7184
7285 let compiled = CompiledProgram :: new ( prog_text, Arguments :: default ( ) , include_debug_symbols) ?;
7386
@@ -103,9 +116,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
103116 }
104117 } ;
105118
119+ let abi_opt = if abi_param {
120+ Some ( compiled. generate_abi_meta ( ) ?)
121+ } else {
122+ None
123+ } ;
124+
106125 let output = Output {
107126 program : Base64Display :: new ( & program_bytes, & STANDARD ) . to_string ( ) ,
108127 witness : witness_bytes. map ( |bytes| Base64Display :: new ( & bytes, & STANDARD ) . to_string ( ) ) ,
128+ abi_meta : abi_opt,
109129 } ;
110130
111131 if output_json {
0 commit comments