This commit is contained in:
Pietro Abate 2017-11-27 17:23:21 +01:00
parent 8f30934220
commit 6e68fb425a
2 changed files with 13 additions and 10 deletions

View File

@ -63,7 +63,7 @@ module ContractAlias = struct
let alias_param ?(name = "name") ?(desc = "existing contract alias") next =
let desc =
desc ^ "\n"
^ "can be an contract alias or a key alias (autodetected in this order)\n\
^ "can be a contract alias or a key alias (autodetected in this order)\n\
use 'key:name' to force the later" in
Cli_entries.(
param ~name ~desc
@ -97,7 +97,8 @@ module ContractAlias = struct
| Error k_errs ->
ContractEntity.of_source cctxt s >>= function
| Ok v -> return (s, v)
| Error c_errs -> Lwt.return (Error (k_errs @ c_errs))
| Error c_errs ->
Lwt.return (Error (k_errs @ c_errs))
end)))
next

View File

@ -214,14 +214,16 @@ module MakeEncodings(E: sig
l p enc.encoded_length
let decode ?alphabet s =
let rec find s = function
| [] -> None
| Encoding { prefix ; of_raw ; wrap } :: encodings ->
match remove_prefix ~prefix s with
| None -> find s encodings
| Some msg -> of_raw msg |> Utils.map_option ~f:wrap in
let s = safe_decode ?alphabet s in
find s !encodings
try
let rec find s = function
| [] -> None
| Encoding { prefix ; of_raw ; wrap } :: encodings ->
match remove_prefix ~prefix s with
| None -> find s encodings
| Some msg -> of_raw msg |> Utils.map_option ~f:wrap in
let s = safe_decode ?alphabet s in
find s !encodings
with Invalid_argument _ -> None
end