diff --git a/src/lib_client_base/client_tags.ml b/src/lib_client_base/client_tags.ml deleted file mode 100644 index b8b5be6e5..000000000 --- a/src/lib_client_base/client_tags.ml +++ /dev/null @@ -1,84 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2018. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -module Tag = struct - - type t = string list - - let add tags t = - t :: tags - - let remove tags t = - let rec aux acc = function - | [] -> raise Not_found - | x :: ts when x = t -> (List.rev acc) @ ts - | x :: ts -> aux (x :: acc) ts - in - aux [] tags - - let encoding = - Data_encoding.(list string) - -end - -module type Entity = sig - val name : string -end - -module Tags (Entity : Entity) = struct - - include Client_aliases.Alias (struct - - type t = Tag.t - - let encoding = Tag.encoding - - (* Split a string of tags separated by commas, and possibly spaces *) - let of_source tags_str = - let rec aux tags s = - try - let idx = String.index s ',' in - let tag = String.(trim (sub s 0 idx)) in - let tail = String.(sub s (idx + 1) (length s - (idx + 1))) in - aux (tag :: tags) tail - with - | Not_found -> - String.(trim s) :: tags - in - return (aux [] tags_str) - - let to_source tags = - return (String.concat ", " tags) - - let name = Entity.name ^ " tag" - - end) - - let tag_param ?(name = "tag") ?(desc = "list of tags") next = - let desc = - desc ^ "\n" - ^ "can be one or multiple tags separated by commas" in - Clic.( - param ~name ~desc - (parameter (fun _ s -> of_source s)) - next) - - let rev_find_by_tag cctxt tag = - load cctxt >>=? fun tags -> - try return (Some (List.find (fun (_, v) -> List.mem tag v) tags |> fst)) - with Not_found -> return None - - let filter cctxt pred = - load cctxt >>=? fun tags -> - return (List.filter pred tags) - - let filter_by_tag cctxt tag = - filter cctxt (fun (_, v) -> List.mem tag v) - -end diff --git a/src/lib_client_base/client_tags.mli b/src/lib_client_base/client_tags.mli deleted file mode 100644 index 1bedd7e4a..000000000 --- a/src/lib_client_base/client_tags.mli +++ /dev/null @@ -1,49 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2018. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -module Tag : sig - - type t = string list - - val add: t -> string -> t - val remove: t -> string -> t - val encoding: t Data_encoding.t - -end - -module type Entity = sig - val name : string -end - -module Tags (Entity : Entity) : sig - - include Client_aliases.Alias with type t = Tag.t - - val tag_param: - ?name:string -> - ?desc:string -> - ('a, 'ctx) Clic.params -> - (Tag.t -> 'a, 'ctx) Clic.params - - val rev_find_by_tag: - #Client_context.full -> - string -> - string option tzresult Lwt.t - - val filter: - #Client_context.full -> - (string * t -> bool) -> - (string * t) list tzresult Lwt.t - - val filter_by_tag: - #Client_context.full -> - string -> - (string * t) list tzresult Lwt.t - -end diff --git a/src/proto_alpha/lib_client/client_proto_contracts.ml b/src/proto_alpha/lib_client/client_proto_contracts.ml index fb8a73f21..fee3345ec 100644 --- a/src/proto_alpha/lib_client/client_proto_contracts.ml +++ b/src/proto_alpha/lib_client/client_proto_contracts.ml @@ -110,10 +110,6 @@ module ContractAlias = struct end -module Contract_tags = Client_tags.Tags (struct - let name = "contract" - end) - let list_contracts cctxt = RawContractAlias.load cctxt >>=? fun raw_contracts -> Lwt_list.map_s diff --git a/src/proto_alpha/lib_client/client_proto_contracts.mli b/src/proto_alpha/lib_client/client_proto_contracts.mli index a1948d8b6..9ffd477bb 100644 --- a/src/proto_alpha/lib_client/client_proto_contracts.mli +++ b/src/proto_alpha/lib_client/client_proto_contracts.mli @@ -54,7 +54,3 @@ val get_delegate: block:Shell_services.block -> Contract.t -> public_key_hash option tzresult Lwt.t - -module Contract_tags : module type of Client_tags.Tags (struct - let name = "contract" - end) diff --git a/src/proto_alpha/lib_client_commands/client_proto_contracts_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_contracts_commands.ml index 272d9c53b..42e1043cb 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_contracts_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_contracts_commands.ml @@ -66,40 +66,4 @@ let commands () = cctxt#message "%a\n%!" Contract.pp contract >>= fun () -> return ()) ; - command ~group ~desc: "Tag a contract in the wallet." - no_options - (prefixes [ "tag" ; "contract" ] - @@ RawContractAlias.alias_param - @@ prefixes [ "with" ] - @@ Contract_tags.tag_param - @@ stop) - (fun () (alias, _contract) new_tags cctxt -> - Contract_tags.find_opt cctxt alias >>=? fun tags -> - let new_tags = - match tags with - | None -> new_tags - | Some tags -> List.merge2 tags new_tags in - Contract_tags.update cctxt alias new_tags) ; - - command ~group ~desc: "Remove tag(s) from a contract in the wallet." - no_options - (prefixes [ "untag" ; "contract" ] - @@ RawContractAlias.alias_param - @@ prefixes [ "with" ] - @@ Contract_tags.tag_param - @@ stop) - (fun () (alias, _contract) new_tags cctxt -> - Contract_tags.find_opt cctxt alias >>=? fun tags -> - let new_tags = - match tags with - | None -> [] - | Some tags -> - List.merge_filter2 - ~f:(fun x1 x2 -> match x1, x2 with - | None, None -> assert false - | None, Some _ -> None - | Some t1, Some t2 when t1 = t2 -> None - | Some t1, _ -> Some t1) tags new_tags in - Contract_tags.update cctxt alias new_tags) ; - ]