RPCs: make the result of [/operations/X] compatible with Alpha's [/helpers/parse/operation].
fixes #160
This commit is contained in:
parent
7e1cc171cc
commit
9872ff8b36
@ -26,7 +26,7 @@ let monitor cctxt ?contents ?check () =
|
|||||||
match bytes with
|
match bytes with
|
||||||
| None -> Lwt.return (Some { hash; content = None })
|
| None -> Lwt.return (Some { hash; content = None })
|
||||||
| Some ({ Store.Operation.shell ; proto } : Updater.raw_operation) ->
|
| 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
|
`Prevalidation ?check shell proto >>= function
|
||||||
| Ok proto -> Lwt.return (Some { hash ; content = Some (shell, proto) })
|
| Ok proto -> Lwt.return (Some { hash ; content = Some (shell, proto) })
|
||||||
| Error err ->
|
| Error err ->
|
||||||
|
@ -266,9 +266,10 @@ module Helpers = struct
|
|||||||
end
|
end
|
||||||
|
|
||||||
module Parse = struct
|
module Parse = struct
|
||||||
let operations cctxt
|
let operation cctxt block ?check shell proto =
|
||||||
block ?check shell bytes =
|
call_error_service1 cctxt
|
||||||
call_error_service1 cctxt Services.Helpers.Parse.operations block (shell, bytes, check)
|
Services.Helpers.Parse.operation block
|
||||||
|
(({ shell ; proto } : Updater.raw_operation), check)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -334,7 +334,7 @@ module Helpers : sig
|
|||||||
end
|
end
|
||||||
|
|
||||||
module Parse : sig
|
module Parse : sig
|
||||||
val operations:
|
val operation:
|
||||||
Client_commands.context ->
|
Client_commands.context ->
|
||||||
block -> ?check:bool -> Updater.shell_operation -> MBytes.t ->
|
block -> ?check:bool -> Updater.shell_operation -> MBytes.t ->
|
||||||
proto_operation tzresult Lwt.t
|
proto_operation tzresult Lwt.t
|
||||||
|
@ -406,10 +406,7 @@ module Operations = struct
|
|||||||
let bytes =
|
let bytes =
|
||||||
RPC.service
|
RPC.service
|
||||||
~input: empty
|
~input: empty
|
||||||
~output:
|
~output: Updater.raw_operation_encoding
|
||||||
(obj1 (req "data"
|
|
||||||
(describe ~title: "Tezos signed operation (hex encoded)"
|
|
||||||
(Updater.raw_operation_encoding))))
|
|
||||||
RPC.Path.(root / "operations" /: operations_arg)
|
RPC.Path.(root / "operations" /: operations_arg)
|
||||||
|
|
||||||
type list_param = {
|
type list_param = {
|
||||||
|
@ -583,17 +583,15 @@ module Helpers = struct
|
|||||||
|
|
||||||
module Parse = struct
|
module Parse = struct
|
||||||
|
|
||||||
let operations custom_root =
|
let operation custom_root =
|
||||||
RPC.service
|
RPC.service
|
||||||
~description:"Parse an operation"
|
~description:"Parse an operation"
|
||||||
~input:
|
~input:
|
||||||
(obj3
|
(merge_objs
|
||||||
(req "shell" Updater.shell_operation_encoding)
|
Updater.raw_operation_encoding
|
||||||
(req "proto"
|
(obj1 (opt "check_signature" bool)))
|
||||||
(describe ~title: "hex encoded operation" bytes))
|
|
||||||
(opt "check_signature" bool))
|
|
||||||
~output: (wrap_tzerror Operation.proto_operation_encoding)
|
~output: (wrap_tzerror Operation.proto_operation_encoding)
|
||||||
RPC.Path.(custom_root / "helpers" / "parse" / "operations" )
|
RPC.Path.(custom_root / "helpers" / "parse" / "operation" )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -470,8 +470,9 @@ let check_signature ctxt signature shell contents =
|
|||||||
Operation.check_signature key
|
Operation.check_signature key
|
||||||
{ signature ; shell ; contents ; hash = dummy_hash }
|
{ signature ; shell ; contents ; hash = dummy_hash }
|
||||||
|
|
||||||
let parse_operations ctxt (shell, bytes, check) =
|
let parse_operation ctxt
|
||||||
Operation.parse_proto bytes >>=? fun (proto, signature) ->
|
(({ shell ; proto } : Updater.raw_operation), check) =
|
||||||
|
Operation.parse_proto proto >>=? fun (proto, signature) ->
|
||||||
begin
|
begin
|
||||||
match check with
|
match check with
|
||||||
| Some true -> check_signature ctxt signature shell proto
|
| Some true -> check_signature ctxt signature shell proto
|
||||||
@ -479,7 +480,8 @@ let parse_operations ctxt (shell, bytes, check) =
|
|||||||
end >>=? fun () ->
|
end >>=? fun () ->
|
||||||
return proto
|
return proto
|
||||||
|
|
||||||
let () = register1 Services.Helpers.Parse.operations parse_operations
|
let () = register1 Services.Helpers.Parse.operation parse_operation
|
||||||
|
|
||||||
|
|
||||||
(*****)
|
(*****)
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ type raw_operation = {
|
|||||||
shell: shell_operation ;
|
shell: shell_operation ;
|
||||||
proto: MBytes.t ;
|
proto: MBytes.t ;
|
||||||
}
|
}
|
||||||
|
val raw_operation_encoding: raw_operation Data_encoding.t
|
||||||
|
|
||||||
|
|
||||||
(** The version agnostic toplevel structure of blocks. *)
|
(** The version agnostic toplevel structure of blocks. *)
|
||||||
|
Loading…
Reference in New Issue
Block a user