Shell: Consistently use Ed25519.Public_key_hash

This commit is contained in:
Grégoire Henry 2016-11-14 15:54:21 +01:00
parent 69261aa542
commit b82ad19806
23 changed files with 94 additions and 123 deletions

View File

@ -8,7 +8,8 @@
(**************************************************************************) (**************************************************************************)
module Public_key_hash : Client_aliases.Alias with type t = Ed25519.public_key_hash module Public_key_hash :
Client_aliases.Alias with type t = Ed25519.Public_key_hash.t
module Public_key : Client_aliases.Alias with type t = Ed25519.public_key module Public_key : Client_aliases.Alias with type t = Ed25519.public_key
module Secret_key : Client_aliases.Alias with type t = Ed25519.secret_key module Secret_key : Client_aliases.Alias with type t = Ed25519.secret_key

View File

@ -101,7 +101,7 @@ let get_delegate block source =
let may_check_key sourcePubKey sourcePubKeyHash = let may_check_key sourcePubKey sourcePubKeyHash =
match sourcePubKey with match sourcePubKey with
| Some sourcePubKey -> | Some sourcePubKey ->
if not (Ed25519.equal_hash (Ed25519.hash sourcePubKey) sourcePubKeyHash) if not (Ed25519.Public_key_hash.equal (Ed25519.hash sourcePubKey) sourcePubKeyHash)
then then
failwith "Invalid public key in `client_proto_endorsement`" failwith "Invalid public key in `client_proto_endorsement`"
else else

View File

@ -22,10 +22,10 @@ let encoding =
module Map = struct module Map = struct
module Raw = Map.Make(struct module Raw = Map.Make(struct
type t = asset * Ed25519.public_key_hash type t = asset * Ed25519.Public_key_hash.t
let compare (a1, pk1) (a2, pk2) = let compare (a1, pk1) (a2, pk2) =
if Compare.Int32.(a1 = a2) then if Compare.Int32.(a1 = a2) then
Ed25519.compare_hash pk1 pk2 Ed25519.Public_key_hash.compare pk1 pk2
else else
Compare.Int32.compare a1 a2 Compare.Int32.compare a1 a2
end) end)
@ -54,7 +54,7 @@ let encoding =
(Json.wrap_error of_tuple_list_exn) (Json.wrap_error of_tuple_list_exn)
(list (list
(tup2 (tup2
(tup2 encoding Ed25519.public_key_hash_encoding) (tup2 encoding Ed25519.Public_key_hash.encoding)
Tez_repr.encoding))) Tez_repr.encoding)))
end end

View File

@ -17,6 +17,6 @@ module Map : sig
type t type t
val empty: t val empty: t
val add: val add:
t -> asset -> Ed25519.public_key_hash -> Tez_repr.tez -> t tzresult t -> asset -> Ed25519.Public_key_hash.t -> Tez_repr.tez -> t tzresult
val encoding: t Data_encoding.t val encoding: t Data_encoding.t
end end

View File

@ -8,7 +8,7 @@
(**************************************************************************) (**************************************************************************)
type account = { type account = {
public_key_hash : Ed25519.public_key_hash ; public_key_hash : Ed25519.Public_key_hash.t ;
public_key : Ed25519.public_key ; public_key : Ed25519.public_key ;
secret_key : Ed25519.secret_key ; secret_key : Ed25519.secret_key ;
} }
@ -94,7 +94,7 @@ let account_encoding =
(fun (public_key_hash, public_key, secret_key) -> (fun (public_key_hash, public_key, secret_key) ->
{ public_key_hash ; public_key ; secret_key }) { public_key_hash ; public_key ; secret_key })
(obj3 (obj3
(req "publicKeyHash" Ed25519.public_key_hash_encoding) (req "publicKeyHash" Ed25519.Public_key_hash.encoding)
(req "publicKey" Ed25519.public_key_encoding) (req "publicKey" Ed25519.public_key_encoding)
(req "secretKey" Ed25519.secret_key_encoding)) (req "secretKey" Ed25519.secret_key_encoding))

View File

@ -8,7 +8,7 @@
(**************************************************************************) (**************************************************************************)
type account = { type account = {
public_key_hash : Ed25519.public_key_hash ; public_key_hash : Ed25519.Public_key_hash.t ;
public_key : Ed25519.public_key ; public_key : Ed25519.public_key ;
secret_key : Ed25519.secret_key ; secret_key : Ed25519.secret_key ;
} }

View File

@ -10,15 +10,15 @@
open Tezos_hash open Tezos_hash
type descr = { type descr = {
manager: Ed25519.public_key_hash ; manager: Ed25519.Public_key_hash.t ;
delegate: Ed25519.public_key_hash option ; delegate: Ed25519.Public_key_hash.t option ;
spendable: bool ; spendable: bool ;
delegatable: bool ; delegatable: bool ;
script: Script_repr.t ; script: Script_repr.t ;
} }
type t = type t =
| Default of Ed25519.public_key_hash | Default of Ed25519.Public_key_hash.t
| Hash of Contract_hash.t | Hash of Contract_hash.t
type contract = t type contract = t
@ -29,12 +29,10 @@ let to_b48check = function
| Hash h -> Contract_hash.to_b48check h | Hash h -> Contract_hash.to_b48check h
let of_b48check s = let of_b48check s =
try
match Base48.decode s with match Base48.decode s with
| Ed25519.Public_key_hash.Hash h -> ok (Default h) | Some (Ed25519.Public_key_hash.Hash h) -> ok (Default h)
| Contract_hash.Hash h -> ok (Hash h) | Some (Contract_hash.Hash h) -> ok (Hash h)
| _ -> error (Invalid_contract_notation s) | _ -> error (Invalid_contract_notation s)
with _ -> error (Invalid_contract_notation s)
let encoding = let encoding =
let open Data_encoding in let open Data_encoding in
@ -50,7 +48,7 @@ let encoding =
splitted splitted
~binary: ~binary:
(union ~tag_size:`Uint8 [ (union ~tag_size:`Uint8 [
case ~tag:0 Ed25519.public_key_hash_encoding case ~tag:0 Ed25519.Public_key_hash.encoding
(function Default k -> Some k | _ -> None) (function Default k -> Some k | _ -> None)
(fun k -> Default k) ; (fun k -> Default k) ;
case ~tag:1 Contract_hash.encoding case ~tag:1 Contract_hash.encoding
@ -96,8 +94,8 @@ let descr_encoding =
(fun (manager, delegate, spendable, delegatable, script) -> (fun (manager, delegate, spendable, delegatable, script) ->
{ manager; delegate; spendable; delegatable; script }) { manager; delegate; spendable; delegatable; script })
(obj5 (obj5
(req "manager" Ed25519.public_key_hash_encoding) (req "manager" Ed25519.Public_key_hash.encoding)
(opt "delegate" Ed25519.public_key_hash_encoding) (opt "delegate" Ed25519.Public_key_hash.encoding)
(dft "spendable" bool false) (dft "spendable" bool false)
(dft "delegatable" bool false) (dft "delegatable" bool false)
(req "script" Script_repr.encoding)) (req "script" Script_repr.encoding))
@ -105,7 +103,7 @@ let descr_encoding =
let generic_contract ~manager ~delegate ~spendable ~delegatable ~script = let generic_contract ~manager ~delegate ~spendable ~delegatable ~script =
match delegate, spendable, delegatable, script with match delegate, spendable, delegatable, script with
| Some delegate, true, false, Script_repr.No_script | Some delegate, true, false, Script_repr.No_script
when Ed25519.equal_hash manager delegate -> when Ed25519.Public_key_hash.equal manager delegate ->
default_contract manager default_contract manager
| _ -> | _ ->
let data = let data =
@ -130,7 +128,7 @@ let arg =
let compare l1 l2 = let compare l1 l2 =
match l1, l2 with match l1, l2 with
| Default pkh1, Default pkh2 -> | Default pkh1, Default pkh2 ->
Ed25519.compare_hash pkh1 pkh2 Ed25519.Public_key_hash.compare pkh1 pkh2
| Hash h1, Hash h2 -> | Hash h1, Hash h2 ->
Contract_hash.compare h1 h2 Contract_hash.compare h1 h2
| Default _, Hash _ -> -1 | Default _, Hash _ -> -1

View File

@ -10,13 +10,13 @@
open Tezos_hash open Tezos_hash
type t = private type t = private
| Default of Ed25519.public_key_hash | Default of Ed25519.Public_key_hash.t
| Hash of Contract_hash.t | Hash of Contract_hash.t
type contract = t type contract = t
type descr = { type descr = {
manager: Ed25519.public_key_hash ; manager: Ed25519.Public_key_hash.t ;
delegate: Ed25519.public_key_hash option ; delegate: Ed25519.Public_key_hash.t option ;
spendable: bool ; spendable: bool ;
delegatable: bool ; delegatable: bool ;
script: Script_repr.t ; script: Script_repr.t ;
@ -24,13 +24,13 @@ type descr = {
include Compare.S with type t := contract include Compare.S with type t := contract
val default_contract : Ed25519.public_key_hash -> contract val default_contract : Ed25519.Public_key_hash.t -> contract
val is_default : contract -> Ed25519.public_key_hash option val is_default : contract -> Ed25519.Public_key_hash.t option
val generic_contract : val generic_contract :
manager:Ed25519.public_key_hash -> manager:Ed25519.Public_key_hash.t ->
delegate:Ed25519.public_key_hash option -> delegate:Ed25519.Public_key_hash.t option ->
spendable:bool -> spendable:bool ->
delegatable:bool -> delegatable:bool ->
script:Script_repr.t -> script:Script_repr.t ->

View File

@ -33,9 +33,9 @@ val is_delegatable : Storage.t -> Contract_repr.t -> bool tzresult Lwt.t
val is_spendable : Storage.t -> Contract_repr.t -> bool tzresult Lwt.t val is_spendable : Storage.t -> Contract_repr.t -> bool tzresult Lwt.t
val get_descr: Storage.t -> Contract_repr.t -> Contract_repr.descr tzresult Lwt.t val get_descr: Storage.t -> Contract_repr.t -> Contract_repr.descr tzresult Lwt.t
val get_manager: Storage.t -> Contract_repr.t -> Ed25519.public_key_hash tzresult Lwt.t val get_manager: Storage.t -> Contract_repr.t -> Ed25519.Public_key_hash.t tzresult Lwt.t
val get_delegate: Storage.t -> Contract_repr.t -> Ed25519.public_key_hash tzresult Lwt.t val get_delegate: Storage.t -> Contract_repr.t -> Ed25519.Public_key_hash.t tzresult Lwt.t
val get_delegate_opt: Storage.t -> Contract_repr.t -> Ed25519.public_key_hash option tzresult Lwt.t val get_delegate_opt: Storage.t -> Contract_repr.t -> Ed25519.Public_key_hash.t option tzresult Lwt.t
val get_balance: Storage.t -> Contract_repr.t -> Tez_repr.t tzresult Lwt.t val get_balance: Storage.t -> Contract_repr.t -> Tez_repr.t tzresult Lwt.t
val get_assets: Storage.t -> Contract_repr.t -> Asset_repr.Map.t tzresult Lwt.t val get_assets: Storage.t -> Contract_repr.t -> Asset_repr.Map.t tzresult Lwt.t
val get_counter: Storage.t -> Contract_repr.t -> int32 tzresult Lwt.t val get_counter: Storage.t -> Contract_repr.t -> int32 tzresult Lwt.t
@ -49,7 +49,7 @@ val update_script_storage: Storage.t -> Contract_repr.t -> Script_repr.expr ->
Storage.t tzresult Lwt.t Storage.t tzresult Lwt.t
(** fails if the contract is not delegatable *) (** fails if the contract is not delegatable *)
val set_delegate : Storage.t -> Contract_repr.t -> Ed25519.public_key_hash option -> Storage.t tzresult Lwt.t val set_delegate : Storage.t -> Contract_repr.t -> Ed25519.Public_key_hash.t option -> Storage.t tzresult Lwt.t
val credit : Storage.t -> Contract_repr.t -> Tez_repr.t -> Storage.t tzresult Lwt.t val credit : Storage.t -> Contract_repr.t -> Tez_repr.t -> Storage.t tzresult Lwt.t
@ -60,14 +60,14 @@ val spend : Storage.t -> Contract_repr.t -> Tez_repr.t -> Storage.t tzresult Lwt
val unconditional_spend : Storage.t -> Contract_repr.t -> Tez_repr.t -> Storage.t tzresult Lwt.t val unconditional_spend : Storage.t -> Contract_repr.t -> Tez_repr.t -> Storage.t tzresult Lwt.t
val issue : val issue :
Storage.t -> Contract_repr.t -> Asset_repr.t -> Ed25519.public_key_hash -> Tez_repr.t -> Storage.t tzresult Lwt.t Storage.t -> Contract_repr.t -> Asset_repr.t -> Ed25519.Public_key_hash.t -> Tez_repr.t -> Storage.t tzresult Lwt.t
val originate : val originate :
Storage.t -> Storage.t ->
balance:Tez_repr.t -> balance:Tez_repr.t ->
manager:Ed25519.public_key_hash -> manager:Ed25519.Public_key_hash.t ->
script:Script_repr.t -> script:Script_repr.t ->
delegate:Ed25519.public_key_hash option -> delegate:Ed25519.Public_key_hash.t option ->
spendable:bool -> spendable:bool ->
delegatable:bool -> delegatable:bool ->
(Storage.t * Contract_repr.t) tzresult Lwt.t (Storage.t * Contract_repr.t) tzresult Lwt.t

View File

@ -55,7 +55,7 @@ let reveal c level nonce =
type status = Storage.Seed.nonce_status = type status = Storage.Seed.nonce_status =
| Unrevealed of { | Unrevealed of {
nonce_hash: Tezos_hash.Nonce_hash.t ; nonce_hash: Tezos_hash.Nonce_hash.t ;
delegate_to_reward: Ed25519.public_key_hash ; delegate_to_reward: Ed25519.Public_key_hash.t ;
reward_amount: Tez_repr.t ; reward_amount: Tez_repr.t ;
} }
| Revealed of nonce | Revealed of nonce

View File

@ -21,17 +21,17 @@ val encoding: nonce Data_encoding.t
val record_hash: val record_hash:
Storage.t -> Storage.t ->
Ed25519.public_key_hash -> Tez_repr.t -> Ed25519.Public_key_hash.t -> Tez_repr.t ->
Nonce_hash.t -> Storage.t tzresult Lwt.t Nonce_hash.t -> Storage.t tzresult Lwt.t
val reveal: val reveal:
Storage.t -> Level_repr.t -> nonce -> Storage.t -> Level_repr.t -> nonce ->
(Storage.t * Ed25519.public_key_hash * Tez_repr.t) tzresult Lwt.t (Storage.t * Ed25519.Public_key_hash.t * Tez_repr.t) tzresult Lwt.t
type status = type status =
| Unrevealed of { | Unrevealed of {
nonce_hash: Tezos_hash.Nonce_hash.t ; nonce_hash: Tezos_hash.Nonce_hash.t ;
delegate_to_reward: Ed25519.public_key_hash ; delegate_to_reward: Ed25519.Public_key_hash.t ;
reward_amount: Tez_repr.t ; reward_amount: Tez_repr.t ;
} }
| Revealed of nonce | Revealed of nonce

View File

@ -46,18 +46,18 @@ and manager_operation =
destination: Contract_repr.contract ; destination: Contract_repr.contract ;
} }
| Origination of { | Origination of {
manager: Ed25519.public_key_hash ; manager: Ed25519.Public_key_hash.t ;
delegate: Ed25519.public_key_hash option ; delegate: Ed25519.Public_key_hash.t option ;
script: Script_repr.t ; script: Script_repr.t ;
spendable: bool ; spendable: bool ;
delegatable: bool ; delegatable: bool ;
credit: Tez_repr.tez ; credit: Tez_repr.tez ;
} }
| Issuance of { | Issuance of {
asset: Asset_repr.asset * Ed25519.public_key_hash ; asset: Asset_repr.asset * Ed25519.Public_key_hash.t ;
amount: Tez_repr.tez ; amount: Tez_repr.tez ;
} }
| Delegation of Ed25519.public_key_hash option | Delegation of Ed25519.Public_key_hash.t option
and delegate_operation = and delegate_operation =
| Endorsement of { | Endorsement of {
@ -99,11 +99,11 @@ module Encoding = struct
let origination_encoding = let origination_encoding =
(obj7 (obj7
(req "kind" (constant "origination")) (req "kind" (constant "origination"))
(req "managerPubkey" Ed25519.public_key_hash_encoding) (req "managerPubkey" Ed25519.Public_key_hash.encoding)
(req "balance" Tez_repr.encoding) (req "balance" Tez_repr.encoding)
(opt "spendable" bool) (opt "spendable" bool)
(opt "delegatable" bool) (opt "delegatable" bool)
(opt "delegate" Ed25519.public_key_hash_encoding) (opt "delegate" Ed25519.Public_key_hash.encoding)
(req "script" Script_repr.encoding)) (req "script" Script_repr.encoding))
let origination_case tag = let origination_case tag =
@ -125,7 +125,7 @@ module Encoding = struct
let issuance_encoding = let issuance_encoding =
(obj3 (obj3
(req "kind" (constant "issuance")) (req "kind" (constant "issuance"))
(req "asset" (tup2 Asset_repr.encoding Ed25519.public_key_hash_encoding)) (req "asset" (tup2 Asset_repr.encoding Ed25519.Public_key_hash.encoding))
(req "quantity" Tez_repr.encoding)) (req "quantity" Tez_repr.encoding))
let issuance_case tag = let issuance_case tag =
@ -138,7 +138,7 @@ module Encoding = struct
let delegation_encoding = let delegation_encoding =
(obj2 (obj2
(req "kind" (constant "delegation")) (req "kind" (constant "delegation"))
(opt "delegate" Ed25519.public_key_hash_encoding)) (opt "delegate" Ed25519.Public_key_hash.encoding))
let delegation_case tag = let delegation_case tag =
case ~tag delegation_encoding case ~tag delegation_encoding

View File

@ -46,18 +46,18 @@ and manager_operation =
destination: Contract_repr.contract ; destination: Contract_repr.contract ;
} }
| Origination of { | Origination of {
manager: Ed25519.public_key_hash ; manager: Ed25519.Public_key_hash.t ;
delegate: Ed25519.public_key_hash option ; delegate: Ed25519.Public_key_hash.t option ;
script: Script_repr.t ; script: Script_repr.t ;
spendable: bool ; spendable: bool ;
delegatable: bool ; delegatable: bool ;
credit: Tez_repr.tez ; credit: Tez_repr.tez ;
} }
| Issuance of { | Issuance of {
asset: Asset_repr.t * Ed25519.public_key_hash ; asset: Asset_repr.t * Ed25519.Public_key_hash.t ;
amount: Tez_repr.tez ; amount: Tez_repr.tez ;
} }
| Delegation of Ed25519.public_key_hash option | Delegation of Ed25519.Public_key_hash.t option
and delegate_operation = and delegate_operation =
| Endorsement of { | Endorsement of {

View File

@ -8,10 +8,10 @@
(**************************************************************************) (**************************************************************************)
val record: val record:
Storage.t -> Ed25519.public_key_hash -> Cycle_repr.t -> Tez_repr.t -> Storage.t tzresult Lwt.t Storage.t -> Ed25519.Public_key_hash.t -> Cycle_repr.t -> Tez_repr.t -> Storage.t tzresult Lwt.t
val discard: val discard:
Storage.t -> Ed25519.public_key_hash -> Cycle_repr.t -> Tez_repr.t -> Storage.t tzresult Lwt.t Storage.t -> Ed25519.Public_key_hash.t -> Cycle_repr.t -> Tez_repr.t -> Storage.t tzresult Lwt.t
val pay_due_rewards: Storage.t -> Storage.t tzresult Lwt.t val pay_due_rewards: Storage.t -> Storage.t tzresult Lwt.t

View File

@ -36,11 +36,11 @@ val clear_cycle :
val mining_rights_owner : val mining_rights_owner :
Storage.t -> Level_repr.t -> priority:int32 -> Storage.t -> Level_repr.t -> priority:int32 ->
Ed25519.public_key_hash tzresult Lwt.t Ed25519.Public_key_hash.t tzresult Lwt.t
val endorsement_rights_owner : val endorsement_rights_owner :
Storage.t -> Level_repr.t -> slot:int -> Storage.t -> Level_repr.t -> slot:int ->
Ed25519.public_key_hash tzresult Lwt.t Ed25519.Public_key_hash.t tzresult Lwt.t
module Contract : sig module Contract : sig
@ -60,4 +60,4 @@ end
(**/**) (**/**)
val get_contract_delegate: val get_contract_delegate:
Storage.t -> Contract_repr.t -> Ed25519.public_key_hash option tzresult Lwt.t Storage.t -> Contract_repr.t -> Ed25519.Public_key_hash.t option tzresult Lwt.t

View File

@ -191,7 +191,7 @@ module Context = struct
let pk_encoding = let pk_encoding =
(obj2 (obj2
(req "hash" Ed25519.public_key_hash_encoding) (req "hash" Ed25519.Public_key_hash.encoding)
(req "public_key" Ed25519.public_key_encoding)) (req "public_key" Ed25519.public_key_encoding))
let list custom_root = let list custom_root =
@ -225,14 +225,14 @@ module Context = struct
RPC.service RPC.service
~description: "Access the manager of a contract." ~description: "Access the manager of a contract."
~input: empty ~input: empty
~output: (wrap_tzerror Ed25519.public_key_hash_encoding) ~output: (wrap_tzerror Ed25519.Public_key_hash.encoding)
RPC.Path.(custom_root / "context" / "contracts" /: Contract.arg / "manager") RPC.Path.(custom_root / "context" / "contracts" /: Contract.arg / "manager")
let delegate custom_root = let delegate custom_root =
RPC.service RPC.service
~description: "Access the delegate of a contract, if any." ~description: "Access the delegate of a contract, if any."
~input: empty ~input: empty
~output: (wrap_tzerror (option Ed25519.public_key_hash_encoding)) ~output: (wrap_tzerror (option Ed25519.Public_key_hash.encoding))
RPC.Path.(custom_root / "context" / "contracts" /: Contract.arg / "delegate") RPC.Path.(custom_root / "context" / "contracts" /: Contract.arg / "delegate")
let counter custom_root = let counter custom_root =
@ -292,12 +292,12 @@ module Context = struct
(fun (manager,balance,spendable,delegate,script,assets,counter) -> (fun (manager,balance,spendable,delegate,script,assets,counter) ->
{manager;balance;spendable;delegate;script;assets;counter}) @@ {manager;balance;spendable;delegate;script;assets;counter}) @@
obj7 obj7
(req "manager" Ed25519.public_key_hash_encoding) (req "manager" Ed25519.Public_key_hash.encoding)
(req "balance" Tez.encoding) (req "balance" Tez.encoding)
(req "spendable" bool) (req "spendable" bool)
(req "delegate" @@ obj2 (req "delegate" @@ obj2
(req "setable" bool) (req "setable" bool)
(opt "value" Ed25519.public_key_hash_encoding)) (opt "value" Ed25519.Public_key_hash.encoding))
(dft "script" Script.encoding No_script) (dft "script" Script.encoding No_script)
(req "assets" Asset.Map.encoding) (req "assets" Asset.Map.encoding)
(req "counter" int32)) (req "counter" int32))
@ -404,7 +404,7 @@ module Helpers = struct
(req "mining_rights" (req "mining_rights"
(list (list
(obj2 (obj2
(req "delegate" Ed25519.public_key_hash_encoding) (req "delegate" Ed25519.Public_key_hash.encoding)
(req "timestamp" Timestamp.encoding))))) (req "timestamp" Timestamp.encoding)))))
RPC.Path.(custom_root / "helpers" / "rights" / "mining") RPC.Path.(custom_root / "helpers" / "rights" / "mining")
@ -418,7 +418,7 @@ module Helpers = struct
obj2 obj2
(req "level" Raw_level.encoding) (req "level" Raw_level.encoding)
(req "delegates" (req "delegates"
(list Ed25519.public_key_hash_encoding))) (list Ed25519.Public_key_hash.encoding)))
RPC.Path.(custom_root / "helpers" / "rights" RPC.Path.(custom_root / "helpers" / "rights"
/ "mining" / "level" /: Raw_level.arg ) / "mining" / "level" /: Raw_level.arg )
@ -447,7 +447,7 @@ module Helpers = struct
~input: empty ~input: empty
~output: (wrap_tzerror @@ ~output: (wrap_tzerror @@
obj1 (req "delegates" obj1 (req "delegates"
(list Ed25519.public_key_hash_encoding))) (list Ed25519.Public_key_hash.encoding)))
RPC.Path.(custom_root / "helpers" / "rights" RPC.Path.(custom_root / "helpers" / "rights"
/ "mining" / "delegate" ) / "mining" / "delegate" )
@ -460,7 +460,7 @@ module Helpers = struct
obj2 obj2
(req "level" Raw_level.encoding) (req "level" Raw_level.encoding)
(req "delegates" (req "delegates"
(list Ed25519.public_key_hash_encoding))) (list Ed25519.Public_key_hash.encoding)))
RPC.Path.(custom_root / "helpers" / "rights" / "endorsement") RPC.Path.(custom_root / "helpers" / "rights" / "endorsement")
let endorsement_rights_for_level custom_root = let endorsement_rights_for_level custom_root =
@ -472,7 +472,7 @@ module Helpers = struct
obj2 obj2
(req "level" Raw_level.encoding) (req "level" Raw_level.encoding)
(req "delegates" (req "delegates"
(list Ed25519.public_key_hash_encoding))) (list Ed25519.Public_key_hash.encoding)))
RPC.Path.(custom_root / "helpers" / "rights" RPC.Path.(custom_root / "helpers" / "rights"
/ "endorsement" / "level" /: Raw_level.arg ) / "endorsement" / "level" /: Raw_level.arg )
@ -501,7 +501,7 @@ module Helpers = struct
~input: empty ~input: empty
~output: (wrap_tzerror @@ ~output: (wrap_tzerror @@
obj1 (req "delegates" obj1 (req "delegates"
(list Ed25519.public_key_hash_encoding))) (list Ed25519.Public_key_hash.encoding)))
RPC.Path.(custom_root / "helpers" / "rights" RPC.Path.(custom_root / "helpers" / "rights"
/ "endorsement" / "delegate" ) / "endorsement" / "delegate" )

View File

@ -197,10 +197,10 @@ module Roll = struct
module Owner_for_cycle = module Owner_for_cycle =
Make_indexed_data_storage(struct Make_indexed_data_storage(struct
type key = Cycle_repr.t * Roll_repr.t type key = Cycle_repr.t * Roll_repr.t
type value = Ed25519.public_key_hash type value = Ed25519.Public_key_hash.t
let name = "roll owner for current cycle" let name = "roll owner for current cycle"
let key = Key.Cycle.roll_owner let key = Key.Cycle.roll_owner
let encoding = Ed25519.public_key_hash_encoding let encoding = Ed25519.Public_key_hash.encoding
end) end)
module Contract_roll_list = module Contract_roll_list =
@ -266,10 +266,10 @@ module Contract = struct
module Manager = module Manager =
Make_indexed_data_storage(struct Make_indexed_data_storage(struct
type key = Contract_repr.t type key = Contract_repr.t
type value = Ed25519.public_key_hash type value = Ed25519.Public_key_hash.t
let name = "contract manager" let name = "contract manager"
let key = Key.Contract.manager let key = Key.Contract.manager
let encoding = Ed25519.public_key_hash_encoding let encoding = Ed25519.Public_key_hash.encoding
end) end)
module Spendable = module Spendable =
@ -293,10 +293,10 @@ module Contract = struct
module Delegate = module Delegate =
Make_indexed_data_storage(struct Make_indexed_data_storage(struct
type key = Contract_repr.t type key = Contract_repr.t
type value = Ed25519.public_key_hash type value = Ed25519.Public_key_hash.t
let name = "contract delegate" let name = "contract delegate"
let key = Key.Contract.delegate let key = Key.Contract.delegate
let encoding = Ed25519.public_key_hash_encoding let encoding = Ed25519.Public_key_hash.encoding
end) end)
module Counter = module Counter =
@ -376,7 +376,7 @@ module Vote = struct
module Proposals = module Proposals =
Make_data_set_storage Make_data_set_storage
(struct (struct
type value = Protocol_hash.t * Ed25519.public_key_hash type value = Protocol_hash.t * Ed25519.Public_key_hash.t
let name = "proposals" let name = "proposals"
let encoding = let encoding =
Data_encoding.tup2 Data_encoding.tup2
@ -413,7 +413,7 @@ module Seed = struct
type nonce_status = type nonce_status =
| Unrevealed of { | Unrevealed of {
nonce_hash: Tezos_hash.Nonce_hash.t ; nonce_hash: Tezos_hash.Nonce_hash.t ;
delegate_to_reward: Ed25519.public_key_hash ; delegate_to_reward: Ed25519.Public_key_hash.t ;
reward_amount: Tez_repr.t ; reward_amount: Tez_repr.t ;
} }
| Revealed of Seed_repr.nonce | Revealed of Seed_repr.nonce
@ -482,7 +482,7 @@ module Rewards = struct
module Amount = module Amount =
Raw_make_iterable_data_storage(struct Raw_make_iterable_data_storage(struct
type t = Ed25519.public_key_hash * Cycle_repr.t type t = Ed25519.Public_key_hash.t * Cycle_repr.t
let prefix = Key.rewards let prefix = Key.rewards
let length = Ed25519.Public_key_hash.path_len + 1 let length = Ed25519.Public_key_hash.path_len + 1
let to_path (pkh, c) = let to_path (pkh, c) =

View File

@ -109,7 +109,7 @@ module Roll : sig
module Owner_for_cycle : Indexed_data_storage module Owner_for_cycle : Indexed_data_storage
with type key = Cycle_repr.t * Roll_repr.t with type key = Cycle_repr.t * Roll_repr.t
and type value = Ed25519.public_key_hash and type value = Ed25519.Public_key_hash.t
and type context := t and type context := t
end end
@ -144,13 +144,13 @@ module Contract : sig
(** The manager of a contract *) (** The manager of a contract *)
module Manager : Indexed_data_storage module Manager : Indexed_data_storage
with type key = Contract_repr.t with type key = Contract_repr.t
and type value = Ed25519.public_key_hash and type value = Ed25519.Public_key_hash.t
and type context := t and type context := t
(** The delegate of a contract, if any. *) (** The delegate of a contract, if any. *)
module Delegate : Indexed_data_storage module Delegate : Indexed_data_storage
with type key = Contract_repr.t with type key = Contract_repr.t
and type value = Ed25519.public_key_hash and type value = Ed25519.Public_key_hash.t
and type context := t and type context := t
module Spendable : Indexed_data_storage module Spendable : Indexed_data_storage
@ -201,16 +201,16 @@ module Vote : sig
and type context := t and type context := t
module Listings : Iterable_data_storage module Listings : Iterable_data_storage
with type key = Ed25519.public_key_hash with type key = Ed25519.Public_key_hash.t
and type value = int32 (* number of rolls for the key. *) and type value = int32 (* number of rolls for the key. *)
and type context := t and type context := t
module Proposals : Data_set_storage module Proposals : Data_set_storage
with type value = Protocol_hash.t * Ed25519.public_key_hash with type value = Protocol_hash.t * Ed25519.Public_key_hash.t
and type context := t and type context := t
module Ballots : Iterable_data_storage module Ballots : Iterable_data_storage
with type key = Ed25519.public_key_hash with type key = Ed25519.Public_key_hash.t
and type value = Vote_repr.ballot and type value = Vote_repr.ballot
and type context := t and type context := t
@ -220,7 +220,7 @@ end
(** Keys *) (** Keys *)
module Public_key : Iterable_data_storage module Public_key : Iterable_data_storage
with type key = Ed25519.public_key_hash with type key = Ed25519.Public_key_hash.t
and type value = Ed25519.public_key and type value = Ed25519.public_key
and type context := t and type context := t
@ -234,7 +234,7 @@ module Seed : sig
type nonce_status = type nonce_status =
| Unrevealed of { | Unrevealed of {
nonce_hash: Tezos_hash.Nonce_hash.t ; nonce_hash: Tezos_hash.Nonce_hash.t ;
delegate_to_reward: Ed25519.public_key_hash ; delegate_to_reward: Ed25519.Public_key_hash.t ;
reward_amount: Tez_repr.t ; reward_amount: Tez_repr.t ;
} }
| Revealed of Seed_repr.nonce | Revealed of Seed_repr.nonce
@ -266,7 +266,7 @@ module Rewards : sig
and type context := t and type context := t
module Amount : Iterable_data_storage module Amount : Iterable_data_storage
with type key = Ed25519.public_key_hash * Cycle_repr.t with type key = Ed25519.Public_key_hash.t * Cycle_repr.t
and type value = Tez_repr.t and type value = Tez_repr.t
and type context := t and type context := t

View File

@ -39,7 +39,7 @@ module Script_int = Script_int_repr
module Script = Script_repr module Script = Script_repr
type public_key = Ed25519.public_key type public_key = Ed25519.public_key
type public_key_hash = Ed25519.public_key_hash type public_key_hash = Ed25519.Public_key_hash.t
type secret_key = Ed25519.secret_key type secret_key = Ed25519.secret_key
type signature = Ed25519.signature type signature = Ed25519.signature

View File

@ -26,7 +26,7 @@ module Nonce_hash_set = Tezos_hash.Nonce_hash_set
module Nonce_hash_map = Tezos_hash.Nonce_hash_map module Nonce_hash_map = Tezos_hash.Nonce_hash_map
type public_key = Ed25519.public_key type public_key = Ed25519.public_key
type public_key_hash = Ed25519.public_key_hash type public_key_hash = Ed25519.Public_key_hash.t
type secret_key = Ed25519.secret_key type secret_key = Ed25519.secret_key
type signature = Ed25519.signature type signature = Ed25519.signature

View File

@ -8,7 +8,7 @@
(**************************************************************************) (**************************************************************************)
val record_proposal: val record_proposal:
Storage.t -> Protocol_hash.t -> Ed25519.public_key_hash -> Storage.t -> Protocol_hash.t -> Ed25519.Public_key_hash.t ->
Storage.t tzresult Lwt.t Storage.t tzresult Lwt.t
val get_proposals: val get_proposals:
@ -23,7 +23,7 @@ type ballots = {
} }
val record_ballot: val record_ballot:
Storage.t -> Ed25519.public_key_hash -> Vote_repr.ballot -> Storage.t -> Ed25519.Public_key_hash.t -> Vote_repr.ballot ->
Storage.t tzresult Lwt.t Storage.t tzresult Lwt.t
val get_ballots: Storage.t -> ballots tzresult Lwt.t val get_ballots: Storage.t -> ballots tzresult Lwt.t
val clear_ballots: Storage.t -> Storage.t Lwt.t val clear_ballots: Storage.t -> Storage.t Lwt.t
@ -33,7 +33,7 @@ val clear_listings: Storage.t -> Storage.t tzresult Lwt.t
val listing_size: Storage.t -> int32 tzresult Lwt.t val listing_size: Storage.t -> int32 tzresult Lwt.t
val in_listings: val in_listings:
Storage.t -> Ed25519.public_key_hash -> bool Lwt.t Storage.t -> Ed25519.Public_key_hash.t -> bool Lwt.t
val get_current_quorum: Storage.t -> int32 tzresult Lwt.t val get_current_quorum: Storage.t -> int32 tzresult Lwt.t
val set_current_quorum: Storage.t -> int32 -> Storage.t tzresult Lwt.t val set_current_quorum: Storage.t -> int32 -> Storage.t tzresult Lwt.t

View File

@ -22,25 +22,11 @@ val check_signature : public_key -> signature -> MBytes.t -> bool
module Public_key_hash : Hash.HASH module Public_key_hash : Hash.HASH
(** A Sha256 hash of an Ed25519 public key for use as an ID *)
type public_key_hash = Public_key_hash.t
(** Hashes an Ed25519 public key *) (** Hashes an Ed25519 public key *)
val hash : public_key -> public_key_hash val hash : public_key -> Public_key_hash.t
(** For using IDs as keys in the database *)
val hash_path : public_key_hash -> string list
(** ID comparison *)
val equal_hash : public_key_hash -> public_key_hash -> bool
(** ID comparison *)
val compare_hash : public_key_hash -> public_key_hash -> int
(** {2 Serializers} **********************************************************) (** {2 Serializers} **********************************************************)
val public_key_hash_encoding : public_key_hash Data_encoding.t
val public_key_encoding : public_key Data_encoding.t val public_key_encoding : public_key Data_encoding.t
val secret_key_encoding : secret_key Data_encoding.t val secret_key_encoding : secret_key Data_encoding.t

View File

@ -33,25 +33,11 @@ val check_signature : public_key -> signature -> MBytes.t -> bool
module Public_key_hash : Hash.HASH module Public_key_hash : Hash.HASH
(** A Sha256 hash of an Ed25519 public key for use as an ID *)
type public_key_hash = Public_key_hash.t
(** Hashes an Ed25519 public key *) (** Hashes an Ed25519 public key *)
val hash : public_key -> public_key_hash val hash : public_key -> Public_key_hash.t
(** For using IDs as keys in the database *)
val hash_path : public_key_hash -> string list
(** ID comparison *)
val equal_hash : public_key_hash -> public_key_hash -> bool
(** ID comparison *)
val compare_hash : public_key_hash -> public_key_hash -> int
(** {2 Serializers} **********************************************************) (** {2 Serializers} **********************************************************)
val public_key_hash_encoding : public_key_hash Data_encoding.t
val public_key_encoding : public_key Data_encoding.t val public_key_encoding : public_key Data_encoding.t
val secret_key_encoding : secret_key Data_encoding.t val secret_key_encoding : secret_key Data_encoding.t
@ -60,4 +46,4 @@ val signature_encoding : signature Data_encoding.t
(** {2 Key pairs generation} *************************************************) (** {2 Key pairs generation} *************************************************)
val generate_key : unit -> public_key_hash * public_key * secret_key val generate_key : unit -> Public_key_hash.t * public_key * secret_key