allow to pack message (aka lambda of type unit -> operation list)

This commit is contained in:
Lesenechal Remi 2019-11-19 15:33:41 +01:00
parent f7d6a5ea58
commit 725176a59d
2 changed files with 13 additions and 0 deletions

View File

@ -79,3 +79,14 @@ let ex_value_ty_to_michelson (v : ex_typed_value) : Michelson.t result =
let evaluate_michelson ?options program = let evaluate_michelson ?options program =
let%bind etv = evaluate ?options program in let%bind etv = evaluate ?options program in
ex_value_ty_to_michelson etv ex_value_ty_to_michelson etv
let pack_message_lambda (lambda:Michelson.t) =
let open Memory_proto_alpha.Protocol.Script_typed_ir in
let input_ty = Lambda_t (Unit_t None , List_t ((Operation_t None),None,false) , None) in
let%bind lambda =
Trace.trace_tzresult_lwt (simple_error "error parsing message") @@
Memory_proto_alpha.parse_michelson_data lambda input_ty in
let%bind data =
Trace.trace_tzresult_lwt (simple_error "error packing message") @@
Memory_proto_alpha.pack input_ty lambda in
ok @@ data

View File

@ -1119,5 +1119,7 @@ let failure_interpret
| Error ((Reject (_, expr, _))::_t) -> return @@ Fail expr (* This catches failwith errors *) | Error ((Reject (_, expr, _))::_t) -> return @@ Fail expr (* This catches failwith errors *)
| Error errs -> Lwt.return @@ Error (List.map (alpha_error_wrap) errs) | Error errs -> Lwt.return @@ Error (List.map (alpha_error_wrap) errs)
let pack (data_ty: 'a ty) (data: 'a) : bytes tzresult Lwt.t =
pack_data dummy_environment.tezos_context data_ty data >>=?? fun (packed,_) -> return packed
let strings_of_prims = Michelson_v1_primitives.strings_of_prims let strings_of_prims = Michelson_v1_primitives.strings_of_prims