Alpha: Minor style issue

This commit is contained in:
Grégoire Henry 2018-02-19 22:08:36 +01:00 committed by Benjamin Canou
parent 7fcc8fa7f9
commit 892acb0c72
4 changed files with 78 additions and 49 deletions

View File

@ -28,9 +28,9 @@ module Tez : sig
type tez = t type tez = t
val zero: tez val zero: tez
val one_cent : tez val one_cent: tez
val fifty_cents : tez val fifty_cents: tez
val one : tez val one: tez
val ( -? ) : tez -> tez -> tez tzresult val ( -? ) : tez -> tez -> tez tzresult
val ( +? ) : tez -> tez -> tez tzresult val ( +? ) : tez -> tez -> tez tzresult
@ -53,9 +53,9 @@ module Period : sig
val of_seconds: int64 -> period tzresult val of_seconds: int64 -> period tzresult
val mult: int32 -> period -> period tzresult val mult: int32 -> period -> period tzresult
val one_second : period val one_second: period
val one_minute : period val one_minute: period
val one_hour : period val one_hour: period
end end
@ -71,7 +71,7 @@ module Timestamp : sig
val of_seconds: string -> time option val of_seconds: string -> time option
val to_seconds_string: time -> string val to_seconds_string: time -> string
val current : context -> time val current: context -> time
end end
@ -108,16 +108,16 @@ module Script_int : module type of Script_int_repr
module Script_timestamp : sig module Script_timestamp : sig
open Script_int open Script_int
type t type t
val compare : t -> t -> int val compare: t -> t -> int
val to_string : t -> string val to_string: t -> string
val to_notation : t -> string option val to_notation: t -> string option
val to_num_str : t -> string val to_num_str: t -> string
val of_string : string -> t option val of_string: string -> t option
val diff : t -> t -> z num val diff: t -> t -> z num
val add_delta : t -> z num -> t val add_delta: t -> z num -> t
val sub_delta : t -> z num -> t val sub_delta: t -> z num -> t
val now : context -> t val now: context -> t
val to_zint : t -> Z.t val to_zint: t -> Z.t
end end
module Script : sig module Script : sig
@ -231,8 +231,8 @@ module Script : sig
type node = (location, prim) Micheline.node type node = (location, prim) Micheline.node
type t = type t =
{ code : expr ; { code: expr ;
storage : expr } storage: expr }
val location_encoding: location Data_encoding.t val location_encoding: location Data_encoding.t
val expr_encoding: expr Data_encoding.t val expr_encoding: expr Data_encoding.t
@ -411,11 +411,11 @@ module Contract : sig
type origination_nonce type origination_nonce
val origination_nonce_encoding : origination_nonce Data_encoding.t val origination_nonce_encoding: origination_nonce Data_encoding.t
val originated_contract : origination_nonce -> contract val originated_contract: origination_nonce -> contract
val originated_contracts : origination_nonce -> contract list val originated_contracts: origination_nonce -> contract list
val initial_origination_nonce : Operation_hash.t -> origination_nonce val initial_origination_nonce: Operation_hash.t -> origination_nonce
val get_manager: val get_manager:
context -> contract -> public_key_hash tzresult Lwt.t context -> contract -> public_key_hash tzresult Lwt.t
@ -473,13 +473,13 @@ module Contract : sig
context -> contract -> int32 -> unit tzresult Lwt.t context -> contract -> int32 -> unit tzresult Lwt.t
module Big_map_storage : sig module Big_map_storage : sig
val set : val set:
context -> contract -> context -> contract ->
string -> Script.expr -> context tzresult Lwt.t string -> Script.expr -> context tzresult Lwt.t
val remove : val remove:
context -> contract -> string -> context tzresult Lwt.t context -> contract -> string -> context tzresult Lwt.t
val mem : context -> contract -> string -> bool Lwt.t val mem: context -> contract -> string -> bool Lwt.t
val get_opt : val get_opt:
context -> contract -> string -> Script_repr.expr option tzresult Lwt.t context -> contract -> string -> Script_repr.expr option tzresult Lwt.t
end end

View File

@ -15,27 +15,34 @@ let nonce_length = 32
(* 10 tez *) (* 10 tez *)
let seed_nonce_revelation_tip = let seed_nonce_revelation_tip =
Tez_repr.(mul_exn one 10) Tez_repr.(mul_exn one 10)
(* 1 tez *) (* 1 tez *)
let origination_burn = let origination_burn =
Tez_repr.one Tez_repr.one
(* 1 tez *) (* 1 tez *)
let minimal_contract_balance = let minimal_contract_balance =
Tez_repr.one Tez_repr.one
(* 1000 tez *) (* 1000 tez *)
let baking_bond_cost = let baking_bond_cost =
Tez_repr.(mul_exn one 1000) Tez_repr.(mul_exn one 1000)
(* 1000 tez *) (* 1000 tez *)
let endorsement_bond_cost = let endorsement_bond_cost =
Tez_repr.(mul_exn one 1000) Tez_repr.(mul_exn one 1000)
(* 150 tez *) (* 150 tez *)
let baking_reward = let baking_reward =
Tez_repr.(mul_exn one 150) Tez_repr.(mul_exn one 150)
(* 150 tez *) (* 150 tez *)
let endorsement_reward = let endorsement_reward =
Tez_repr.(mul_exn one 150) Tez_repr.(mul_exn one 150)
(* 100,000 tez *) (* 100,000 tez *)
let faucet_credit = let faucet_credit =
Tez_repr.(mul_exn one 100_000) Tez_repr.(mul_exn one 100_000)
(* 4,000,000 tez *) (* 4,000,000 tez *)
let bootstrap_wealth = let bootstrap_wealth =
Tez_repr.(mul_exn one 4_000_000) Tez_repr.(mul_exn one 4_000_000)

View File

@ -185,7 +185,8 @@ let () =
let failwith msg = fail (Failure msg) let failwith msg = fail (Failure msg)
let create_base c contract ~balance ~manager ~delegate ?script ~spendable ~delegatable = let create_base c contract
~balance ~manager ~delegate ?script ~spendable ~delegatable =
(match Contract_repr.is_default contract with (match Contract_repr.is_default contract with
| None -> return 0l | None -> return 0l
| Some _ -> Storage.Contract.Global_counter.get c) >>=? fun counter -> | Some _ -> Storage.Contract.Global_counter.get c) >>=? fun counter ->
@ -303,10 +304,10 @@ let get_manager c contract =
let update_manager_key c contract = function let update_manager_key c contract = function
| Some public_key -> | Some public_key ->
begin Storage.Contract.Manager.get c contract >>=? function begin Storage.Contract.Manager.get c contract >>=? function
| (Manager_repr.Public_key v) -> (* key revealed for the second time *) | Public_key v -> (* key revealed for the second time *)
if Ed25519.Public_key.(v = public_key) then return (c,v) if Ed25519.Public_key.(v = public_key) then return (c,v)
else fail (Inconsistent_public_key (v,public_key)) else fail (Inconsistent_public_key (v,public_key))
| (Manager_repr.Hash v) -> | Hash v ->
let actual_hash = Ed25519.Public_key.hash public_key in let actual_hash = Ed25519.Public_key.hash public_key in
if (Ed25519.Public_key_hash.equal actual_hash v) then if (Ed25519.Public_key_hash.equal actual_hash v) then
let v = (Manager_repr.Public_key public_key) in let v = (Manager_repr.Public_key public_key) in
@ -314,10 +315,10 @@ let update_manager_key c contract = function
return (c,public_key) (* reveal and update key *) return (c,public_key) (* reveal and update key *)
else fail (Inconsistent_hash (public_key,v,actual_hash)) else fail (Inconsistent_hash (public_key,v,actual_hash))
end end
| None -> | None ->
begin Storage.Contract.Manager.get c contract >>=? function begin Storage.Contract.Manager.get c contract >>=? function
| (Manager_repr.Public_key v) -> return (c,v) (* already revealed *) | Public_key v -> return (c,v) (* already revealed *)
| (Manager_repr.Hash v) -> fail (Missing_public_key (v)) | Hash v -> fail (Missing_public_key (v))
end end
let get_delegate_opt = Roll_storage.get_contract_delegate let get_delegate_opt = Roll_storage.get_contract_delegate
@ -447,7 +448,8 @@ let init c =
Storage.Contract.Global_counter.init c 0l Storage.Contract.Global_counter.init c 0l
module Big_map = struct module Big_map = struct
let set handle key value = Storage.Contract.Big_map.init_set handle key value >>= return let set handle key value =
Storage.Contract.Big_map.init_set handle key value >>= return
let remove = Storage.Contract.Big_map.delete let remove = Storage.Contract.Big_map.delete
let mem = Storage.Contract.Big_map.mem let mem = Storage.Contract.Big_map.mem
let get_opt = Storage.Contract.Big_map.get_option let get_opt = Storage.Contract.Big_map.get_option

View File

@ -21,30 +21,42 @@ type error +=
| Missing_public_key of Ed25519.Public_key_hash.t (* `Permanent *) | Missing_public_key of Ed25519.Public_key_hash.t (* `Permanent *)
| Failure of string (* `Permanent *) | Failure of string (* `Permanent *)
val delete : Raw_context.t -> Contract_repr.t -> Raw_context.t tzresult Lwt.t val delete: Raw_context.t -> Contract_repr.t -> Raw_context.t tzresult Lwt.t
val exists: Raw_context.t -> Contract_repr.t -> bool tzresult Lwt.t val exists: Raw_context.t -> Contract_repr.t -> bool tzresult Lwt.t
val must_exist: Raw_context.t -> Contract_repr.t -> unit tzresult Lwt.t val must_exist: Raw_context.t -> Contract_repr.t -> unit tzresult Lwt.t
val list: Raw_context.t -> Contract_repr.t list Lwt.t val list: Raw_context.t -> Contract_repr.t list Lwt.t
val check_counter_increment: Raw_context.t -> Contract_repr.t -> int32 -> unit tzresult Lwt.t val check_counter_increment:
val increment_counter: Raw_context.t -> Contract_repr.t -> Raw_context.t tzresult Lwt.t Raw_context.t -> Contract_repr.t -> int32 -> unit tzresult Lwt.t
val is_delegatable : Raw_context.t -> Contract_repr.t -> bool tzresult Lwt.t val increment_counter:
val is_spendable : Raw_context.t -> Contract_repr.t -> bool tzresult Lwt.t Raw_context.t -> Contract_repr.t -> Raw_context.t tzresult Lwt.t
val is_delegatable:
Raw_context.t -> Contract_repr.t -> bool tzresult Lwt.t
val is_spendable: Raw_context.t -> Contract_repr.t -> bool tzresult Lwt.t
val get_manager:
Raw_context.t -> Contract_repr.t -> Ed25519.Public_key_hash.t tzresult Lwt.t
val get_manager: Raw_context.t -> Contract_repr.t -> Ed25519.Public_key_hash.t tzresult Lwt.t
val update_manager_key: val update_manager_key:
Raw_context.t -> Contract_repr.t -> Ed25519.Public_key.t option -> Raw_context.t -> Contract_repr.t -> Ed25519.Public_key.t option ->
(Raw_context.t * Ed25519.Public_key.t) tzresult Lwt.t (Raw_context.t * Ed25519.Public_key.t) tzresult Lwt.t
val get_delegate_opt: Raw_context.t -> Contract_repr.t -> Ed25519.Public_key_hash.t option tzresult Lwt.t val get_delegate_opt:
Raw_context.t -> Contract_repr.t ->
Ed25519.Public_key_hash.t option tzresult Lwt.t
val get_balance: Raw_context.t -> Contract_repr.t -> Tez_repr.t tzresult Lwt.t val get_balance: Raw_context.t -> Contract_repr.t -> Tez_repr.t tzresult Lwt.t
val get_counter: Raw_context.t -> Contract_repr.t -> int32 tzresult Lwt.t val get_counter: Raw_context.t -> Contract_repr.t -> int32 tzresult Lwt.t
val get_script: Raw_context.t -> Contract_repr.t -> Script_repr.t option tzresult Lwt.t val get_script:
val get_storage: Raw_context.t -> Contract_repr.t -> Script_repr.expr option tzresult Lwt.t Raw_context.t -> Contract_repr.t -> Script_repr.t option tzresult Lwt.t
val get_storage:
Raw_context.t -> Contract_repr.t -> Script_repr.expr option tzresult Lwt.t
type big_map_diff = (string * Script_repr.expr option) list type big_map_diff = (string * Script_repr.expr option) list
@ -54,17 +66,25 @@ val update_script_storage_and_fees:
Raw_context.t tzresult Lwt.t Raw_context.t tzresult Lwt.t
(** fails if the contract is not delegatable *) (** fails if the contract is not delegatable *)
val set_delegate : Raw_context.t -> Contract_repr.t -> Ed25519.Public_key_hash.t option -> Raw_context.t tzresult Lwt.t val set_delegate:
Raw_context.t -> Contract_repr.t -> Ed25519.Public_key_hash.t option ->
Raw_context.t tzresult Lwt.t
val credit : Raw_context.t -> Contract_repr.t -> Tez_repr.t -> Raw_context.t tzresult Lwt.t val credit:
Raw_context.t -> Contract_repr.t -> Tez_repr.t ->
Raw_context.t tzresult Lwt.t
(** checks that the contract is spendable and decrease_balance *) (** checks that the contract is spendable and decrease_balance *)
val spend : Raw_context.t -> Contract_repr.t -> Tez_repr.t -> Raw_context.t tzresult Lwt.t val spend:
Raw_context.t -> Contract_repr.t -> Tez_repr.t ->
Raw_context.t tzresult Lwt.t
(** decrease_balance even if the contract is not spendable *) (** decrease_balance even if the contract is not spendable *)
val spend_from_script : Raw_context.t -> Contract_repr.t -> Tez_repr.t -> Raw_context.t tzresult Lwt.t val spend_from_script:
Raw_context.t -> Contract_repr.t -> Tez_repr.t ->
Raw_context.t tzresult Lwt.t
val originate : val originate:
Raw_context.t -> Raw_context.t ->
Contract_repr.origination_nonce -> Contract_repr.origination_nonce ->
balance:Tez_repr.t -> balance:Tez_repr.t ->
@ -75,7 +95,7 @@ val originate :
delegatable:bool -> delegatable:bool ->
(Raw_context.t * Contract_repr.t * Contract_repr.origination_nonce) tzresult Lwt.t (Raw_context.t * Contract_repr.t * Contract_repr.origination_nonce) tzresult Lwt.t
val init : val init:
Raw_context.t -> Raw_context.t tzresult Lwt.t Raw_context.t -> Raw_context.t tzresult Lwt.t
module Big_map : sig module Big_map : sig