diff --git a/src/main/run/of_michelson.ml b/src/main/run/of_michelson.ml index a0a2e5e11..50b9bd852 100644 --- a/src/main/run/of_michelson.ml +++ b/src/main/run/of_michelson.ml @@ -79,3 +79,14 @@ let ex_value_ty_to_michelson (v : ex_typed_value) : Michelson.t result = let evaluate_michelson ?options program = let%bind etv = evaluate ?options program in 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 diff --git a/vendors/ligo-utils/proto-alpha-utils/x_memory_proto_alpha.ml b/vendors/ligo-utils/proto-alpha-utils/x_memory_proto_alpha.ml index d37bf59f7..541a926cc 100644 --- a/vendors/ligo-utils/proto-alpha-utils/x_memory_proto_alpha.ml +++ b/vendors/ligo-utils/proto-alpha-utils/x_memory_proto_alpha.ml @@ -1119,5 +1119,7 @@ let failure_interpret | Error ((Reject (_, expr, _))::_t) -> return @@ Fail expr (* This catches failwith errors *) | 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 \ No newline at end of file