package tezos-protocol-012-Psithaca

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Michelson Existential Witness types

type ('ta, 'tb) eq =
  1. | Eq : ('same, 'same) eq
type ex_comparable_ty =
  1. | Ex_comparable_ty : 'a Script_typed_ir.comparable_ty -> ex_comparable_ty
type ex_ty =
  1. | Ex_ty : 'a Script_typed_ir.ty -> ex_ty
type ex_stack_ty =
  1. | Ex_stack_ty : ('a, 's) Script_typed_ir.stack_ty -> ex_stack_ty
type ex_script =
  1. | Ex_script : ('a, 'b) Script_typed_ir.script -> ex_script
type ('arg, 'storage) code = {
  1. code : (('arg, 'storage) Script_typed_ir.pair, (Script_typed_ir.operation Script_typed_ir.boxed_list, 'storage) Script_typed_ir.pair) Script_typed_ir.lambda;
  2. arg_type : 'arg Script_typed_ir.ty;
  3. storage_type : 'storage Script_typed_ir.ty;
  4. views : Script_typed_ir.view Script_typed_ir.SMap.t;
  5. root_name : Script_ir_annot.field_annot option;
  6. code_size : Cache_memory_helpers.sint;
    (*

    This is an over-approximation of the value size in memory, in bytes, of the contract's static part, that is its source code. This includes the code of the contract as well as the code of the views. The storage size is not taken into account by this field as it has a dynamic size.

    *)
}
type ex_code =
  1. | Ex_code : ('a, 'c) code -> ex_code
type 'storage ex_view =
  1. | Ex_view : ('input * 'storage, 'output) Script_typed_ir.lambda -> 'storage ex_view
type ('a, 's, 'b, 'u) cinstr = {
  1. apply : 'r 'f. ('a, 's) Script_typed_ir.kinfo -> ('b, 'u, 'r, 'f) Script_typed_ir.kinstr -> ('a, 's, 'r, 'f) Script_typed_ir.kinstr;
}
type ('a, 's, 'b, 'u) descr = {
  1. loc : Alpha_context.Script.location;
  2. bef : ('a, 's) Script_typed_ir.stack_ty;
  3. aft : ('b, 'u) Script_typed_ir.stack_ty;
  4. instr : ('a, 's, 'b, 'u) cinstr;
}
type tc_context =
  1. | Lambda : tc_context
  2. | Dip : ('a, 's) Script_typed_ir.stack_ty * tc_context -> tc_context
  3. | Toplevel : {
    1. storage_type : 'sto Script_typed_ir.ty;
    2. param_type : 'param Script_typed_ir.ty;
    3. root_name : Script_ir_annot.field_annot option;
    } -> tc_context
type ('a, 's) judgement =
  1. | Typed : ('a, 's, 'b, 'u) descr -> ('a, 's) judgement
  2. | Failed : {
    1. descr : 'b 'u. ('b, 'u) Script_typed_ir.stack_ty -> ('a, 's, 'b, 'u) descr;
    } -> ('a, 's) judgement
val close_descr : ('a, 'b, 'c, 'd) descr -> ('a, 'b, 'c, 'd) Script_typed_ir.kdescr
type unparsing_mode =
  1. | Optimized
  2. | Readable
  3. | Optimized_legacy

Flag that drives unparsing of typed values to nodes.

  • Optimized_legacy must be kept backward-compatible in order to compute valid hashes (of big map keys).
  • Optimized may be used as long as the result can be read by parse_data.
  • Readable produces with string values instead of bytes when feasible.
type merge_type_error_flag =
  1. | Default_merge_type_error
  2. | Fast_merge_type_error

Create an empty big_map

val big_map_mem : Alpha_context.context -> 'key -> ('key, 'value) Script_typed_ir.big_map -> (bool * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val big_map_get : Alpha_context.context -> 'key -> ('key, 'value) Script_typed_ir.big_map -> ('value option * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val big_map_update : Alpha_context.context -> 'key -> 'value option -> ('key, 'value) Script_typed_ir.big_map -> (('key, 'value) Script_typed_ir.big_map * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t

Update a big map. See big_map_get_and_update for details.

val big_map_get_and_update : Alpha_context.context -> 'key -> 'value option -> ('key, 'value) Script_typed_ir.big_map -> (('value option * ('key, 'value) Script_typed_ir.big_map) * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t

Update a big map, returning the old value of the given key and the new map.

This does not modify the underlying storage, only the diff table.

val ty_eq : Alpha_context.context -> Alpha_context.Script.location -> 'ta Script_typed_ir.ty -> 'tb Script_typed_ir.ty -> (('ta Script_typed_ir.ty, 'tb Script_typed_ir.ty) eq * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result
val merge_types : legacy:bool -> merge_type_error_flag:merge_type_error_flag -> Alpha_context.Script.location -> 'a Script_typed_ir.ty -> 'b Script_typed_ir.ty -> (('a Script_typed_ir.ty, 'b Script_typed_ir.ty) eq * 'a Script_typed_ir.ty, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) Gas_monad.t
val parse_comparable_data : ?type_logger:type_logger -> Alpha_context.context -> 'a Script_typed_ir.comparable_ty -> Alpha_context.Script.node -> ('a * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t

Parsing and Typechecking Michelson

val parse_data : ?type_logger:type_logger -> Alpha_context.context -> legacy:bool -> allow_forged:bool -> 'a Script_typed_ir.ty -> Alpha_context.Script.node -> ('a * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val unparse_data : Alpha_context.context -> unparsing_mode -> 'a Script_typed_ir.ty -> 'a -> (Alpha_context.Script.node * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val unparse_comparable_data : loc:'loc -> Alpha_context.context -> unparsing_mode -> 'a Script_typed_ir.comparable_ty -> 'a -> ('loc Alpha_context.Script.michelson_node * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val unparse_code : Alpha_context.context -> unparsing_mode -> Alpha_context.Script.node -> (Alpha_context.Script.node * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val parse_instr : ?type_logger:type_logger -> tc_context -> Alpha_context.context -> legacy:bool -> Alpha_context.Script.node -> ('a, 's) Script_typed_ir.stack_ty -> (('a, 's) judgement * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val parse_big_map_value_ty : Alpha_context.context -> legacy:bool -> Alpha_context.Script.node -> (ex_ty * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result

parse_ty specialized for the right-hand side part of a big map type, i.e. the `value` in `big_map key value`.

val parse_packable_ty : Alpha_context.context -> legacy:bool -> Alpha_context.Script.node -> (ex_ty * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result
val parse_parameter_ty : Alpha_context.context -> legacy:bool -> Alpha_context.Script.node -> (ex_ty * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result
val parse_comparable_ty : Alpha_context.context -> Alpha_context.Script.node -> (ex_comparable_ty * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result
val parse_view_input_ty : Alpha_context.context -> stack_depth:int -> legacy:bool -> Alpha_context.Script.node -> (ex_ty * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result
val parse_view_output_ty : Alpha_context.context -> stack_depth:int -> legacy:bool -> Alpha_context.Script.node -> (ex_ty * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result
val parse_view_returning : ?type_logger:type_logger -> Alpha_context.context -> legacy:bool -> 'storage Script_typed_ir.ty -> Script_typed_ir.view -> ('storage ex_view * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val typecheck_views : ?type_logger:type_logger -> Alpha_context.context -> legacy:bool -> 'storage Script_typed_ir.ty -> Script_typed_ir.view Script_typed_ir.SMap.t -> (Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val parse_any_ty : Alpha_context.context -> legacy:bool -> Alpha_context.Script.node -> (ex_ty * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result

parse_ty allowing big_map values, operations, contract and tickets.

val parse_ty : Alpha_context.context -> legacy:bool -> allow_lazy_storage:bool -> allow_operation:bool -> allow_contract:bool -> allow_ticket:bool -> Alpha_context.Script.node -> (ex_ty * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result

We expose parse_ty for convenience to external tools. Please use specialized versions such as parse_packable_ty, parse_parameter_ty, parse_comparable_ty, or parse_big_map_value_ty if possible.

val unparse_ty : loc:'loc -> Alpha_context.context -> 'a Script_typed_ir.ty -> ('loc Alpha_context.Script.michelson_node * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result
val unparse_comparable_ty : loc:'loc -> Alpha_context.context -> 'a Script_typed_ir.comparable_ty -> ('loc Alpha_context.Script.michelson_node * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result
val ty_of_comparable_ty : 'a Script_typed_ir.comparable_ty -> 'a Script_typed_ir.ty
val parse_toplevel : Alpha_context.context -> legacy:bool -> Alpha_context.Script.expr -> (toplevel * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val add_field_annot : Script_ir_annot.field_annot option -> Script_ir_annot.var_annot option -> ('loc, 'prim) Tezos_micheline.Micheline.node -> ('loc, 'prim) Tezos_micheline.Micheline.node
val typecheck_code : legacy:bool -> show_types:bool -> Alpha_context.context -> Alpha_context.Script.expr -> (Script_tc_errors.type_map * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t

High-level function to typecheck a Michelson script. This function is not used for validating operations but only for the typecheck_code RPC.

If show_types is set to true, details of the typechecking are returned in the type_map, otherwise the returned type_map is empty.

val serialize_ty_for_error : 'a Script_typed_ir.ty -> Alpha_context.Script.expr
val parse_code : ?type_logger:type_logger -> Alpha_context.context -> legacy:bool -> code:Alpha_context.Script.lazy_expr -> (ex_code * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val parse_storage : ?type_logger:type_logger -> Alpha_context.context -> legacy:bool -> allow_forged:bool -> 'storage Script_typed_ir.ty -> storage:Alpha_context.Script.lazy_expr -> ('storage * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val parse_script : ?type_logger:type_logger -> Alpha_context.context -> legacy:bool -> allow_forged_in_storage:bool -> Alpha_context.Script.t -> (ex_script * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t

Combines parse_code and parse_storage

val unparse_script : Alpha_context.context -> unparsing_mode -> ('a, 'b) Script_typed_ir.script -> (Alpha_context.Script.t * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val parse_contract : legacy:bool -> Alpha_context.context -> Alpha_context.Script.location -> 'a Script_typed_ir.ty -> Alpha_context.Contract.t -> entrypoint:string -> (Alpha_context.context * 'a Script_typed_ir.typed_contract, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val parse_contract_for_script : Alpha_context.context -> Alpha_context.Script.location -> 'a Script_typed_ir.ty -> Alpha_context.Contract.t -> entrypoint:string -> (Alpha_context.context * 'a Script_typed_ir.typed_contract option, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val find_entrypoint : 't Script_typed_ir.ty -> root_name:Script_ir_annot.field_annot option -> string -> ((Alpha_context.Script.node -> Alpha_context.Script.node) * ex_ty, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result
module Entrypoints_map : sig ... end
val list_entrypoints : 't Script_typed_ir.ty -> Alpha_context.context -> root_name:Script_ir_annot.field_annot option -> (Michelson_v1_primitives.prim list list * (Michelson_v1_primitives.prim list * Alpha_context.Script.unlocated_michelson_node) Entrypoints_map.t, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result
val pack_data : Alpha_context.context -> 'a Script_typed_ir.ty -> 'a -> (bytes * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val hash_comparable_data : Alpha_context.context -> 'a Script_typed_ir.comparable_ty -> 'a -> (Script_expr_hash.t * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
val hash_data : Alpha_context.context -> 'a Script_typed_ir.ty -> 'a -> (Script_expr_hash.t * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t
type lazy_storage_ids
val no_lazy_storage_id : lazy_storage_ids
val collect_lazy_storage : Alpha_context.context -> 'a Script_typed_ir.ty -> 'a -> (lazy_storage_ids * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result

Traverse the given type, producing a lazy_storage_ids for use with extract_lazy_storage_diff.

val list_of_big_map_ids : lazy_storage_ids -> Alpha_context.Big_map.Id.t list
val extract_lazy_storage_diff : Alpha_context.context -> unparsing_mode -> temporary:bool -> to_duplicate:lazy_storage_ids -> to_update:lazy_storage_ids -> 'a Script_typed_ir.ty -> 'a -> ('a * Alpha_context.Lazy_storage.diffs option * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result Lwt.t

Produce a lazy storage diff, containing in-memory writes to lazy data structures such as big_maps yet to be committed.

The resulting diff can be committed to the underlying storage (context) using Lazy_storage_diff.apply.

  • parameter to_duplicate

    Lazy data structure reference produced via collect_lazy_storage that can not be reused. Typically collected via traversing the parameters to a smart contract.

  • parameter to_update

    Lazy data structure reference produced via collect_lazy_storage that can be reused. Typically collected via traversing the previous storage of a smart contract.

val get_single_sapling_state : Alpha_context.context -> 'a Script_typed_ir.ty -> 'a -> (Alpha_context.Sapling.Id.t option * Alpha_context.context, Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.error Tezos_protocol_environment_012_Psithaca__Environment.Error_monad.trace) result
val script_size : ex_script -> int * Gas_limit_repr.cost

script_size script returns an overapproximation of the size of the in-memory representation of script as well as the cost associated to computing that overapproximation.