2019-09-05 17:21:01 +04:00
|
|
|
(*****************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Open Source License *)
|
|
|
|
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* Permission is hereby granted, free of charge, to any person obtaining a *)
|
|
|
|
(* copy of this software and associated documentation files (the "Software"),*)
|
|
|
|
(* to deal in the Software without restriction, including without limitation *)
|
|
|
|
(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)
|
|
|
|
(* and/or sell copies of the Software, and to permit persons to whom the *)
|
|
|
|
(* Software is furnished to do so, subject to the following conditions: *)
|
|
|
|
(* *)
|
|
|
|
(* The above copyright notice and this permission notice shall be included *)
|
|
|
|
(* in all copies or substantial portions of the Software. *)
|
|
|
|
(* *)
|
|
|
|
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
|
|
|
|
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)
|
|
|
|
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)
|
|
|
|
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
|
|
|
|
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)
|
|
|
|
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)
|
|
|
|
(* DEALINGS IN THE SOFTWARE. *)
|
|
|
|
(* *)
|
|
|
|
(*****************************************************************************)
|
|
|
|
|
|
|
|
open Storage_functors
|
|
|
|
|
|
|
|
module Int = struct
|
|
|
|
type t = int
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let encoding = Data_encoding.uint16
|
|
|
|
end
|
|
|
|
|
|
|
|
module Int32 = struct
|
|
|
|
type t = Int32.t
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let encoding = Data_encoding.int32
|
|
|
|
end
|
|
|
|
|
|
|
|
module Z = struct
|
2019-10-17 13:45:27 +04:00
|
|
|
include Z
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let encoding = Data_encoding.z
|
|
|
|
end
|
|
|
|
|
|
|
|
module Int_index = struct
|
|
|
|
type t = int
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let path_length = 1
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let to_path c l = string_of_int c :: l
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let of_path = function
|
2020-02-12 20:40:17 +04:00
|
|
|
| [] | _ :: _ :: _ ->
|
|
|
|
None
|
|
|
|
| [c] ->
|
|
|
|
int_of_string_opt c
|
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type 'a ipath = 'a * t
|
2020-02-12 20:40:17 +04:00
|
|
|
|
|
|
|
let args =
|
|
|
|
Storage_description.One
|
|
|
|
{
|
|
|
|
rpc_arg = RPC_arg.int;
|
|
|
|
encoding = Data_encoding.int31;
|
|
|
|
compare = Compare.Int.compare;
|
|
|
|
}
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
module Make_index (H : Storage_description.INDEX) :
|
|
|
|
INDEX with type t = H.t and type 'a ipath = 'a * H.t = struct
|
2019-09-05 17:21:01 +04:00
|
|
|
include H
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type 'a ipath = 'a * t
|
2020-02-12 20:40:17 +04:00
|
|
|
|
|
|
|
let args = Storage_description.One {rpc_arg; encoding; compare}
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
2019-10-17 13:45:27 +04:00
|
|
|
module Block_priority =
|
2020-02-12 20:40:17 +04:00
|
|
|
Make_single_data_storage (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["block_priority"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Int)
|
|
|
|
|
|
|
|
(** Contracts handling *)
|
|
|
|
|
|
|
|
module Contract = struct
|
|
|
|
module Raw_context =
|
2020-02-12 20:40:17 +04:00
|
|
|
Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["contracts"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Global_counter =
|
2020-02-12 20:40:17 +04:00
|
|
|
Make_single_data_storage (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["global_counter"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Z)
|
|
|
|
|
|
|
|
module Indexed_context =
|
|
|
|
Make_indexed_subcontext
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["index"]
|
|
|
|
end))
|
|
|
|
(Make_index (Contract_repr.Index))
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
let fold = Indexed_context.fold_keys
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let list = Indexed_context.keys
|
|
|
|
|
|
|
|
module Balance =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["balance"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Tez_repr)
|
|
|
|
|
|
|
|
module Frozen_balance_index =
|
|
|
|
Make_indexed_subcontext
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Indexed_context.Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["frozen_balance"]
|
|
|
|
end))
|
|
|
|
(Make_index (Cycle_repr.Index))
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Frozen_deposits =
|
|
|
|
Frozen_balance_index.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["deposits"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Tez_repr)
|
|
|
|
|
|
|
|
module Frozen_fees =
|
|
|
|
Frozen_balance_index.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["fees"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Tez_repr)
|
|
|
|
|
|
|
|
module Frozen_rewards =
|
|
|
|
Frozen_balance_index.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["rewards"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Tez_repr)
|
|
|
|
|
|
|
|
module Manager =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["manager"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Manager_repr)
|
|
|
|
|
|
|
|
module Delegate =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["delegate"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Signature.Public_key_hash)
|
|
|
|
|
|
|
|
module Inactive_delegate =
|
2020-02-12 20:40:17 +04:00
|
|
|
Indexed_context.Make_set
|
|
|
|
(Registered)
|
|
|
|
(struct
|
|
|
|
let name = ["inactive_delegate"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Delegate_desactivation =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["delegate_desactivation"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Cycle_repr)
|
|
|
|
|
|
|
|
module Delegated =
|
|
|
|
Make_data_set_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Indexed_context.Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["delegated"]
|
|
|
|
end))
|
|
|
|
(Make_index (Contract_repr.Index))
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Counter =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["counter"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Z)
|
|
|
|
|
|
|
|
(* Consume gas for serilization and deserialization of expr in this
|
|
|
|
module *)
|
|
|
|
module Make_carbonated_map_expr (N : Storage_sigs.NAME) = struct
|
2020-02-12 20:40:17 +04:00
|
|
|
module I =
|
|
|
|
Indexed_context.Make_carbonated_map
|
2019-09-05 17:21:01 +04:00
|
|
|
(N)
|
|
|
|
(struct
|
|
|
|
type t = Script_repr.lazy_expr
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let encoding = Script_repr.lazy_expr_encoding
|
|
|
|
end)
|
|
|
|
|
|
|
|
type context = I.context
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type key = I.key
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type value = I.value
|
|
|
|
|
|
|
|
let mem = I.mem
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let delete = I.delete
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let remove = I.remove
|
|
|
|
|
|
|
|
let consume_deserialize_gas ctxt value =
|
2020-02-12 20:40:17 +04:00
|
|
|
Lwt.return
|
|
|
|
@@ ( Raw_context.check_enough_gas
|
|
|
|
ctxt
|
|
|
|
(Script_repr.minimal_deserialize_cost value)
|
|
|
|
>>? fun () ->
|
|
|
|
Script_repr.force_decode value
|
|
|
|
>>? fun (_value, value_cost) ->
|
|
|
|
Raw_context.consume_gas ctxt value_cost )
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
let consume_serialize_gas ctxt value =
|
2020-02-12 20:40:17 +04:00
|
|
|
Lwt.return
|
|
|
|
@@ ( Script_repr.force_bytes value
|
|
|
|
>>? fun (_value, value_cost) ->
|
|
|
|
Raw_context.consume_gas ctxt value_cost )
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
let get ctxt contract =
|
2020-02-12 20:40:17 +04:00
|
|
|
I.get ctxt contract
|
|
|
|
>>=? fun (ctxt, value) ->
|
|
|
|
consume_deserialize_gas ctxt value >>|? fun ctxt -> (ctxt, value)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
let get_option ctxt contract =
|
2020-02-12 20:40:17 +04:00
|
|
|
I.get_option ctxt contract
|
|
|
|
>>=? fun (ctxt, value_opt) ->
|
2019-09-05 17:21:01 +04:00
|
|
|
match value_opt with
|
2020-02-12 20:40:17 +04:00
|
|
|
| None ->
|
|
|
|
return (ctxt, None)
|
2019-09-05 17:21:01 +04:00
|
|
|
| Some value ->
|
2020-02-12 20:40:17 +04:00
|
|
|
consume_deserialize_gas ctxt value >>|? fun ctxt -> (ctxt, value_opt)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
let set ctxt contract value =
|
2020-02-12 20:40:17 +04:00
|
|
|
consume_serialize_gas ctxt value
|
|
|
|
>>=? fun ctxt -> I.set ctxt contract value
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
let set_option ctxt contract value_opt =
|
|
|
|
match value_opt with
|
2020-02-12 20:40:17 +04:00
|
|
|
| None ->
|
|
|
|
I.set_option ctxt contract None
|
2019-09-05 17:21:01 +04:00
|
|
|
| Some value ->
|
2020-02-12 20:40:17 +04:00
|
|
|
consume_serialize_gas ctxt value
|
|
|
|
>>=? fun ctxt -> I.set_option ctxt contract value_opt
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
let init ctxt contract value =
|
2020-02-12 20:40:17 +04:00
|
|
|
consume_serialize_gas ctxt value
|
|
|
|
>>=? fun ctxt -> I.init ctxt contract value
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
let init_set ctxt contract value =
|
2020-02-12 20:40:17 +04:00
|
|
|
consume_serialize_gas ctxt value
|
|
|
|
>>=? fun ctxt -> I.init_set ctxt contract value
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
module Code = Make_carbonated_map_expr (struct
|
|
|
|
let name = ["code"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
module Storage = Make_carbonated_map_expr (struct
|
|
|
|
let name = ["storage"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2019-10-17 13:45:27 +04:00
|
|
|
module Paid_storage_space =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["paid_bytes"]
|
|
|
|
end)
|
2019-10-17 13:45:27 +04:00
|
|
|
(Z)
|
|
|
|
|
|
|
|
module Used_storage_space =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["used_bytes"]
|
|
|
|
end)
|
2019-10-17 13:45:27 +04:00
|
|
|
(Z)
|
|
|
|
|
|
|
|
module Roll_list =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["roll_list"]
|
|
|
|
end)
|
2019-10-17 13:45:27 +04:00
|
|
|
(Roll_repr)
|
|
|
|
|
|
|
|
module Change =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["change"]
|
|
|
|
end)
|
2019-10-17 13:45:27 +04:00
|
|
|
(Tez_repr)
|
|
|
|
end
|
|
|
|
|
|
|
|
(** Big maps handling *)
|
|
|
|
|
|
|
|
module Big_map = struct
|
|
|
|
module Raw_context =
|
2020-02-12 20:40:17 +04:00
|
|
|
Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["big_maps"]
|
|
|
|
end)
|
2019-10-17 13:45:27 +04:00
|
|
|
|
|
|
|
module Next = struct
|
2020-02-12 20:40:17 +04:00
|
|
|
include Make_single_data_storage (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["next"]
|
|
|
|
end)
|
|
|
|
(Z)
|
|
|
|
|
2019-10-17 13:45:27 +04:00
|
|
|
let incr ctxt =
|
2020-02-12 20:40:17 +04:00
|
|
|
get ctxt
|
|
|
|
>>=? fun i -> set ctxt (Z.succ i) >>=? fun ctxt -> return (ctxt, i)
|
|
|
|
|
2019-10-17 13:45:27 +04:00
|
|
|
let init ctxt = init ctxt Z.zero
|
|
|
|
end
|
|
|
|
|
|
|
|
module Index = struct
|
|
|
|
type t = Z.t
|
|
|
|
|
|
|
|
let rpc_arg =
|
|
|
|
let construct = Z.to_string in
|
|
|
|
let destruct hash =
|
|
|
|
match Z.of_string hash with
|
2020-02-12 20:40:17 +04:00
|
|
|
| exception _ ->
|
|
|
|
Error "Cannot parse big map id"
|
|
|
|
| id ->
|
|
|
|
Ok id
|
|
|
|
in
|
2019-10-17 13:45:27 +04:00
|
|
|
RPC_arg.make
|
2020-02-12 20:40:17 +04:00
|
|
|
~descr:"A big map identifier"
|
|
|
|
~name:"big_map_id"
|
2019-10-17 13:45:27 +04:00
|
|
|
~construct
|
|
|
|
~destruct
|
|
|
|
()
|
|
|
|
|
|
|
|
let encoding =
|
2020-02-12 20:40:17 +04:00
|
|
|
Data_encoding.def
|
|
|
|
"big_map_id"
|
2019-10-17 13:45:27 +04:00
|
|
|
~title:"Big map identifier"
|
2020-02-12 20:40:17 +04:00
|
|
|
~description:"A big map identifier"
|
2019-10-17 13:45:27 +04:00
|
|
|
Z.encoding
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-10-17 13:45:27 +04:00
|
|
|
let compare = Compare.Z.compare
|
|
|
|
|
|
|
|
let path_length = 7
|
|
|
|
|
|
|
|
let to_path c l =
|
|
|
|
let raw_key = Data_encoding.Binary.to_bytes_exn encoding c in
|
2020-02-12 20:40:17 +04:00
|
|
|
let (`Hex index_key) = MBytes.to_hex (Raw_hashes.blake2b raw_key) in
|
|
|
|
String.sub index_key 0 2 :: String.sub index_key 2 2
|
|
|
|
:: String.sub index_key 4 2 :: String.sub index_key 6 2
|
|
|
|
:: String.sub index_key 8 2 :: String.sub index_key 10 2 :: Z.to_string c
|
|
|
|
:: l
|
2019-10-17 13:45:27 +04:00
|
|
|
|
|
|
|
let of_path = function
|
2020-02-12 20:40:17 +04:00
|
|
|
| []
|
|
|
|
| [_]
|
|
|
|
| [_; _]
|
|
|
|
| [_; _; _]
|
|
|
|
| [_; _; _; _]
|
|
|
|
| [_; _; _; _; _]
|
|
|
|
| [_; _; _; _; _; _]
|
|
|
|
| _ :: _ :: _ :: _ :: _ :: _ :: _ :: _ :: _ ->
|
2019-10-17 13:45:27 +04:00
|
|
|
None
|
2020-02-12 20:40:17 +04:00
|
|
|
| [index1; index2; index3; index4; index5; index6; key] ->
|
2019-10-17 13:45:27 +04:00
|
|
|
let c = Z.of_string key in
|
|
|
|
let raw_key = Data_encoding.Binary.to_bytes_exn encoding c in
|
2020-02-12 20:40:17 +04:00
|
|
|
let (`Hex index_key) = MBytes.to_hex (Raw_hashes.blake2b raw_key) in
|
|
|
|
assert (Compare.String.(String.sub index_key 0 2 = index1)) ;
|
|
|
|
assert (Compare.String.(String.sub index_key 2 2 = index2)) ;
|
|
|
|
assert (Compare.String.(String.sub index_key 4 2 = index3)) ;
|
|
|
|
assert (Compare.String.(String.sub index_key 6 2 = index4)) ;
|
|
|
|
assert (Compare.String.(String.sub index_key 8 2 = index5)) ;
|
|
|
|
assert (Compare.String.(String.sub index_key 10 2 = index6)) ;
|
2019-10-17 13:45:27 +04:00
|
|
|
Some c
|
|
|
|
end
|
|
|
|
|
|
|
|
module Indexed_context =
|
|
|
|
Make_indexed_subcontext
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["index"]
|
|
|
|
end))
|
|
|
|
(Make_index (Index))
|
2019-10-17 13:45:27 +04:00
|
|
|
|
|
|
|
let rpc_arg = Index.rpc_arg
|
|
|
|
|
|
|
|
let fold = Indexed_context.fold_keys
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-10-17 13:45:27 +04:00
|
|
|
let list = Indexed_context.keys
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
let remove_rec ctxt n = Indexed_context.remove_rec ctxt n
|
2019-10-17 13:45:27 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
let copy ctxt ~from ~to_ = Indexed_context.copy ctxt ~from ~to_
|
2019-10-17 13:45:27 +04:00
|
|
|
|
|
|
|
type key = Raw_context.t * Z.t
|
|
|
|
|
|
|
|
module Total_bytes =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["total_bytes"]
|
|
|
|
end)
|
2019-10-17 13:45:27 +04:00
|
|
|
(Z)
|
|
|
|
|
|
|
|
module Key_type =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["key_type"]
|
|
|
|
end)
|
|
|
|
(struct
|
|
|
|
type t = Script_repr.expr
|
|
|
|
|
|
|
|
let encoding = Script_repr.expr_encoding
|
|
|
|
end)
|
2019-10-17 13:45:27 +04:00
|
|
|
|
|
|
|
module Value_type =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["value_type"]
|
|
|
|
end)
|
|
|
|
(struct
|
|
|
|
type t = Script_repr.expr
|
2019-10-17 13:45:27 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
let encoding = Script_repr.expr_encoding
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
module Contents = struct
|
|
|
|
module I =
|
|
|
|
Storage_functors.Make_indexed_carbonated_data_storage
|
|
|
|
(Make_subcontext (Registered) (Indexed_context.Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["contents"]
|
|
|
|
end))
|
|
|
|
(Make_index (Script_expr_hash))
|
|
|
|
(struct
|
|
|
|
type t = Script_repr.expr
|
|
|
|
|
|
|
|
let encoding = Script_repr.expr_encoding
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
type context = I.context
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type key = I.key
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type value = I.value
|
|
|
|
|
|
|
|
let mem = I.mem
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let delete = I.delete
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let remove = I.remove
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let set = I.set
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let set_option = I.set_option
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let init = I.init
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let init_set = I.init_set
|
|
|
|
|
|
|
|
let consume_deserialize_gas ctxt value =
|
2020-02-12 20:40:17 +04:00
|
|
|
Lwt.return
|
|
|
|
@@ Raw_context.consume_gas ctxt (Script_repr.deserialized_cost value)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
let get ctxt contract =
|
2020-02-12 20:40:17 +04:00
|
|
|
I.get ctxt contract
|
|
|
|
>>=? fun (ctxt, value) ->
|
|
|
|
consume_deserialize_gas ctxt value >>|? fun ctxt -> (ctxt, value)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
let get_option ctxt contract =
|
2020-02-12 20:40:17 +04:00
|
|
|
I.get_option ctxt contract
|
|
|
|
>>=? fun (ctxt, value_opt) ->
|
2019-09-05 17:21:01 +04:00
|
|
|
match value_opt with
|
2020-02-12 20:40:17 +04:00
|
|
|
| None ->
|
|
|
|
return (ctxt, None)
|
2019-09-05 17:21:01 +04:00
|
|
|
| Some value ->
|
2020-02-12 20:40:17 +04:00
|
|
|
consume_deserialize_gas ctxt value >>|? fun ctxt -> (ctxt, value_opt)
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module Delegates =
|
|
|
|
Make_data_set_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["delegates"]
|
|
|
|
end))
|
|
|
|
(Make_index (Signature.Public_key_hash))
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Active_delegates_with_rolls =
|
|
|
|
Make_data_set_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["active_delegates_with_rolls"]
|
|
|
|
end))
|
|
|
|
(Make_index (Signature.Public_key_hash))
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Delegates_with_frozen_balance_index =
|
|
|
|
Make_indexed_subcontext
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["delegates_with_frozen_balance"]
|
|
|
|
end))
|
|
|
|
(Make_index (Cycle_repr.Index))
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Delegates_with_frozen_balance =
|
|
|
|
Make_data_set_storage
|
|
|
|
(Delegates_with_frozen_balance_index.Raw_context)
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_index (Signature.Public_key_hash))
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Rolls *)
|
|
|
|
|
|
|
|
module Cycle = struct
|
|
|
|
module Indexed_context =
|
|
|
|
Make_indexed_subcontext
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["cycle"]
|
|
|
|
end))
|
|
|
|
(Make_index (Cycle_repr.Index))
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Last_roll =
|
|
|
|
Make_indexed_data_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Indexed_context.Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["last_roll"]
|
|
|
|
end))
|
|
|
|
(Int_index)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Roll_repr)
|
|
|
|
|
|
|
|
module Roll_snapshot =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["roll_snapshot"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Int)
|
|
|
|
|
|
|
|
type unrevealed_nonce = {
|
2020-02-12 20:40:17 +04:00
|
|
|
nonce_hash : Nonce_hash.t;
|
|
|
|
delegate : Signature.Public_key_hash.t;
|
|
|
|
rewards : Tez_repr.t;
|
|
|
|
fees : Tez_repr.t;
|
2019-09-05 17:21:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
type nonce_status =
|
|
|
|
| Unrevealed of unrevealed_nonce
|
|
|
|
| Revealed of Seed_repr.nonce
|
|
|
|
|
|
|
|
let nonce_status_encoding =
|
|
|
|
let open Data_encoding in
|
2020-02-12 20:40:17 +04:00
|
|
|
union
|
|
|
|
[ case
|
|
|
|
(Tag 0)
|
|
|
|
~title:"Unrevealed"
|
|
|
|
(tup4
|
|
|
|
Nonce_hash.encoding
|
|
|
|
Signature.Public_key_hash.encoding
|
|
|
|
Tez_repr.encoding
|
|
|
|
Tez_repr.encoding)
|
|
|
|
(function
|
|
|
|
| Unrevealed {nonce_hash; delegate; rewards; fees} ->
|
|
|
|
Some (nonce_hash, delegate, rewards, fees)
|
|
|
|
| _ ->
|
|
|
|
None)
|
|
|
|
(fun (nonce_hash, delegate, rewards, fees) ->
|
|
|
|
Unrevealed {nonce_hash; delegate; rewards; fees});
|
|
|
|
case
|
|
|
|
(Tag 1)
|
|
|
|
~title:"Revealed"
|
|
|
|
Seed_repr.nonce_encoding
|
|
|
|
(function Revealed nonce -> Some nonce | _ -> None)
|
|
|
|
(fun nonce -> Revealed nonce) ]
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Nonce =
|
|
|
|
Make_indexed_data_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Indexed_context.Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["nonces"]
|
|
|
|
end))
|
|
|
|
(Make_index (Raw_level_repr.Index))
|
|
|
|
(struct
|
|
|
|
type t = nonce_status
|
|
|
|
|
|
|
|
let encoding = nonce_status_encoding
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Seed =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["random_seed"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(struct
|
|
|
|
type t = Seed_repr.seed
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let encoding = Seed_repr.seed_encoding
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
module Roll = struct
|
|
|
|
module Raw_context =
|
2020-02-12 20:40:17 +04:00
|
|
|
Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["rolls"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Indexed_context =
|
|
|
|
Make_indexed_subcontext
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["index"]
|
|
|
|
end))
|
|
|
|
(Make_index (Roll_repr.Index))
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Next =
|
2020-02-12 20:40:17 +04:00
|
|
|
Make_single_data_storage (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["next"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Roll_repr)
|
|
|
|
|
|
|
|
module Limbo =
|
2020-02-12 20:40:17 +04:00
|
|
|
Make_single_data_storage (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["limbo"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Roll_repr)
|
|
|
|
|
|
|
|
module Delegate_roll_list =
|
2020-02-12 20:40:17 +04:00
|
|
|
Wrap_indexed_data_storage
|
|
|
|
(Contract.Roll_list)
|
|
|
|
(struct
|
|
|
|
type t = Signature.Public_key_hash.t
|
|
|
|
|
|
|
|
let wrap = Contract_repr.implicit_contract
|
|
|
|
|
|
|
|
let unwrap = Contract_repr.is_implicit
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Successor =
|
|
|
|
Indexed_context.Make_map
|
2020-02-12 20:40:17 +04:00
|
|
|
(struct
|
|
|
|
let name = ["successor"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Roll_repr)
|
|
|
|
|
|
|
|
module Delegate_change =
|
2020-02-12 20:40:17 +04:00
|
|
|
Wrap_indexed_data_storage
|
|
|
|
(Contract.Change)
|
|
|
|
(struct
|
|
|
|
type t = Signature.Public_key_hash.t
|
|
|
|
|
|
|
|
let wrap = Contract_repr.implicit_contract
|
|
|
|
|
|
|
|
let unwrap = Contract_repr.is_implicit
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Snapshoted_owner_index = struct
|
|
|
|
type t = Cycle_repr.t * int
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let path_length = Cycle_repr.Index.path_length + 1
|
2020-02-12 20:40:17 +04:00
|
|
|
|
|
|
|
let to_path (c, n) s = Cycle_repr.Index.to_path c (string_of_int n :: s)
|
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let of_path l =
|
|
|
|
match Misc.take Cycle_repr.Index.path_length l with
|
2020-02-12 20:40:17 +04:00
|
|
|
| None | Some (_, ([] | _ :: _ :: _)) ->
|
|
|
|
None
|
|
|
|
| Some (l1, [l2]) -> (
|
|
|
|
match (Cycle_repr.Index.of_path l1, int_of_string_opt l2) with
|
|
|
|
| (None, _) | (_, None) ->
|
|
|
|
None
|
|
|
|
| (Some c, Some i) ->
|
|
|
|
Some (c, i) )
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
type 'a ipath = ('a * Cycle_repr.t) * int
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let left_args =
|
2020-02-12 20:40:17 +04:00
|
|
|
Storage_description.One
|
|
|
|
{
|
|
|
|
rpc_arg = Cycle_repr.rpc_arg;
|
|
|
|
encoding = Cycle_repr.encoding;
|
|
|
|
compare = Cycle_repr.compare;
|
|
|
|
}
|
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let right_args =
|
2020-02-12 20:40:17 +04:00
|
|
|
Storage_description.One
|
|
|
|
{
|
|
|
|
rpc_arg = RPC_arg.int;
|
|
|
|
encoding = Data_encoding.int31;
|
|
|
|
compare = Compare.Int.compare;
|
|
|
|
}
|
|
|
|
|
|
|
|
let args = Storage_description.(Pair (left_args, right_args))
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
module Owner =
|
|
|
|
Make_indexed_data_snapshotable_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["owner"]
|
|
|
|
end))
|
|
|
|
(Snapshoted_owner_index)
|
|
|
|
(Make_index (Roll_repr.Index))
|
2019-09-05 17:21:01 +04:00
|
|
|
(Signature.Public_key)
|
|
|
|
|
|
|
|
module Snapshot_for_cycle = Cycle.Roll_snapshot
|
|
|
|
module Last_for_snapshot = Cycle.Last_roll
|
|
|
|
|
|
|
|
let clear = Indexed_context.clear
|
|
|
|
end
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
(** Votes *)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Vote = struct
|
|
|
|
module Raw_context =
|
2020-02-12 20:40:17 +04:00
|
|
|
Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["votes"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Current_period_kind =
|
2020-02-12 20:40:17 +04:00
|
|
|
Make_single_data_storage (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["current_period_kind"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(struct
|
|
|
|
type t = Voting_period_repr.kind
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let encoding = Voting_period_repr.kind_encoding
|
|
|
|
end)
|
|
|
|
|
2019-10-17 13:45:27 +04:00
|
|
|
module Participation_ema =
|
2020-02-12 20:40:17 +04:00
|
|
|
Make_single_data_storage (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["participation_ema"]
|
|
|
|
end)
|
2019-10-17 13:45:27 +04:00
|
|
|
(Int32)
|
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
module Current_proposal =
|
2020-02-12 20:40:17 +04:00
|
|
|
Make_single_data_storage (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["current_proposal"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Protocol_hash)
|
|
|
|
|
|
|
|
module Listings_size =
|
2020-02-12 20:40:17 +04:00
|
|
|
Make_single_data_storage (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["listings_size"]
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
(Int32)
|
|
|
|
|
|
|
|
module Listings =
|
|
|
|
Make_indexed_data_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["listings"]
|
|
|
|
end))
|
|
|
|
(Make_index (Signature.Public_key_hash))
|
|
|
|
(Int32)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Proposals =
|
|
|
|
Make_data_set_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["proposals"]
|
|
|
|
end))
|
|
|
|
(Pair
|
|
|
|
(Make_index
|
|
|
|
(Protocol_hash))
|
|
|
|
(Make_index (Signature.Public_key_hash)))
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Proposals_count =
|
|
|
|
Make_indexed_data_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["proposals_count"]
|
|
|
|
end))
|
|
|
|
(Make_index (Signature.Public_key_hash))
|
|
|
|
(Int)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Ballots =
|
|
|
|
Make_indexed_data_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["ballots"]
|
|
|
|
end))
|
|
|
|
(Make_index (Signature.Public_key_hash))
|
|
|
|
(struct
|
|
|
|
type t = Vote_repr.ballot
|
|
|
|
|
|
|
|
let encoding = Vote_repr.ballot_encoding
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
(** Seed *)
|
|
|
|
|
|
|
|
module Seed = struct
|
|
|
|
type unrevealed_nonce = Cycle.unrevealed_nonce = {
|
2020-02-12 20:40:17 +04:00
|
|
|
nonce_hash : Nonce_hash.t;
|
|
|
|
delegate : Signature.Public_key_hash.t;
|
|
|
|
rewards : Tez_repr.t;
|
|
|
|
fees : Tez_repr.t;
|
2019-09-05 17:21:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
type nonce_status = Cycle.nonce_status =
|
|
|
|
| Unrevealed of unrevealed_nonce
|
|
|
|
| Revealed of Seed_repr.nonce
|
|
|
|
|
|
|
|
module Nonce = struct
|
|
|
|
open Level_repr
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type context = Raw_context.t
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let mem ctxt l = Cycle.Nonce.mem (ctxt, l.cycle) l.level
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let get ctxt l = Cycle.Nonce.get (ctxt, l.cycle) l.level
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let get_option ctxt l = Cycle.Nonce.get_option (ctxt, l.cycle) l.level
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let set ctxt l v = Cycle.Nonce.set (ctxt, l.cycle) l.level v
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let init ctxt l v = Cycle.Nonce.init (ctxt, l.cycle) l.level v
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let init_set ctxt l v = Cycle.Nonce.init_set (ctxt, l.cycle) l.level v
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let set_option ctxt l v = Cycle.Nonce.set_option (ctxt, l.cycle) l.level v
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let delete ctxt l = Cycle.Nonce.delete (ctxt, l.cycle) l.level
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
let remove ctxt l = Cycle.Nonce.remove (ctxt, l.cycle) l.level
|
|
|
|
end
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
module For_cycle = Cycle.Seed
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
(** Commitments *)
|
|
|
|
|
|
|
|
module Commitments =
|
|
|
|
Make_indexed_data_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["commitments"]
|
|
|
|
end))
|
|
|
|
(Make_index (Blinded_public_key_hash.Index))
|
|
|
|
(Tez_repr)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
(** Ramp up security deposits... *)
|
|
|
|
|
|
|
|
module Ramp_up = struct
|
|
|
|
module Rewards =
|
|
|
|
Make_indexed_data_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["ramp_up"; "rewards"]
|
|
|
|
end))
|
|
|
|
(Make_index (Cycle_repr.Index))
|
|
|
|
(struct
|
|
|
|
type t = Tez_repr.t list * Tez_repr.t list
|
|
|
|
|
|
|
|
let encoding =
|
|
|
|
Data_encoding.(
|
|
|
|
obj2
|
|
|
|
(req "baking_reward_per_endorsement" (list Tez_repr.encoding))
|
|
|
|
(req "endorsement_reward" (list Tez_repr.encoding)))
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
module Security_deposits =
|
|
|
|
Make_indexed_data_storage
|
2020-02-12 20:40:17 +04:00
|
|
|
(Make_subcontext (Registered) (Raw_context)
|
|
|
|
(struct
|
|
|
|
let name = ["ramp_up"; "deposits"]
|
|
|
|
end))
|
|
|
|
(Make_index (Cycle_repr.Index))
|
|
|
|
(struct
|
|
|
|
type t = Tez_repr.t * Tez_repr.t
|
|
|
|
|
|
|
|
let encoding =
|
|
|
|
Data_encoding.tup2 Tez_repr.encoding Tez_repr.encoding
|
|
|
|
end)
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|