ligo/src/proto/alpha/script_repr.ml

34 lines
1.3 KiB
OCaml
Raw Normal View History

2016-09-08 21:13:10 +04:00
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2016. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
open Tezos_hash
type location = Micheline.canonical_location
2016-09-08 21:13:10 +04:00
let location_encoding = Micheline.canonical_location_encoding
2016-09-08 21:13:10 +04:00
type expr = Michelson_v1_primitives.prim Micheline.canonical
2016-09-08 21:13:10 +04:00
type node = (location, Michelson_v1_primitives.prim) Micheline.node
2016-09-08 21:13:10 +04:00
let expr_encoding = Micheline.canonical_encoding Michelson_v1_primitives.prim_encoding
2016-09-08 21:13:10 +04:00
let hash_expr data =
let bytes = Data_encoding.Binary.to_bytes expr_encoding data in
Script_expr_hash.(hash_bytes [ bytes ] |> to_b58check)
2016-09-08 21:13:10 +04:00
type t = { code : expr ; storage : expr }
2016-09-08 21:13:10 +04:00
let encoding =
let open Data_encoding in
conv
(fun { code ; storage } -> (code, storage))
(fun (code, storage) -> { code ; storage })
(obj2 (req "code" expr_encoding) (req "storage" expr_encoding))