diff --git a/gitlab-pages/website/static/.well-known/acme-challenge/pY4yiss3_bmzORHLtOPUEYaFxWxD_GkD8XZajWh0DUU b/gitlab-pages/website/static/.well-known/acme-challenge/pY4yiss3_bmzORHLtOPUEYaFxWxD_GkD8XZajWh0DUU new file mode 100644 index 000000000..d17cdcfbe --- /dev/null +++ b/gitlab-pages/website/static/.well-known/acme-challenge/pY4yiss3_bmzORHLtOPUEYaFxWxD_GkD8XZajWh0DUU @@ -0,0 +1 @@ +pY4yiss3_bmzORHLtOPUEYaFxWxD_GkD8XZajWh0DUU.4Dc00ftieGaWDmacztwSS7euFOKPULDHjUNzikwPvao diff --git a/src/bin/cli.ml b/src/bin/cli.ml index e10c0c28c..f73a054cf 100644 --- a/src/bin/cli.ml +++ b/src/bin/cli.ml @@ -72,6 +72,14 @@ let syntax = info ~docv ~doc ["syntax" ; "s"] in value @@ opt string "auto" info +let amount = + let open Arg in + let info = + let docv = "AMOUNT" in + let doc = "$(docv) is the amount the dry-run transaction will use." in + info ~docv ~doc ["amount"] in + value @@ opt string "0" info + let compile_file = let f source entry_point syntax = toplevel @@ @@ -118,43 +126,43 @@ let compile_storage = (term , Term.info ~docs cmdname) let dry_run = - let f source entry_point storage input syntax = + let f source entry_point storage input amount syntax = toplevel @@ let%bind output = - Ligo.Run.run_contract source entry_point storage input syntax in + Ligo.Run.run_contract ~amount source entry_point storage input syntax in Format.printf "%a\n" Ast_simplified.PP.expression output ; ok () in let term = - Term.(const f $ source 0 $ entry_point 1 $ expression "PARAMETER" 2 $ expression "STORAGE" 3 $ syntax) in + Term.(const f $ source 0 $ entry_point 1 $ expression "PARAMETER" 2 $ expression "STORAGE" 3 $ amount $ syntax) in let cmdname = "dry-run" in let docs = "Subcommand: run a smart-contract with the given storage and input." in (term , Term.info ~docs cmdname) let run_function = - let f source entry_point parameter syntax = + let f source entry_point parameter amount syntax = toplevel @@ let%bind output = - Ligo.Run.run_function source entry_point parameter syntax in + Ligo.Run.run_function ~amount 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 "PARAMETER" 2 $ syntax) in + Term.(const f $ source 0 $ entry_point 1 $ expression "PARAMETER" 2 $ amount $ 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 = + let f source entry_point amount syntax = toplevel @@ let%bind output = - Ligo.Run.evaluate_value source entry_point syntax in + Ligo.Run.evaluate_value ~amount 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 + Term.(const f $ source 0 $ entry_point 1 $ amount $ syntax) in let cmdname = "evaluate-value" in let docs = "Subcommand: evaluate a given definition." in (term , Term.info ~docs cmdname) diff --git a/src/contracts/amount.mligo b/src/contracts/amount.mligo new file mode 100644 index 000000000..995f165fe --- /dev/null +++ b/src/contracts/amount.mligo @@ -0,0 +1 @@ +let check = if Current.amount > 100tz then 42 else 0 \ No newline at end of file diff --git a/src/main/run_simplified.ml b/src/main/run_simplified.ml index 898ba6954..17833d6b3 100644 --- a/src/main/run_simplified.ml +++ b/src/main/run_simplified.ml @@ -17,8 +17,8 @@ let run_simplityped let%bind annotated_result = Typer.untype_expression typed_result in ok annotated_result -let evaluate_simplityped (program : Ast_typed.program) (entry : string) +let evaluate_simplityped ?options (program : Ast_typed.program) (entry : string) : Ast_simplified.expression result = - let%bind typed_result = Run_typed.evaluate_typed entry program in + let%bind typed_result = Run_typed.evaluate_typed ?options entry program in let%bind annotated_result = Typer.untype_expression typed_result in ok annotated_result diff --git a/src/main/run_source.ml b/src/main/run_source.ml index e97d9d855..c961b7cad 100644 --- a/src/main/run_source.ml +++ b/src/main/run_source.ml @@ -233,23 +233,35 @@ let type_file ?(debug_simplify = false) ?(debug_typed = false) )) ; ok typed -let run_contract source entry_point storage input syntax = +let run_contract ?amount source entry_point storage input syntax = let%bind typed = type_file syntax source in let%bind storage_simpl = parsify_expression syntax storage in let%bind input_simpl = parsify_expression syntax input in - Run_simplified.run_simplityped typed entry_point (Ast_simplified.e_pair storage_simpl input_simpl) + let options = + let open Proto_alpha_utils.Memory_proto_alpha in + let amount = Option.bind (fun amount -> Alpha_context.Tez.of_string amount) amount in + (make_options ?amount ()) in + Run_simplified.run_simplityped ~options typed entry_point (Ast_simplified.e_pair storage_simpl input_simpl) -let run_function source entry_point parameter syntax = +let run_function ?amount 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 options = + let open Proto_alpha_utils.Memory_proto_alpha in + let amount = Option.bind (fun amount -> Alpha_context.Tez.of_string amount) amount in + (make_options ?amount ()) in + Run_simplified.run_simplityped ~options typed entry_point parameter' -let evaluate_value source entry_point syntax = +let evaluate_value ?amount source entry_point syntax = let%bind typed = type_file syntax source in - Run_simplified.evaluate_simplityped typed entry_point + let options = + let open Proto_alpha_utils.Memory_proto_alpha in + let amount = Option.bind (fun amount -> Alpha_context.Tez.of_string amount) amount in + (make_options ?amount ()) in + Run_simplified.evaluate_simplityped ~options typed entry_point diff --git a/src/main/run_typed.ml b/src/main/run_typed.ml index 47a67469d..4f0ff0f77 100644 --- a/src/main/run_typed.ml +++ b/src/main/run_typed.ml @@ -13,12 +13,12 @@ let transpile_value let%bind r = Run_mini_c.run_entry f input in ok r -let evaluate_typed (entry:string) (program:Ast_typed.program) : Ast_typed.annotated_expression result = +let evaluate_typed ?options (entry:string) (program:Ast_typed.program) : Ast_typed.annotated_expression result = trace (simple_error "easy evaluate typed") @@ let%bind result = let%bind mini_c_main = Transpiler.translate_entry program entry in - Run_mini_c.run_entry mini_c_main (Mini_c.Combinators.d_unit) in + Run_mini_c.run_entry ?options mini_c_main (Mini_c.Combinators.d_unit) in let%bind typed_result = let%bind typed_main = Ast_typed.get_entry program entry in Transpiler.untranspile result typed_main.type_annotation in