From f7aa0398cab69200b87d2b6522c0fd9113c17142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Sun, 27 May 2018 22:56:41 +0200 Subject: [PATCH] Alpha/RPC: minor renaming --- .../lib_protocol/src/alpha_context.mli | 8 ++++---- .../lib_protocol/src/alpha_services.ml | 2 +- .../src/blinded_public_key_hash.mli | 3 +++ .../lib_protocol/src/contract_repr.ml | 2 +- .../lib_protocol/src/contract_repr.mli | 2 +- .../lib_protocol/src/contract_services.ml | 20 +++++++++---------- .../lib_protocol/src/cycle_repr.ml | 2 +- .../lib_protocol/src/cycle_repr.mli | 2 +- .../lib_protocol/src/delegate_services.ml | 8 ++++---- .../lib_protocol/src/raw_level_repr.ml | 2 +- .../lib_protocol/src/raw_level_repr.mli | 2 +- src/proto_alpha/lib_protocol/src/roll_repr.ml | 5 +++++ .../lib_protocol/src/roll_repr.mli | 1 + .../lib_protocol/src/voting_period_repr.ml | 2 +- .../lib_protocol/src/voting_period_repr.mli | 2 +- 15 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index a9bfac038..6a06951f0 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -79,7 +79,7 @@ module Raw_level : sig include BASIC_DATA type raw_level = t - val arg: raw_level RPC_arg.arg + val rpc_arg: raw_level RPC_arg.arg val diff: raw_level -> raw_level -> int32 @@ -95,7 +95,7 @@ module Cycle : sig include BASIC_DATA type cycle = t - val arg: cycle RPC_arg.arg + val rpc_arg: cycle RPC_arg.arg val root: cycle val succ: cycle -> cycle @@ -375,7 +375,7 @@ module Voting_period : sig include BASIC_DATA type voting_period = t - val arg: voting_period RPC_arg.arg + val rpc_arg: voting_period RPC_arg.arg val root: voting_period val succ: voting_period -> voting_period @@ -485,7 +485,7 @@ module Contract : sig include BASIC_DATA type contract = t - val arg: contract RPC_arg.arg + val rpc_arg: contract RPC_arg.arg val to_b58check: contract -> string val of_b58check: string -> contract tzresult diff --git a/src/proto_alpha/lib_protocol/src/alpha_services.ml b/src/proto_alpha/lib_protocol/src/alpha_services.ml index da4b62605..8c3d07ac4 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_services.ml +++ b/src/proto_alpha/lib_protocol/src/alpha_services.ml @@ -42,7 +42,7 @@ module Nonce = struct ~description: "Info about the nonce of a previous block." ~query: RPC_query.empty ~output: info_encoding - RPC_path.(custom_root / "context" / "nonces" /: Raw_level.arg) + RPC_path.(custom_root / "context" / "nonces" /: Raw_level.rpc_arg) end diff --git a/src/proto_alpha/lib_protocol/src/blinded_public_key_hash.mli b/src/proto_alpha/lib_protocol/src/blinded_public_key_hash.mli index 7e7da12cf..e5a8ac417 100644 --- a/src/proto_alpha/lib_protocol/src/blinded_public_key_hash.mli +++ b/src/proto_alpha/lib_protocol/src/blinded_public_key_hash.mli @@ -9,6 +9,9 @@ include S.HASH +val encoding : t Data_encoding.t +val rpc_arg : t RPC_arg.t + type activation_code val activation_code_encoding : activation_code Data_encoding.t diff --git a/src/proto_alpha/lib_protocol/src/contract_repr.ml b/src/proto_alpha/lib_protocol/src/contract_repr.ml index 0f56f6aee..58b67e18f 100644 --- a/src/proto_alpha/lib_protocol/src/contract_repr.ml +++ b/src/proto_alpha/lib_protocol/src/contract_repr.ml @@ -135,7 +135,7 @@ let incr_origination_nonce nonce = let origination_index = Int32.succ nonce.origination_index in { nonce with origination_index } -let arg = +let rpc_arg = let construct = to_b58check in let destruct hash = match of_b58check hash with diff --git a/src/proto_alpha/lib_protocol/src/contract_repr.mli b/src/proto_alpha/lib_protocol/src/contract_repr.mli index 8c124a0c3..b98faf464 100644 --- a/src/proto_alpha/lib_protocol/src/contract_repr.mli +++ b/src/proto_alpha/lib_protocol/src/contract_repr.mli @@ -58,7 +58,7 @@ val encoding : contract Data_encoding.t val origination_nonce_encoding : origination_nonce Data_encoding.t -val arg : contract RPC_arg.arg +val rpc_arg : contract RPC_arg.arg module Index : sig type t = contract diff --git a/src/proto_alpha/lib_protocol/src/contract_services.ml b/src/proto_alpha/lib_protocol/src/contract_services.ml index 990f56494..786b49abf 100644 --- a/src/proto_alpha/lib_protocol/src/contract_services.ml +++ b/src/proto_alpha/lib_protocol/src/contract_services.ml @@ -51,14 +51,14 @@ module S = struct ~description: "Access the balance of a contract." ~query: RPC_query.empty ~output: Tez.encoding - RPC_path.(custom_root /: Contract.arg / "balance") + RPC_path.(custom_root /: Contract.rpc_arg / "balance") let manager = RPC_service.get_service ~description: "Access the manager of a contract." ~query: RPC_query.empty ~output: Signature.Public_key_hash.encoding - RPC_path.(custom_root /: Contract.arg / "manager") + RPC_path.(custom_root /: Contract.rpc_arg / "manager") let manager_key = RPC_service.get_service @@ -67,56 +67,56 @@ module S = struct ~output: (obj2 (req "manager" Signature.Public_key_hash.encoding) (opt "key" Signature.Public_key.encoding)) - RPC_path.(custom_root /: Contract.arg / "manager_key") + RPC_path.(custom_root /: Contract.rpc_arg / "manager_key") let delegate = RPC_service.get_service ~description: "Access the delegate of a contract, if any." ~query: RPC_query.empty ~output: Signature.Public_key_hash.encoding - RPC_path.(custom_root /: Contract.arg / "delegate") + RPC_path.(custom_root /: Contract.rpc_arg / "delegate") let counter = RPC_service.get_service ~description: "Access the counter of a contract, if any." ~query: RPC_query.empty ~output: int32 - RPC_path.(custom_root /: Contract.arg / "counter") + RPC_path.(custom_root /: Contract.rpc_arg / "counter") let spendable = RPC_service.get_service ~description: "Tells if the contract tokens can be spent by the manager." ~query: RPC_query.empty ~output: bool - RPC_path.(custom_root /: Contract.arg / "spendable") + RPC_path.(custom_root /: Contract.rpc_arg / "spendable") let delegatable = RPC_service.get_service ~description: "Tells if the contract delegate can be changed." ~query: RPC_query.empty ~output: bool - RPC_path.(custom_root /: Contract.arg / "delegatable") + RPC_path.(custom_root /: Contract.rpc_arg / "delegatable") let script = RPC_service.get_service ~description: "Access the code and data of the contract." ~query: RPC_query.empty ~output: Script.encoding - RPC_path.(custom_root /: Contract.arg / "script") + RPC_path.(custom_root /: Contract.rpc_arg / "script") let storage = RPC_service.get_service ~description: "Access the data of the contract." ~query: RPC_query.empty ~output: Script.expr_encoding - RPC_path.(custom_root /: Contract.arg / "storage") + RPC_path.(custom_root /: Contract.rpc_arg / "storage") let info = RPC_service.get_service ~description: "Access the complete status of a contract." ~query: RPC_query.empty ~output: info_encoding - RPC_path.(custom_root /: Contract.arg) + RPC_path.(custom_root /: Contract.rpc_arg) let list = RPC_service.get_service diff --git a/src/proto_alpha/lib_protocol/src/cycle_repr.ml b/src/proto_alpha/lib_protocol/src/cycle_repr.ml index d6179d538..b8297513e 100644 --- a/src/proto_alpha/lib_protocol/src/cycle_repr.ml +++ b/src/proto_alpha/lib_protocol/src/cycle_repr.ml @@ -11,7 +11,7 @@ type t = int32 type cycle = t let encoding = Data_encoding.int32 -let arg = +let rpc_arg = let construct = Int32.to_string in let destruct str = match Int32.of_string str with diff --git a/src/proto_alpha/lib_protocol/src/cycle_repr.mli b/src/proto_alpha/lib_protocol/src/cycle_repr.mli index 3e4308d4f..194c920cb 100644 --- a/src/proto_alpha/lib_protocol/src/cycle_repr.mli +++ b/src/proto_alpha/lib_protocol/src/cycle_repr.mli @@ -11,7 +11,7 @@ type t type cycle = t include Compare.S with type t := t val encoding: cycle Data_encoding.t -val arg: cycle RPC_arg.arg +val rpc_arg: cycle RPC_arg.arg val pp: Format.formatter -> cycle -> unit val root: cycle diff --git a/src/proto_alpha/lib_protocol/src/delegate_services.ml b/src/proto_alpha/lib_protocol/src/delegate_services.ml index 3502a6e78..93cfed80d 100644 --- a/src/proto_alpha/lib_protocol/src/delegate_services.ml +++ b/src/proto_alpha/lib_protocol/src/delegate_services.ml @@ -314,8 +314,8 @@ module Baking_rights = struct let open RPC_query in query (fun levels cycles delegates max_priority all -> { levels ; cycles ; delegates ; max_priority ; all }) - |+ multi_field "level" Raw_level.arg (fun t -> t.levels) - |+ multi_field "cycle" Cycle.arg (fun t -> t.cycles) + |+ multi_field "level" Raw_level.rpc_arg (fun t -> t.levels) + |+ multi_field "cycle" Cycle.rpc_arg (fun t -> t.cycles) |+ multi_field "delegate" Signature.Public_key_hash.rpc_arg (fun t -> t.delegates) |+ opt_field "max_priority" RPC_arg.int (fun t -> t.max_priority) |+ flag "all" (fun t -> t.all) @@ -437,8 +437,8 @@ module Endorsing_rights = struct let open RPC_query in query (fun levels cycles delegates -> { levels ; cycles ; delegates }) - |+ multi_field "level" Raw_level.arg (fun t -> t.levels) - |+ multi_field "cycle" Cycle.arg (fun t -> t.cycles) + |+ multi_field "level" Raw_level.rpc_arg (fun t -> t.levels) + |+ multi_field "cycle" Cycle.rpc_arg (fun t -> t.cycles) |+ multi_field "delegate" Signature.Public_key_hash.rpc_arg (fun t -> t.delegates) |> seal diff --git a/src/proto_alpha/lib_protocol/src/raw_level_repr.ml b/src/proto_alpha/lib_protocol/src/raw_level_repr.ml index b00ec13c4..4d473bb52 100644 --- a/src/proto_alpha/lib_protocol/src/raw_level_repr.ml +++ b/src/proto_alpha/lib_protocol/src/raw_level_repr.ml @@ -12,7 +12,7 @@ type raw_level = t include (Compare.Int32 : Compare.S with type t := t) let encoding = Data_encoding.int32 let pp ppf level = Format.fprintf ppf "%ld" level -let arg = +let rpc_arg = let construct raw_level = Int32.to_string raw_level in let destruct str = match Int32.of_string str with diff --git a/src/proto_alpha/lib_protocol/src/raw_level_repr.mli b/src/proto_alpha/lib_protocol/src/raw_level_repr.mli index c70d9bd8a..40fe1615e 100644 --- a/src/proto_alpha/lib_protocol/src/raw_level_repr.mli +++ b/src/proto_alpha/lib_protocol/src/raw_level_repr.mli @@ -13,7 +13,7 @@ type t type raw_level = t val encoding: raw_level Data_encoding.t -val arg: raw_level RPC_arg.arg +val rpc_arg: raw_level RPC_arg.arg val pp: Format.formatter -> raw_level -> unit include Compare.S with type t := raw_level diff --git a/src/proto_alpha/lib_protocol/src/roll_repr.ml b/src/proto_alpha/lib_protocol/src/roll_repr.ml index 053cba14d..dcedbb4fd 100644 --- a/src/proto_alpha/lib_protocol/src/roll_repr.ml +++ b/src/proto_alpha/lib_protocol/src/roll_repr.ml @@ -18,6 +18,11 @@ let succ i = Int32.succ i let random sequence ~bound = Seed_repr.take_int32 sequence bound +let rpc_arg = + RPC_arg.like + RPC_arg.int32 + "roll" + let to_int32 v = v let (=) = Compare.Int32.(=) diff --git a/src/proto_alpha/lib_protocol/src/roll_repr.mli b/src/proto_alpha/lib_protocol/src/roll_repr.mli index 69035782a..ceaf736bd 100644 --- a/src/proto_alpha/lib_protocol/src/roll_repr.mli +++ b/src/proto_alpha/lib_protocol/src/roll_repr.mli @@ -11,6 +11,7 @@ type t = private int32 type roll = t val encoding: roll Data_encoding.t +val rpc_arg: roll RPC_arg.t val random: Seed_repr.sequence -> bound:roll -> roll * Seed_repr.sequence diff --git a/src/proto_alpha/lib_protocol/src/voting_period_repr.ml b/src/proto_alpha/lib_protocol/src/voting_period_repr.ml index 177a2cab1..e88bd9d9f 100644 --- a/src/proto_alpha/lib_protocol/src/voting_period_repr.ml +++ b/src/proto_alpha/lib_protocol/src/voting_period_repr.ml @@ -12,7 +12,7 @@ type voting_period = t include (Compare.Int32 : Compare.S with type t := t) let encoding = Data_encoding.int32 let pp ppf level = Format.fprintf ppf "%ld" level -let arg = +let rpc_arg = let construct voting_period = Int32.to_string voting_period in let destruct str = match Int32.of_string str with diff --git a/src/proto_alpha/lib_protocol/src/voting_period_repr.mli b/src/proto_alpha/lib_protocol/src/voting_period_repr.mli index d9d6f8c46..f92a7fdf4 100644 --- a/src/proto_alpha/lib_protocol/src/voting_period_repr.mli +++ b/src/proto_alpha/lib_protocol/src/voting_period_repr.mli @@ -10,7 +10,7 @@ type t type voting_period = t val encoding: voting_period Data_encoding.t -val arg: voting_period RPC_arg.arg +val rpc_arg: voting_period RPC_arg.arg val pp: Format.formatter -> voting_period -> unit include Compare.S with type t := voting_period