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

View File

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

View File

@ -185,7 +185,8 @@ let () =
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
| None -> return 0l
| 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
| Some public_key ->
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)
else fail (Inconsistent_public_key (v,public_key))
| (Manager_repr.Hash v) ->
| Hash v ->
let actual_hash = Ed25519.Public_key.hash public_key in
if (Ed25519.Public_key_hash.equal actual_hash v) then
let v = (Manager_repr.Public_key public_key) in
@ -316,8 +317,8 @@ let update_manager_key c contract = function
end
| None ->
begin Storage.Contract.Manager.get c contract >>=? function
| (Manager_repr.Public_key v) -> return (c,v) (* already revealed *)
| (Manager_repr.Hash v) -> fail (Missing_public_key (v))
| Public_key v -> return (c,v) (* already revealed *)
| Hash v -> fail (Missing_public_key (v))
end
let get_delegate_opt = Roll_storage.get_contract_delegate
@ -447,7 +448,8 @@ let init c =
Storage.Contract.Global_counter.init c 0l
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 mem = Storage.Contract.Big_map.mem
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 *)
| 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 must_exist: Raw_context.t -> Contract_repr.t -> unit tzresult 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 increment_counter: Raw_context.t -> Contract_repr.t -> Raw_context.t tzresult Lwt.t
val check_counter_increment:
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 is_spendable : Raw_context.t -> Contract_repr.t -> bool tzresult Lwt.t
val increment_counter:
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:
Raw_context.t -> Contract_repr.t -> Ed25519.Public_key.t option ->
(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_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_storage: Raw_context.t -> Contract_repr.t -> Script_repr.expr option tzresult Lwt.t
val get_script:
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
@ -54,17 +66,25 @@ val update_script_storage_and_fees:
Raw_context.t tzresult Lwt.t
(** 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 *)
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 *)
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 ->
Contract_repr.origination_nonce ->
balance:Tez_repr.t ->
@ -75,7 +95,7 @@ val originate :
delegatable:bool ->
(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
module Big_map : sig