Alpha: remove a few more try ... with
This commit is contained in:
parent
105d8e3833
commit
4c4400a073
@ -1231,11 +1231,9 @@ let rec parse_data
|
|||||||
return (Script_timestamp.of_zint v, ctxt)
|
return (Script_timestamp.of_zint v, ctxt)
|
||||||
| Timestamp_t _, String (_, s) (* As unparsed with [Redable]. *) ->
|
| Timestamp_t _, String (_, s) (* As unparsed with [Redable]. *) ->
|
||||||
Lwt.return (Gas.consume ctxt Typecheck_costs.string_timestamp) >>=? fun ctxt ->
|
Lwt.return (Gas.consume ctxt Typecheck_costs.string_timestamp) >>=? fun ctxt ->
|
||||||
begin try
|
begin match Script_timestamp.of_string s with
|
||||||
match Script_timestamp.of_string s with
|
|
||||||
| Some v -> return (v, ctxt)
|
| Some v -> return (v, ctxt)
|
||||||
| None -> fail (error ())
|
| None -> fail (error ())
|
||||||
with _ -> fail (error ())
|
|
||||||
end
|
end
|
||||||
| Timestamp_t _, expr ->
|
| Timestamp_t _, expr ->
|
||||||
traced (fail (Invalid_kind (location expr, [ String_kind ; Int_kind ], kind expr)))
|
traced (fail (Invalid_kind (location expr, [ String_kind ; Int_kind ], kind expr)))
|
||||||
@ -1248,10 +1246,9 @@ let rec parse_data
|
|||||||
end
|
end
|
||||||
| Key_t _, String (_, s) -> (* As unparsed with [Readable]. *)
|
| Key_t _, String (_, s) -> (* As unparsed with [Readable]. *)
|
||||||
Lwt.return (Gas.consume ctxt Typecheck_costs.key) >>=? fun ctxt ->
|
Lwt.return (Gas.consume ctxt Typecheck_costs.key) >>=? fun ctxt ->
|
||||||
begin
|
begin match Signature.Public_key.of_b58check_opt s with
|
||||||
try
|
| Some k -> return (k, ctxt)
|
||||||
return (Signature.Public_key.of_b58check_exn s, ctxt)
|
| None -> fail (error ())
|
||||||
with _ -> fail (error ())
|
|
||||||
end
|
end
|
||||||
| Key_t _, expr ->
|
| Key_t _, expr ->
|
||||||
traced (fail (Invalid_kind (location expr, [ String_kind ; Bytes_kind ], kind expr)))
|
traced (fail (Invalid_kind (location expr, [ String_kind ; Bytes_kind ], kind expr)))
|
||||||
@ -1264,40 +1261,33 @@ let rec parse_data
|
|||||||
end
|
end
|
||||||
| Key_hash_t _, String (_, s) (* As unparsed with [Readable]. *) ->
|
| Key_hash_t _, String (_, s) (* As unparsed with [Readable]. *) ->
|
||||||
Lwt.return (Gas.consume ctxt Typecheck_costs.key_hash) >>=? fun ctxt ->
|
Lwt.return (Gas.consume ctxt Typecheck_costs.key_hash) >>=? fun ctxt ->
|
||||||
begin
|
begin match Signature.Public_key_hash.of_b58check_opt s with
|
||||||
try
|
| Some k -> return (k, ctxt)
|
||||||
return (Signature.Public_key_hash.of_b58check_exn s, ctxt)
|
| None -> fail (error ())
|
||||||
with _ -> fail (error ())
|
|
||||||
end
|
end
|
||||||
| Key_hash_t _, expr ->
|
| Key_hash_t _, expr ->
|
||||||
traced (fail (Invalid_kind (location expr, [ String_kind ; Bytes_kind ], kind expr)))
|
traced (fail (Invalid_kind (location expr, [ String_kind ; Bytes_kind ], kind expr)))
|
||||||
(* Signatures *)
|
(* Signatures *)
|
||||||
| Signature_t _, Bytes (_, bytes) (* As unparsed with [Optimized]. *) ->
|
| Signature_t _, Bytes (_, bytes) (* As unparsed with [Optimized]. *) ->
|
||||||
Lwt.return (Gas.consume ctxt Typecheck_costs.signature) >>=? fun ctxt ->
|
Lwt.return (Gas.consume ctxt Typecheck_costs.signature) >>=? fun ctxt ->
|
||||||
begin
|
begin match Data_encoding.Binary.of_bytes Signature.encoding bytes with
|
||||||
match Data_encoding.Binary.of_bytes Signature.encoding bytes with
|
|
||||||
| Some k -> return (k, ctxt)
|
| Some k -> return (k, ctxt)
|
||||||
| None -> fail (error ())
|
| None -> fail (error ())
|
||||||
end
|
end
|
||||||
| Signature_t _, String (_, s) (* As unparsed with [Readable]. *) ->
|
| Signature_t _, String (_, s) (* As unparsed with [Readable]. *) ->
|
||||||
Lwt.return (Gas.consume ctxt Typecheck_costs.signature) >>=? fun ctxt ->
|
Lwt.return (Gas.consume ctxt Typecheck_costs.signature) >>=? fun ctxt ->
|
||||||
begin
|
begin match Signature.of_b58check_opt s with
|
||||||
try
|
| Some s -> return (s, ctxt)
|
||||||
return (Signature.of_b58check_exn s, ctxt)
|
| None -> fail (error ())
|
||||||
with _ -> fail (error ())
|
|
||||||
end
|
end
|
||||||
| Signature_t _, expr ->
|
| Signature_t _, expr ->
|
||||||
traced (fail (Invalid_kind (location expr, [ String_kind ; Bytes_kind ], kind expr)))
|
traced (fail (Invalid_kind (location expr, [ String_kind ; Bytes_kind ], kind expr)))
|
||||||
(* Operations *)
|
(* Operations *)
|
||||||
| Operation_t _, Bytes (_, bytes) -> begin try
|
| Operation_t _, Bytes (_, bytes) ->
|
||||||
Lwt.return (Gas.consume ctxt (Typecheck_costs.operation bytes)) >>=? fun ctxt ->
|
Lwt.return (Gas.consume ctxt (Typecheck_costs.operation bytes)) >>=? fun ctxt ->
|
||||||
match Data_encoding.Binary.of_bytes
|
begin match Data_encoding.Binary.of_bytes Operation.internal_operation_encoding bytes with
|
||||||
Operation.internal_operation_encoding
|
|
||||||
bytes with
|
|
||||||
| Some op -> return (op, ctxt)
|
| Some op -> return (op, ctxt)
|
||||||
| None -> raise Not_found
|
| None -> fail (error ())
|
||||||
with _ ->
|
|
||||||
fail (error ())
|
|
||||||
end
|
end
|
||||||
| Operation_t _, expr ->
|
| Operation_t _, expr ->
|
||||||
traced (fail (Invalid_kind (location expr, [ Bytes_kind ], kind expr)))
|
traced (fail (Invalid_kind (location expr, [ Bytes_kind ], kind expr)))
|
||||||
|
Loading…
Reference in New Issue
Block a user