From a87fd484b40c013b17f54f40a32bb9dc942e0f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Wed, 1 Jun 2022 11:47:22 +0200 Subject: [PATCH] Alpha/Plugin: Add a private forge operations RPC --- src/proto_alpha/lib_plugin/plugin.ml | 38 +++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/proto_alpha/lib_plugin/plugin.ml b/src/proto_alpha/lib_plugin/plugin.ml index a4e87f1dd557..54f82a95312d 100644 --- a/src/proto_alpha/lib_plugin/plugin.ml +++ b/src/proto_alpha/lib_plugin/plugin.ml @@ -3521,7 +3521,9 @@ module RPC = struct let path = RPC_path.(path / "forge") - let operations = + let private_path = RPC_path.(path / "private" / "forge") + + let operation = RPC_service.post_service ~description:"Forge an operation" ~query:RPC_query.empty @@ -3529,6 +3531,20 @@ module RPC = struct ~output:bytes RPC_path.(path / "operations") + let operations_input_encoding = + let open Data_encoding in + obj2 + (req "branch" Tezos_base.Operation.shell_header_encoding) + (req "operations" (list Operation.contents_list_encoding)) + + let operations = + RPC_service.post_service + ~description:"Forge a list of operations" + ~query:RPC_query.empty + ~input:operations_input_encoding + ~output:(Data_encoding.list bytes) + RPC_path.(path / "operations") + let empty_proof_of_work_nonce = Bytes.make Constants_repr.proof_of_work_nonce_size '\000' @@ -3650,12 +3666,23 @@ module RPC = struct let register () = Registration.register0_noctxt ~chunked:true - S.operations + S.operation (fun () (shell, proto) -> return (Data_encoding.Binary.to_bytes_exn Operation.unsigned_encoding (shell, proto))) ; + Registration.register0_noctxt + ~chunked:true + S.operations + (fun () (shell, operations) -> + return + (List.map + (fun proto -> + Data_encoding.Binary.to_bytes_exn + Operation.unsigned_encoding + (shell, proto)) + operations)) ; Registration.register0_noctxt ~chunked:true S.protocol_data @@ -3759,7 +3786,7 @@ module RPC = struct :: ops in Environment.wrap_tzresult @@ Operation.of_list ops >>?= fun ops -> - RPC_context.make_call0 S.operations ctxt block () ({branch}, ops) + RPC_context.make_call0 S.operation ctxt block () ({branch}, ops) let reveal ctxt block ~branch ~source ~sourcePubKey ~counter ~fee () = operations @@ -3829,12 +3856,15 @@ module RPC = struct let operation ctxt block ~branch operation = RPC_context.make_call0 - S.operations + S.operation ctxt block () ({branch}, Contents_list (Single operation)) + let operations ctxt block ~branch operations = + RPC_context.make_call0 S.operations ctxt block () ({branch}, operations) + let endorsement ctxt b ~branch ~consensus_content () = operation ctxt b ~branch (Endorsement consensus_content) -- GitLab