RPCs: make the result of [/operations/X] compatible with Alpha's [/helpers/parse/operation].

fixes #160
This commit is contained in:
Benjamin Canou 2017-03-21 17:23:06 +01:00
parent 7e1cc171cc
commit 9872ff8b36
7 changed files with 18 additions and 19 deletions

View File

@ -26,7 +26,7 @@ let monitor cctxt ?contents ?check () =
match bytes with
| None -> Lwt.return (Some { hash; content = None })
| Some ({ Store.Operation.shell ; proto } : Updater.raw_operation) ->
Client_proto_rpcs.Helpers.Parse.operations cctxt
Client_proto_rpcs.Helpers.Parse.operation cctxt
`Prevalidation ?check shell proto >>= function
| Ok proto -> Lwt.return (Some { hash ; content = Some (shell, proto) })
| Error err ->

View File

@ -266,9 +266,10 @@ module Helpers = struct
end
module Parse = struct
let operations cctxt
block ?check shell bytes =
call_error_service1 cctxt Services.Helpers.Parse.operations block (shell, bytes, check)
let operation cctxt block ?check shell proto =
call_error_service1 cctxt
Services.Helpers.Parse.operation block
(({ shell ; proto } : Updater.raw_operation), check)
end
end

View File

@ -334,7 +334,7 @@ module Helpers : sig
end
module Parse : sig
val operations:
val operation:
Client_commands.context ->
block -> ?check:bool -> Updater.shell_operation -> MBytes.t ->
proto_operation tzresult Lwt.t

View File

@ -406,10 +406,7 @@ module Operations = struct
let bytes =
RPC.service
~input: empty
~output:
(obj1 (req "data"
(describe ~title: "Tezos signed operation (hex encoded)"
(Updater.raw_operation_encoding))))
~output: Updater.raw_operation_encoding
RPC.Path.(root / "operations" /: operations_arg)
type list_param = {

View File

@ -583,17 +583,15 @@ module Helpers = struct
module Parse = struct
let operations custom_root =
let operation custom_root =
RPC.service
~description:"Parse an operation"
~input:
(obj3
(req "shell" Updater.shell_operation_encoding)
(req "proto"
(describe ~title: "hex encoded operation" bytes))
(opt "check_signature" bool))
(merge_objs
Updater.raw_operation_encoding
(obj1 (opt "check_signature" bool)))
~output: (wrap_tzerror Operation.proto_operation_encoding)
RPC.Path.(custom_root / "helpers" / "parse" / "operations" )
RPC.Path.(custom_root / "helpers" / "parse" / "operation" )
end

View File

@ -470,8 +470,9 @@ let check_signature ctxt signature shell contents =
Operation.check_signature key
{ signature ; shell ; contents ; hash = dummy_hash }
let parse_operations ctxt (shell, bytes, check) =
Operation.parse_proto bytes >>=? fun (proto, signature) ->
let parse_operation ctxt
(({ shell ; proto } : Updater.raw_operation), check) =
Operation.parse_proto proto >>=? fun (proto, signature) ->
begin
match check with
| Some true -> check_signature ctxt signature shell proto
@ -479,7 +480,8 @@ let parse_operations ctxt (shell, bytes, check) =
end >>=? fun () ->
return proto
let () = register1 Services.Helpers.Parse.operations parse_operations
let () = register1 Services.Helpers.Parse.operation parse_operation
(*****)

View File

@ -16,6 +16,7 @@ type raw_operation = {
shell: shell_operation ;
proto: MBytes.t ;
}
val raw_operation_encoding: raw_operation Data_encoding.t
(** The version agnostic toplevel structure of blocks. *)