fix dry-run ; add features to the bin

This commit is contained in:
Galfour 2019-06-11 17:57:07 +00:00
parent 7b9e3b6699
commit a75c0ac061
2 changed files with 52 additions and 5 deletions

View File

@ -131,4 +131,40 @@ let dry_run =
let docs = "Subcommand: run a smart-contract with the given storage and input." in let docs = "Subcommand: run a smart-contract with the given storage and input." in
(term , Term.info ~docs cmdname) (term , Term.info ~docs cmdname)
let () = Term.exit @@ Term.eval_choice main [compile_file ; compile_parameter ; compile_storage ; dry_run ] let run_function =
let f source entry_point parameter syntax =
toplevel @@
let%bind output =
Ligo.Run.run_function source entry_point parameter syntax in
Format.printf "%a\n" Ast_simplified.PP.expression output ;
ok ()
in
let term =
Term.(const f $ source 0 $ entry_point 1 $ expression 2 $ syntax) in
let cmdname = "run-function" in
let docs = "Subcommand: run a function with the given parameter." in
(term , Term.info ~docs cmdname)
let evaluate_value =
let f source entry_point syntax =
toplevel @@
let%bind output =
Ligo.Run.evaluate_value source entry_point syntax in
Format.printf "%a\n" Ast_simplified.PP.expression output ;
ok ()
in
let term =
Term.(const f $ source 0 $ entry_point 1 $ syntax) in
let cmdname = "evaluate-value" in
let docs = "Subcommand: evaluate a given definition." in
(term , Term.info ~docs cmdname)
let () = Term.exit @@ Term.eval_choice main [
compile_file ;
compile_parameter ;
compile_storage ;
dry_run ;
run_function ;
evaluate_value ;
]

View File

@ -217,12 +217,23 @@ let type_file ?(debug_simplify = false) ?(debug_typed = false)
)) ; )) ;
ok typed ok typed
let run_contract source entry_point storage input syntax = let run_contract source entry_point storage input syntax =
let%bind typed = let%bind typed =
type_file source entry_point in type_file syntax source in
let%bind storage_simpl = let%bind storage_simpl =
parsify_expression storage syntax in parsify_expression syntax storage in
let%bind input_simpl = let%bind input_simpl =
parsify_expression input syntax in parsify_expression syntax input in
Run_simplified.run_simplityped typed entry_point (Ast_simplified.e_pair storage_simpl input_simpl) Run_simplified.run_simplityped typed entry_point (Ast_simplified.e_pair storage_simpl input_simpl)
let run_function source entry_point parameter syntax =
let%bind typed =
type_file syntax source in
let%bind parameter' =
parsify_expression syntax parameter in
Run_simplified.run_simplityped typed entry_point parameter'
let evaluate_value source entry_point syntax =
let%bind typed =
type_file syntax source in
Run_simplified.evaluate_simplityped typed entry_point