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
|
|
|
|
|
2017-11-02 21:57:17 +04:00
|
|
|
type location = Micheline.canonical_location
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-11-02 21:57:17 +04:00
|
|
|
let location_encoding = Micheline.canonical_location_encoding
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-11-02 21:57:17 +04:00
|
|
|
type expr = Michelson_v1_primitives.prim Micheline.canonical
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-11-02 21:57:17 +04:00
|
|
|
type node = (location, Michelson_v1_primitives.prim) Micheline.node
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-11-02 21:57:17 +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
|
2017-02-19 21:22:32 +04:00
|
|
|
Script_expr_hash.(hash_bytes [ bytes ] |> to_b58check)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-11-02 21:57:17 +04:00
|
|
|
type t = { code : expr ; storage : expr }
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
let encoding =
|
|
|
|
let open Data_encoding in
|
2017-03-09 22:17:13 +04:00
|
|
|
conv
|
2017-11-02 21:57:17 +04:00
|
|
|
(fun { code ; storage } -> (code, storage))
|
2017-03-09 22:17:13 +04:00
|
|
|
(fun (code, storage) -> { code ; storage })
|
2017-11-02 21:57:17 +04:00
|
|
|
(obj2 (req "code" expr_encoding) (req "storage" expr_encoding))
|