General: s/registred/registered/
This commit is contained in:
parent
e27a9e6aaf
commit
8713ae36f6
@ -152,10 +152,10 @@ let simple_decode ?alphabet { prefix ; of_raw ; _ } s =
|
|||||||
let simple_encode ?alphabet { prefix ; to_raw ; _ } d =
|
let simple_encode ?alphabet { prefix ; to_raw ; _ } d =
|
||||||
safe_encode ?alphabet (prefix ^ to_raw d)
|
safe_encode ?alphabet (prefix ^ to_raw d)
|
||||||
|
|
||||||
type registred_encoding = Encoding : 'a encoding -> registred_encoding
|
type registered_encoding = Encoding : 'a encoding -> registered_encoding
|
||||||
|
|
||||||
module MakeEncodings(E: sig
|
module MakeEncodings(E: sig
|
||||||
val encodings: registred_encoding list
|
val encodings: registered_encoding list
|
||||||
end) = struct
|
end) = struct
|
||||||
|
|
||||||
let encodings = ref E.encodings
|
let encodings = ref E.encodings
|
||||||
@ -175,7 +175,7 @@ module MakeEncodings(E: sig
|
|||||||
let len = String.length zeros in
|
let len = String.length zeros in
|
||||||
if String.length ones <> len then
|
if String.length ones <> len then
|
||||||
Format.ksprintf invalid_arg
|
Format.ksprintf invalid_arg
|
||||||
"Base58.registred_encoding: variable length encoding." ;
|
"Base58.registered_encoding: variable length encoding." ;
|
||||||
let rec loop i =
|
let rec loop i =
|
||||||
if i = len then len
|
if i = len then len
|
||||||
else if zeros.[i] = ones.[i] then loop (i+1)
|
else if zeros.[i] = ones.[i] then loop (i+1)
|
||||||
|
@ -32,7 +32,7 @@ end
|
|||||||
[Environment.Ed25519.Public_key_hash]. *)
|
[Environment.Ed25519.Public_key_hash]. *)
|
||||||
type data = ..
|
type data = ..
|
||||||
|
|
||||||
(** Abstract representation of registred encodings. The type paramater
|
(** Abstract representation of registered encodings. The type paramater
|
||||||
is the type of the encoded data, for instance [Hash.Block_hash.t]. *)
|
is the type of the encoded data, for instance [Hash.Block_hash.t]. *)
|
||||||
type 'a encoding = private {
|
type 'a encoding = private {
|
||||||
prefix: string ;
|
prefix: string ;
|
||||||
@ -45,7 +45,7 @@ type 'a encoding = private {
|
|||||||
}
|
}
|
||||||
|
|
||||||
(** Register a new encoding. The function might raise `Invalid_arg` if
|
(** Register a new encoding. The function might raise `Invalid_arg` if
|
||||||
the provided [prefix] overlap with a previously registred
|
the provided [prefix] overlap with a previously registered
|
||||||
prefix. The [to_raw] and [of_raw] are the ad-hoc
|
prefix. The [to_raw] and [of_raw] are the ad-hoc
|
||||||
serialisation/deserialisation for the data. The [wrap] should wrap
|
serialisation/deserialisation for the data. The [wrap] should wrap
|
||||||
the deserialised value into the extensible sum-type [data] (see
|
the deserialised value into the extensible sum-type [data] (see
|
||||||
@ -78,13 +78,13 @@ val simple_encode: ?alphabet:Alphabet.t -> 'a encoding -> 'a -> string
|
|||||||
val simple_decode: ?alphabet:Alphabet.t -> 'a encoding -> string -> 'a option
|
val simple_decode: ?alphabet:Alphabet.t -> 'a encoding -> string -> 'a option
|
||||||
|
|
||||||
(** Generic decoder. It returns [None] when the decoded data does
|
(** Generic decoder. It returns [None] when the decoded data does
|
||||||
not start with a registred prefix. *)
|
not start with a registered prefix. *)
|
||||||
val decode: ?alphabet:Alphabet.t -> string -> data option
|
val decode: ?alphabet:Alphabet.t -> string -> data option
|
||||||
|
|
||||||
(** {2 Completion of partial Base58Check value} *)
|
(** {2 Completion of partial Base58Check value} *)
|
||||||
|
|
||||||
(** Register a (global) resolver for a previsously
|
(** Register a (global) resolver for a previsously
|
||||||
registred kind af data. *)
|
registered kind af data. *)
|
||||||
val register_resolver: 'a encoding -> (string -> 'a list Lwt.t) -> unit
|
val register_resolver: 'a encoding -> (string -> 'a list Lwt.t) -> unit
|
||||||
|
|
||||||
(** Try to complete a prefix of a Base58Check encoded data, by using
|
(** Try to complete a prefix of a Base58Check encoded data, by using
|
||||||
|
@ -442,20 +442,20 @@ module Make() = struct
|
|||||||
Error_kind { id ; from_error ; category ; encoding_case ; pp } :: !error_kinds
|
Error_kind { id ; from_error ; category ; encoding_case ; pp } :: !error_kinds
|
||||||
|
|
||||||
(** Catch all error when 'deserializing' an error. *)
|
(** Catch all error when 'deserializing' an error. *)
|
||||||
type error += Unregistred_error of Data_encoding.json
|
type error += Unregistered_error of Data_encoding.json
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
let id = "" in
|
let id = "" in
|
||||||
let category = `Temporary in
|
let category = `Temporary in
|
||||||
let to_error msg = Unregistred_error msg in
|
let to_error msg = Unregistered_error msg in
|
||||||
let from_error = function
|
let from_error = function
|
||||||
| Unregistred_error json -> Some json
|
| Unregistered_error json -> Some json
|
||||||
| _ -> None in
|
| _ -> None in
|
||||||
let encoding_case =
|
let encoding_case =
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
case Json_only json from_error to_error in
|
case Json_only json from_error to_error in
|
||||||
let pp ppf json =
|
let pp ppf json =
|
||||||
Format.fprintf ppf "@[<v 2>Unregistred error:@ %a@]"
|
Format.fprintf ppf "@[<v 2>Unregistered error:@ %a@]"
|
||||||
Data_encoding.Json.pp json in
|
Data_encoding.Json.pp json in
|
||||||
error_kinds :=
|
error_kinds :=
|
||||||
Error_kind { id ; from_error ; category ; encoding_case ; pp } :: !error_kinds
|
Error_kind { id ; from_error ; category ; encoding_case ; pp } :: !error_kinds
|
||||||
|
@ -34,7 +34,7 @@ let inject_protocol state ?force:_ proto =
|
|||||||
State.Protocol.store state proto >>= function
|
State.Protocol.store state proto >>= function
|
||||||
| None ->
|
| None ->
|
||||||
failwith
|
failwith
|
||||||
"Previously registred protocol (%a)"
|
"Previously registered protocol (%a)"
|
||||||
Protocol_hash.pp_short hash
|
Protocol_hash.pp_short hash
|
||||||
| Some _ -> return ()
|
| Some _ -> return ()
|
||||||
in
|
in
|
||||||
|
@ -70,9 +70,9 @@ let known c delegate =
|
|||||||
| None | Some (Manager_repr.Hash _) -> return false
|
| None | Some (Manager_repr.Hash _) -> return false
|
||||||
| Some (Manager_repr.Public_key _) -> return true
|
| Some (Manager_repr.Public_key _) -> return true
|
||||||
|
|
||||||
(* A delegate is registred if its "implicit account"
|
(* A delegate is registered if its "implicit account"
|
||||||
delegates to itself. *)
|
delegates to itself. *)
|
||||||
let registred c delegate =
|
let registered c delegate =
|
||||||
Storage.Contract.Delegate.mem
|
Storage.Contract.Delegate.mem
|
||||||
c (Contract_repr.implicit_contract delegate)
|
c (Contract_repr.implicit_contract delegate)
|
||||||
|
|
||||||
@ -96,14 +96,14 @@ let set c contract delegate =
|
|||||||
end
|
end
|
||||||
| Some delegate ->
|
| Some delegate ->
|
||||||
known c delegate >>=? fun known_delegate ->
|
known c delegate >>=? fun known_delegate ->
|
||||||
registred c delegate >>= fun registred_delegate ->
|
registered c delegate >>= fun registered_delegate ->
|
||||||
is_delegatable c contract >>=? fun delegatable ->
|
is_delegatable c contract >>=? fun delegatable ->
|
||||||
let self_delegation =
|
let self_delegation =
|
||||||
match Contract_repr.is_implicit contract with
|
match Contract_repr.is_implicit contract with
|
||||||
| Some pkh -> Ed25519.Public_key_hash.equal pkh delegate
|
| Some pkh -> Ed25519.Public_key_hash.equal pkh delegate
|
||||||
| None -> false in
|
| None -> false in
|
||||||
if not known_delegate || not (registred_delegate || self_delegation) then
|
if not known_delegate || not (registered_delegate || self_delegation) then
|
||||||
fail (Roll_storage.Unregistred_delegate delegate)
|
fail (Roll_storage.Unregistered_delegate delegate)
|
||||||
else if not (delegatable || self_delegation) then
|
else if not (delegatable || self_delegation) then
|
||||||
fail (Non_delegatable_contract contract)
|
fail (Non_delegatable_contract contract)
|
||||||
else
|
else
|
||||||
|
@ -11,21 +11,21 @@ type error +=
|
|||||||
| Consume_roll_change
|
| Consume_roll_change
|
||||||
| No_roll_for_delegate
|
| No_roll_for_delegate
|
||||||
| No_roll_snapshot_for_cycle of Cycle_repr.t
|
| No_roll_snapshot_for_cycle of Cycle_repr.t
|
||||||
| Unregistred_delegate of Ed25519.Public_key_hash.t (* `Permanent *)
|
| Unregistered_delegate of Ed25519.Public_key_hash.t (* `Permanent *)
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
register_error_kind
|
register_error_kind
|
||||||
`Permanent
|
`Permanent
|
||||||
~id:"contract.manager.unregistred_delegate"
|
~id:"contract.manager.unregistered_delegate"
|
||||||
~title:"Unregistred delegate"
|
~title:"Unregistered delegate"
|
||||||
~description:"A contract cannot be delegated to an unregistred delegate"
|
~description:"A contract cannot be delegated to an unregistered delegate"
|
||||||
~pp:(fun ppf (k) ->
|
~pp:(fun ppf (k) ->
|
||||||
Format.fprintf ppf "The provided public key (with hash %a) is \
|
Format.fprintf ppf "The provided public key (with hash %a) is \
|
||||||
\ not registred as valid delegate key."
|
\ not registered as valid delegate key."
|
||||||
Ed25519.Public_key_hash.pp k)
|
Ed25519.Public_key_hash.pp k)
|
||||||
Data_encoding.(obj1 (req "hash" Ed25519.Public_key_hash.encoding))
|
Data_encoding.(obj1 (req "hash" Ed25519.Public_key_hash.encoding))
|
||||||
(function Unregistred_delegate (k) -> Some (k) | _ -> None)
|
(function Unregistered_delegate (k) -> Some (k) | _ -> None)
|
||||||
(fun (k) -> Unregistred_delegate (k))
|
(fun (k) -> Unregistered_delegate (k))
|
||||||
|
|
||||||
let get_contract_delegate c contract =
|
let get_contract_delegate c contract =
|
||||||
Storage.Contract.Delegate.get_option c contract
|
Storage.Contract.Delegate.get_option c contract
|
||||||
@ -34,7 +34,7 @@ let delegate_pubkey ctxt delegate =
|
|||||||
Storage.Contract.Manager.get_option ctxt
|
Storage.Contract.Manager.get_option ctxt
|
||||||
(Contract_repr.implicit_contract delegate) >>=? function
|
(Contract_repr.implicit_contract delegate) >>=? function
|
||||||
| None | Some (Manager_repr.Hash _) ->
|
| None | Some (Manager_repr.Hash _) ->
|
||||||
fail (Unregistred_delegate delegate)
|
fail (Unregistered_delegate delegate)
|
||||||
| Some (Manager_repr.Public_key pk) ->
|
| Some (Manager_repr.Public_key pk) ->
|
||||||
return pk
|
return pk
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
type error +=
|
type error +=
|
||||||
| Consume_roll_change
|
| Consume_roll_change
|
||||||
| No_roll_for_delegate
|
| No_roll_for_delegate
|
||||||
| Unregistred_delegate of Ed25519.Public_key_hash.t (* `Permanent *)
|
| Unregistered_delegate of Ed25519.Public_key_hash.t (* `Permanent *)
|
||||||
|
|
||||||
val init : Raw_context.t -> Raw_context.t tzresult Lwt.t
|
val init : Raw_context.t -> Raw_context.t tzresult Lwt.t
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user