diff --git a/.dockerignore b/.dockerignore index e79905563..6b40b41f4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,13 +7,10 @@ tezos-node tezos-protocol-compiler tezos-client -tezos-webclient tezos-attacker src/Makefile.local -src/webclient_static.ml - src/node/updater/environment_gen src/node/updater/proto_environment.mli src/compiler/embedded_cmis.ml @@ -25,12 +22,6 @@ src/client/embedded/**/_tzbuild src/client/embedded/alpha/concrete_lexer.ml src/client/embedded/alpha/concrete_parser.ml src/client/embedded/alpha/concrete_parser.mli -src/client/embedded/alpha/webclient_proto_static.ml -src/client/embedded/alpha/main.byte -src/client/embedded/alpha/webclient_static/main.js -src/client/embedded/alpha/webclient/browser/main.byte -src/client/embedded/alpha/webclient/static/main.js -src/client/embedded/alpha/webclient/webclient_proto_static.ml test/reports test/**/test-* diff --git a/.gitignore b/.gitignore index 19ed1f401..5dc9c2aa5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,15 +2,12 @@ /tezos-node /tezos-protocol-compiler /tezos-client -/tezos-webclient /tezos-attacker /src/.ocamlinit.utils /src/.ocamlinit.node /src/Makefile.local -/src/webclient_static.ml - /src/compiler/environment_gen /src/node/updater/proto_environment.mli /src/compiler/embedded_cmis.ml @@ -22,12 +19,6 @@ /src/client/embedded/alpha/concrete_lexer.ml /src/client/embedded/alpha/concrete_parser.ml /src/client/embedded/alpha/concrete_parser.mli -/src/client/embedded/alpha/webclient_proto_static.ml -/src/client/embedded/alpha/main.byte -/src/client/embedded/alpha/webclient_static/main.js -/src/client/embedded/alpha/webclient/browser/main.byte -/src/client/embedded/alpha/webclient/static/main.js -/src/client/embedded/alpha/webclient/webclient_proto_static.ml /test/reports diff --git a/src/Makefile b/src/Makefile index 56fdf1639..9c7cf31a7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,10 +6,9 @@ include Makefile.files TZCOMPILER=../tezos-protocol-compiler TZNODE=../tezos-node TZCLIENT=../tezos-client -TZWEBCLIENT=../tezos-webclient TZATTACKER=../tezos-attacker -all: ${TZCOMPILER} ${TZNODE} ${TZCLIENT} # ${TZWEBCLIENT} ${TZATTACKER} +all: ${TZCOMPILER} ${TZNODE} ${TZCLIENT} # ${TZATTACKER} NODEPS := @@ -241,47 +240,6 @@ ${TZCLIENT}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa \ clean:: -rm -f ${TZCLIENT} -############################################################################ -## Webclient program -############################################################################ - -WEBCLIENT_OBJS := \ - ${WEBCLIENT_IMPLS:.ml=.cmx} ${WEBCLIENT_IMPLS:.ml=.ml.deps} \ - ${WEBCLIENT_LIB_IMPLS:.ml=.cmx} ${WEBCLIENT_LIB_IMPLS:.ml=.ml.deps} \ - ${WEBCLIENT_LIB_INTFS:.mli=.cmi} ${WEBCLIENT_LIB_INTFS:.mli=.mli.deps} \ - ${TZWEBCLIENT} -${WEBCLIENT_OBJS}: PACKAGES=${WEBCLIENT_PACKAGES} -${WEBCLIENT_OBJS}: SOURCE_DIRECTORIES=${WEBCLIENT_SOURCE_DIRECTORIES} -${WEBCLIENT_OBJS}: OPENED_MODULES=${WEBCLIENT_OPENED_MODULES} - -${WEBCLIENT_LIB_IMPLS:.ml=.cmx} ${WEBCLIENT_LIB_IMPLS:.ml=.ml.deps}: TARGET="(webclient.cmxa)" -${WEBCLIENT_LIB_INTFS:.mli=.cmi} ${WEBCLIENT_LIB_INTFS:.mli=.mli.deps}: TARGET="(webclient.cmxa)" - -${EMBEDDED_WEBCLIENT_VERSIONS}: webclient.cmxa -${WEBCLIENT_IMPLS:.ml=.cmx}: ${EMBEDDED_CLIENT_VERSIONS} ${EMBEDDED_WEBCLIENT_VERSIONS} - -webclient.cmxa: ${WEBCLIENT_LIB_IMPLS:.ml=.cmx} client.cmxa - @echo LINK $(notdir $@) - ${OCAMLOPT} ${OCAMLFLAGS} -a -o $@ ${WEBCLIENT_LIB_IMPLS:.ml=.cmx} - -${TZWEBCLIENT}: minutils.cmxa utils.cmxa compiler.cmxa node.cmxa \ - client.cmxa webclient.cmxa \ - ${EMBEDDED_CLIENT_PROTOCOLS} \ - ${EMBEDDED_CLIENT_VERSIONS} \ - ${EMBEDDED_WEBCLIENT_VERSIONS} \ - ${WEBCLIENT_IMPLS:.ml=.cmx} - @echo LINK $(notdir $@) - @${OCAMLOPT} -linkpkg ${OCAMLFLAGS} -o $@ $^ - -clean:: - -rm -f ${TZCLIENT} - -webclient_static.ml: $(shell find webclient_static/) - ocp-ocamlres webclient_static -o $@ - -partial-clean:: - -rm -f webclient_static.ml - ############################################################################ ## Generic rules ############################################################################ @@ -325,9 +283,7 @@ DEPENDS := $(filter-out $(NO_DEPS), \ $(NODE_INTFS) $(NODE_IMPLS) \ $(CLIENT_LIB_INTFS) $(CLIENT_LIB_IMPLS) \ $(CLIENT_INTFS) $(CLIENT_IMPLS) \ - $(WEBCLIENT_LIB_INTFS) $(WEBCLIENT_LIB_IMPLS) \ $(ATTACKER_LIB_INTFS) $(ATTACKER_LIB_IMPLS) \ - $(WEBCLIENT_INTFS) $(WEBCLIENT_IMPLS) \ $(ATTACKER_INTFS) $(ATTACKER_IMPLS) \ ) DEPENDS_BYTECODE := \ @@ -401,16 +357,9 @@ partial-clean:: client/embedded/client_%.cmx: \ $(patsubst %.ml, %.cmx, $(NODE_LIB_IMPLS) $(CLIENT_LIB_IMPLS)) \ proto/client_embedded_proto_%.cmxa \ - $$(shell find client/embedded/% \( -name webclient -or -name _tzbuild \) -prune -or \( -name \*.ml -print -or -name \*.mli -print \)) + $$(shell find client/embedded/% \( -name _tzbuild \) -prune -or \( -name \*.ml -print -or -name \*.mli -print \)) @$(MAKE) -C client/embedded/$* ../client_$*.cmx -client/embedded/webclient_%.cmx: \ - client/embedded/client_%.cmx \ - minutils.cma \ - $$(shell find client/embedded/%/webclient -name \*.ml -or -name \*.mli 2>/dev/null) \ - $$(shell find client/embedded/%/webclient/static/ 2>/dev/null) - @$(MAKE) -C client/embedded/$* ../webclient_$*.cmx - partial-clean:: -for d in $$(ls -d client/embedded/*/) ; do make clean -C $$d ; done -rm -f client/embedded/*.cm* client/embedded/*.o diff --git a/src/Makefile.files b/src/Makefile.files index c7413ea86..df5c66c2c 100644 --- a/src/Makefile.files +++ b/src/Makefile.files @@ -376,29 +376,3 @@ CLIENT_VERSIONS := \ EMBEDDED_CLIENT_VERSIONS := \ $(patsubst %,${SRCDIR}/client/embedded/client_%.cmx, \ ${CLIENT_VERSIONS}) - -############################################################################ -## Web-Client program -############################################################################ - -# we do not include 'node/main' -WEBCLIENT_SOURCE_DIRECTORIES := \ - ${NODE_LIB_SOURCE_DIRECTORIES} \ - ${SRCDIR}/client ${SRCDIR}/client/embedded - -WEBCLIENT_OPENED_MODULES := Error_monad Hash Utils Tezos_data - -WEBCLIENT_LIB_INTFS := \ - -WEBCLIENT_LIB_IMPLS := \ - client/webclient_version.ml \ - -WEBCLIENT_IMPLS := \ - webclient_static.ml \ - webclient_main.ml - -EMBEDDED_WEBCLIENT_VERSIONS := \ - $(patsubst ${SRCDIR}/client/embedded/%/, \ - ${SRCDIR}/client/embedded/webclient_%.cmx, \ - $(shell ls -d ${SRCDIR}/client/embedded/*/)) - diff --git a/src/client/embedded/Makefile.shared b/src/client/embedded/Makefile.shared index 4c850a33d..3c4b859a8 100644 --- a/src/client/embedded/Makefile.shared +++ b/src/client/embedded/Makefile.shared @@ -1,7 +1,6 @@ all: \ - ../client_$(PROTO_VERSION).cmx \ - ../webclient_$(PROTO_VERSION).cmx + ../client_$(PROTO_VERSION).cmx -include ../../../Makefile.local include ../../../Makefile.config @@ -42,33 +41,11 @@ ${OBJS} ${OBJS_DEPS} ../client_$(PROTO_VERSION).cmx: \ ${OBJS} ${OBJS_DEPS} ../client_$(PROTO_VERSION).cmx: \ ../../../proto/client_embedded_proto_${PROTO_VERSION}.cmxa -WEBOBJS := \ - ${WEBCLIENT_IMPLS:.ml=.cmx} ${WEBCLIENT_INTFS:.mli=.cmi} -WEBOBJS_DEPENDS := \ - ${WEBCLIENT_IMPLS:.ml=.ml.deps} ${WEBCLIENT_INTFS:.mli=.mli.deps} - -${WEBOBJS} ${WEBOBJS_DEPS}: TARGET="(webclient_$(PROTO_VERSION).cmx)" -${WEBOBJS} ${WEBOBJS_DEPS}: SOURCE_DIRECTORIES += .. -${WEBOBJS} ${WEBOBJS_DEPS}: OPENED_MODULES += Client_${PROTO_VERSION} -${WEBOBJS}: EXTRA_OCAMLFLAGS = -for-pack Webclient_$(PROTO_VERSION) -../client_$(PROTO_VERSION).cmx: EXTRA_OCAMLFLAGS = -${WEBOBJS} ${WEBOBJS_DEPS} ../webclient_$(PROTO_VERSION).cmx: \ - PACKAGES=lwt ocplib-json-typed sodium ocplib-ocamlres -${WEBOBJS} ${WEBOBJS_DEPS} ../webclient_$(PROTO_VERSION).cmx: \ - ../../../proto/client_embedded_proto_${PROTO_VERSION}.cmxa -${WEBOBJS} ../webclient_$(PROTO_VERSION).cmx: \ - ../client_${PROTO_VERSION}.cmx - ../client_$(PROTO_VERSION).cmx: $(patsubst %.ml, %.cmx, ${CLIENT_IMPLS}) @echo LINK $(notdir $@) @$(OCAMLOPT) -linkall ${OCAMLFLAGS} -pack -o $@ \ $(patsubst %.ml, %.cmx, ${CLIENT_IMPLS}) -../webclient_$(PROTO_VERSION).cmx: $(patsubst %.ml, %.cmx, ${WEBCLIENT_IMPLS}) - @echo LINK $(notdir $@) - @$(OCAMLOPT) -linkall ${OCAMLFLAGS} -pack -o $@ \ - $(patsubst %.ml, %.cmx, ${WEBCLIENT_IMPLS}) - %.cmx: %.ml @echo OCAMLOPT ${TARGET} $(notdir $@) @$(OCAMLOPT) ${OCAMLFLAGS} -c $< @@ -92,7 +69,6 @@ ${WEBOBJS} ../webclient_$(PROTO_VERSION).cmx: \ .PHONY: clean clean:: -rm -f ../client_$(PROTO_VERSION).cm* ../client_$(PROTO_VERSION).o - -rm -f ../webclient_$(PROTO_VERSION).cm* ../webclient_$(PROTO_VERSION).o -rm -f *.cm* *~ *.o *.a *.deps *.deps.byte -rm -rf _tzbuild -rm -f .depend @@ -104,8 +80,7 @@ endif predepend: DEPENDS += \ - $(patsubst %,%.deps,${CLIENT_INTFS} ${CLIENT_IMPLS}) \ - $(patsubst %,%.deps,${WEBCLIENT_INTFS} ${WEBCLIENT_IMPLS}) + $(patsubst %,%.deps,${CLIENT_INTFS} ${CLIENT_IMPLS}) DEPENDS := $(filter-out ${NODEPENDS}, ${DEPENDS}) .SECONDARY: ${DEPENDS} diff --git a/src/client/embedded/alpha/Makefile b/src/client/embedded/alpha/Makefile index d9e0be83b..0638c88b0 100644 --- a/src/client/embedded/alpha/Makefile +++ b/src/client/embedded/alpha/Makefile @@ -22,78 +22,16 @@ CLIENT_IMPLS := \ client_proto_nonces.ml \ client_proto_main.ml -WEBCLIENT_INTFS := \ - webclient/shared/webclient_proto_services.mli - -WEBCLIENT_IMPLS := \ - webclient/webclient_proto_static.ml \ - webclient/shared/webclient_proto_services.ml \ - webclient/webclient_proto_service_directory.ml \ - webclient/webclient_proto_main.ml - -SOURCE_DIRECTORIES := webclient/shared webclient/browser webclient - -include baker/Makefile -JS_IMPLS := \ - webclient/shared/webclient_proto_services.ml \ - webclient/browser/webclient_main.ml - -JS_INTFS := \ - webclient/shared/webclient_proto_services.mli - -JS_DEPS := $(patsubst %,%.deps.byte,${JS_IMPLS} ${JS_INTFS}) - -DEPENDS += ${JS_DEPS} - -# the generated .ml depends on the result of the bytecode compilation -NODEPENDS := webclient/webclient_proto_static.ml.deps - include ../Makefile.shared -${WEBOBJS}: OPENED_MODULES += Environment Tezos_context ${OBJS}: OPENED_MODULES += Environment Tezos_context predepend: concrete_parser.ml concrete_lexer.ml -webclient/webclient_proto_static.ml: $(shell find webclient/static/*) webclient/static/main.js - ocp-ocamlres webclient/static -o $@ - -webclient/webclient_proto_main.cmx: webclient/webclient_proto_static.cmx - .PHONY: clean clean:: - -rm -f webclient/webclient_proto_static.ml - -rm -f webclient/*/*.cm* webclient/*/*~ webclient/*/*.o webclient/*/*.a - -rm -f webclient/*/*.deps webclient/*/*.deps.byte -rm -f baker/*.cm* baker/*~ baker/*.o baker/*.a -rm -f baker/*.deps baker/*.deps.byte -rm -f concrete_lexer.ml concrete_parser.ml concrete_parser.mli - -rm -f webclient/static/main.js - -.INTERMEDIATE: webclient/browser/main.byte - -JS_PACKAGES := \ - lwt \ - cstruct \ - ocplib-json-typed.browser \ - ocplib-json-typed.bson \ - ocplib-resto.directory \ - js_of_ocaml.tyxml \ - js_of_ocaml.ppx -${JS_DEPS} ${JS_IMPLS:.ml=.cmo} ${JS_INTFS:.mli=.cmi} webclient/browser/main.byte: \ - PACKAGES=${JS_PACKAGES} -${JS_DEPS} ${JS_IMPLS:.ml=.cmo} ${JS_INTFS:.mli=.cmi} webclient/browser/main.byte: \ - OPENED_MODULES= -${JS_DEPS} ${JS_IMPLS:.ml=.cmo} ${JS_INTFS:.mli=.cmi} webclient/browser/main.byte: \ - SOURCE_DIRECTORIES=../../../minutils webclient/shared webclient/browser - -webclient/static/main.js: webclient/browser/main.byte - @echo JS_OF_OCAML $(notdir $@) - @js_of_ocaml +weak.js $< -o $@ - -webclient/browser/main.byte: \ - ../../../minutils.cma \ - ${JS_IMPLS:.ml=.cmo} - @echo LINK $(notdir $@) - ${OCAMLC} ${OCAMLFLAGS} -o $@ $^ -linkpkg diff --git a/src/client/embedded/alpha/webclient/.merlin b/src/client/embedded/alpha/webclient/.merlin deleted file mode 100644 index 4906c83c7..000000000 --- a/src/client/embedded/alpha/webclient/.merlin +++ /dev/null @@ -1,5 +0,0 @@ -REC -B browser/ -S browser/ -B shared/ -S shared/ diff --git a/src/client/embedded/alpha/webclient/browser/.merlin b/src/client/embedded/alpha/webclient/browser/.merlin deleted file mode 100644 index b19c07692..000000000 --- a/src/client/embedded/alpha/webclient/browser/.merlin +++ /dev/null @@ -1,9 +0,0 @@ -B ../../../../../minutils -S ../../../../../minutils -B ../shared -S ../shared -PKG lwt -PKG ocplib-json-typed.bson -PKG ocplib-resto.directory \ -PKG js_of_ocaml.ppx -PKG js_of_ocaml.tyxml diff --git a/src/client/embedded/alpha/webclient/browser/webclient_main.ml b/src/client/embedded/alpha/webclient/browser/webclient_main.ml deleted file mode 100644 index 39c38e53b..000000000 --- a/src/client/embedded/alpha/webclient/browser/webclient_main.ml +++ /dev/null @@ -1,54 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2016. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -open Lwt.Infix - -module Services = Webclient_proto_services.Make (struct - type root = unit - end) - -let call_service service params input = - let write_json_body json = - let jsobj = - Json_repr.convert - (module Json_repr.Ezjsonm) - (module Json_repr_browser.Repr) - json in - Js._JSON##stringify jsobj in - let read_json_body body = - Json_repr.convert - (module Json_repr_browser.Repr) - (module Json_repr.Ezjsonm) - (Js._JSON##parse body) in - let meth, path, json = RPC.forge_request service params input in - let meth_str = RPC.string_of_method meth in - let url = String.concat "/" path in - let xhr = XmlHttpRequest.create () in - let t, u = Lwt.wait () in - xhr##.onreadystatechange := Js.wrap_callback (fun _ -> - if xhr##.readyState = XmlHttpRequest.DONE then - let response = read_json_body xhr##.responseText in - Lwt.wakeup u response) ; - xhr##_open (Js.string meth_str) (Js.string url) Js._true ; - xhr##send (Js.Opt.return (write_json_body json)) ; - t >>= fun json -> - match RPC.read_answer service json with - | Ok res -> Lwt.return res - | Error msg -> Lwt.fail_with msg - -let () = Lwt.async @@ fun () -> - call_service Services.contracts () () >>= fun names -> - call_service Services.hash () () >>= fun hash -> - let list = Tyxml_js.Html.(ul (List.map (fun n -> (li [ pcdata n ])) names)) in - Tyxml_js.Register.id "receptacle" - Tyxml_js.Html. - [ h2 [ pcdata "Block: " ; pcdata hash ] ; - h2 [ pcdata "Contract aliases:" ] ; - list ] ; - Lwt.return () diff --git a/src/client/embedded/alpha/webclient/shared/.merlin b/src/client/embedded/alpha/webclient/shared/.merlin deleted file mode 100644 index fe28cdf14..000000000 --- a/src/client/embedded/alpha/webclient/shared/.merlin +++ /dev/null @@ -1,5 +0,0 @@ -B ../../../../../minutils -S ../../../../../minutils -PKG lwt -PKG ocplib-json-typed.bson -PKG ocplib-resto.directory diff --git a/src/client/embedded/alpha/webclient/shared/webclient_proto_services.ml b/src/client/embedded/alpha/webclient/shared/webclient_proto_services.ml deleted file mode 100644 index d36d785a0..000000000 --- a/src/client/embedded/alpha/webclient/shared/webclient_proto_services.ml +++ /dev/null @@ -1,30 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2016. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -module type RPC_CONTEXT = sig - type root -end - -module Make (RPC_context : RPC_CONTEXT) = struct - - let box_result field enc = - let open Data_encoding in - obj1 (req field enc) - - let contracts = - let input = Data_encoding.empty in - let output = box_result "contracts" Data_encoding.(list string) in - RPC.service ~input ~output RPC.Path.(root / "contracts") - - let hash = - let input = Data_encoding.empty in - let output = box_result "hash" Data_encoding.string in - RPC.service ~input ~output RPC.Path.(root / "hash") - -end diff --git a/src/client/embedded/alpha/webclient/shared/webclient_proto_services.mli b/src/client/embedded/alpha/webclient/shared/webclient_proto_services.mli deleted file mode 100644 index 7d19597e7..000000000 --- a/src/client/embedded/alpha/webclient/shared/webclient_proto_services.mli +++ /dev/null @@ -1,19 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2016. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -module type RPC_CONTEXT = sig - type root -end - -module Make (RPC_context : RPC_CONTEXT) : sig - val contracts : - (RPC_context.root, RPC_context.root, unit, string list) RPC.service - val hash : - (RPC_context.root, RPC_context.root, unit, string) RPC.service -end diff --git a/src/client/embedded/alpha/webclient/static/index.html b/src/client/embedded/alpha/webclient/static/index.html deleted file mode 100644 index 65f7743f8..000000000 --- a/src/client/embedded/alpha/webclient/static/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - Tezos Web Client :: Bootstrap Version - - - - -

Tezos Web client :: Bootstrap Version

-
- - diff --git a/src/client/embedded/alpha/webclient/static/not_found.html b/src/client/embedded/alpha/webclient/static/not_found.html deleted file mode 100644 index 467aceb19..000000000 --- a/src/client/embedded/alpha/webclient/static/not_found.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - Tezos Web Client :: Bootstrap Version - - - -

Not Found

- - diff --git a/src/client/embedded/alpha/webclient/webclient_proto_main.ml b/src/client/embedded/alpha/webclient/webclient_proto_main.ml deleted file mode 100644 index 9b6607795..000000000 --- a/src/client/embedded/alpha/webclient/webclient_proto_main.ml +++ /dev/null @@ -1,15 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2016. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - - -let () = - Webclient_version.register_services - Client_proto_main.protocol Webclient_proto_service_directory.root ; - Webclient_version.register_static_files - Client_proto_main.protocol Webclient_proto_static.root diff --git a/src/client/embedded/alpha/webclient/webclient_proto_service_directory.ml b/src/client/embedded/alpha/webclient/webclient_proto_service_directory.ml deleted file mode 100644 index e528213ff..000000000 --- a/src/client/embedded/alpha/webclient/webclient_proto_service_directory.ml +++ /dev/null @@ -1,26 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2016. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -module Services = Webclient_proto_services.Make (struct - type root = Node_rpc_services.Blocks.block - end) - -let cctxt = Client_commands.ignore_context - -let root = - let root = - RPC.register RPC.empty Services.contracts @@ fun _block () -> - Client_proto_contracts.RawContractAlias.load cctxt >>= fun list -> - let (names, _) = List.split list in - RPC.Answer.return names in - let root = - RPC.register root Services.hash @@ fun block () -> - Client_node_rpcs.(call_service1 cctxt Node_rpc_services.Blocks.hash block ()) >>= fun res -> - RPC.Answer.return (Hash.Block_hash.to_b58check res) in - root diff --git a/src/client/webclient_version.ml b/src/client/webclient_version.ml deleted file mode 100644 index 9c4c3cde0..000000000 --- a/src/client/webclient_version.ml +++ /dev/null @@ -1,28 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2016. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -(* Tezos Web Interface - version dependent services *) - -let contextual_static_files : string OCamlRes.Res.root Protocol_hash.Table.t = - Protocol_hash.Table.create 7 - -let register_static_files version root = - Protocol_hash.Table.add contextual_static_files version root - -let find_contextual_static_files version = - Protocol_hash.Table.find contextual_static_files version - -let contextual_services : Node_rpc_services.Blocks.block RPC.directory Protocol_hash.Table.t = - Protocol_hash.Table.create 7 - -let register_services version root = - Protocol_hash.Table.add contextual_services version root - -let find_contextual_services version = - Protocol_hash.Table.find contextual_services version diff --git a/src/tezos-deps.opam b/src/tezos-deps.opam index ace54d42f..7035cbf16 100644 --- a/src/tezos-deps.opam +++ b/src/tezos-deps.opam @@ -33,8 +33,6 @@ depends: [ "ocplib-json-typed" "ocplib-resto" {>= "dev" } "reactiveData" - "tyxml" - "js_of_ocaml" "sodium" {>= "0.3.0" } "magic-mime" "leveldb" {>= "1.1.2" } diff --git a/src/utils/logging.ml b/src/utils/logging.ml index fd4674057..85179111a 100644 --- a/src/utils/logging.ml +++ b/src/utils/logging.ml @@ -89,7 +89,6 @@ module Client = struct module Revelation = Make(struct let name = "client.revealation" end) module Denunciation = Make(struct let name = "client.denunciation" end) end -module Webclient = Make(struct let name = "webclient" end) type template = Lwt_log.template let default_template = "$(date) - $(section): $(message)" diff --git a/src/utils/logging.mli b/src/utils/logging.mli index 3f5a008eb..ca04957b9 100644 --- a/src/utils/logging.mli +++ b/src/utils/logging.mli @@ -44,7 +44,6 @@ module Client : sig module Revelation : LOG module Denunciation : LOG end -module Webclient : LOG module Make(S: sig val name: string end) : LOG diff --git a/src/webclient_main.ml b/src/webclient_main.ml deleted file mode 100644 index 554d54457..000000000 --- a/src/webclient_main.ml +++ /dev/null @@ -1,213 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2016. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -(* Tezos Command line interface - Main Program *) - -open Lwt.Infix -open Logging.Webclient - -let make_context () = - let buffers = Hashtbl.create 50 in - Hashtbl.add buffers "stdout" (Buffer.create 1000) ; - Hashtbl.add buffers "stderr" (Buffer.create 1000) ; - let log channel msg = - let buffer = - try Hashtbl.find buffers channel with - Not_found -> - let buffer = Buffer.create 1000 in - Hashtbl.add buffers channel buffer ; - buffer in - Buffer.add_string buffer msg ; - Buffer.add_char buffer '\n' ; - Lwt.return () in - Client_commands.make_context log, - (fun () -> - Hashtbl.fold - (fun channel buffer acc -> - (channel, Buffer.contents buffer) :: acc) - buffers []) - -let block_protocol cctxt block = - Lwt.catch - (fun () -> - Client_node_rpcs.Blocks.protocol cctxt block) - (fun _ -> - cctxt.Client_commands.message - "\n\ - The connection to the RPC server failed, \ - using the default protocol version.\n" >>= fun () -> - Lwt.return Client_alpha.Client_proto_main.protocol) - -let eval_command argv = - let cctxt, result = make_context () in - Lwt.catch - (fun () -> - Client_config.preparse_args argv cctxt >>= fun config -> - let cctxt = { cctxt with config } in - block_protocol cctxt Client_commands.(cctxt.config.block) - >>= fun version -> - let commands = - Client_generic_rpcs.commands @ - Client_keys.commands () @ - Client_protocols.commands () @ - Client_helpers.commands () @ - Client_commands.commands_for_version version in - Client_config.parse_args ~version - (Cli_entries.usage ~commands) - (Cli_entries.inline_dispatch commands) - argv cctxt >>= fun (command, config) -> - command Client_commands.({ cctxt with config }) >>= fun () -> - Lwt.return (Ok (result ()))) - (fun exn -> - let msg = match exn with - | Arg.Help help -> - Format.asprintf "%s%!" help - | Arg.Bad help -> - Format.asprintf "%s%!" help - | Cli_entries.Command_not_found -> - Format.asprintf "Unknown command, try `-help`.\n%!" - | Client_commands.Version_not_found -> - Format.asprintf "Unknown protocol version, try `list versions`.\n%!" - | Cli_entries.Bad_argument (idx, _n, v) -> - Format.asprintf "There's a problem with argument %d, %s.\n%!" idx v - | Cli_entries.Command_failed message -> - Format.asprintf "Command failed, %s.\n%!" message - | Failure msg -> - Format.asprintf "Fatal error: %s\n%!" msg - | exn -> - Format.asprintf "Fatal internal error: %s\n%!" (Printexc.to_string exn) in - let result = - result () in - let stderr = - List.assoc "stderr" result in - let stderr = - if stderr = "" - || String.get stderr (String.length stderr - 1) = '\n' then - msg - else - stderr ^ "\n" ^ msg in - let result = - ("stderr", stderr):: - List.filter (fun (n, _) -> n <> "stderr") result in - Lwt.return (Error result)) - -module ConnectionMap = Map.Make(Cohttp.Connection) - -exception Invalid_method -exception Cannot_parse_body of string - -let root = - let input, output = - let open Data_encoding in - (obj1 (req "command" string)), - (obj1 (req "outputs" (assoc string))) in - let root = - RPC.empty in - let root = - RPC.register0 root - (RPC.service ~input ~output RPC.Path.(root / "command")) - (fun command -> - let argv = Array.of_list (Utils.split ' ' command) in - eval_command argv >>= function - | Ok output | Error output -> - RPC.Answer.return output) in - let root = - RPC.register_dynamic_directory1 root - RPC.Path.(root / "block" /: Node_rpc_services.Blocks.blocks_arg) - (fun block -> - Client_node_rpcs.Blocks.protocol Client_commands.ignore_context block >>= fun version -> - let directory = Webclient_version.find_contextual_services version in - let directory = RPC.map (fun ((), block) -> block) directory in - Lwt.return directory) in - root - -let find_static_file path_str = - let path = OCamlRes.Path.of_string path_str in - let index path = match path with - | [], None -> "text/html", ([], Some ("index", Some "html")) - | oth -> Magic_mime.lookup path_str, oth in - match path with - | ("block" :: block :: path, file) -> - let content_type, path = index (path, file) in - (match Node_rpc_services.Blocks.parse_block block with - | Ok block -> - block_protocol Client_commands.ignore_context block >>= fun version -> - Lwt.return - (try - let root = - Webclient_version.find_contextual_static_files version in - Some (content_type, OCamlRes.Res.find path root) - with Not_found -> None) - | Error _ -> Lwt.return None) - | _ -> - Lwt.return - (try - let content_type, path = index path in - Some (content_type, OCamlRes.Res.find path Webclient_static.root) - with Not_found -> None) - -let http_proxy mode = - let pre_hook path = - find_static_file path >>= function - | Some (content_type, body) -> - Lwt.return - (Some content_type, - { RPC.Answer.code = 200 ; body = RPC.Answer.Single body }) - | None -> - Lwt.return - (None, { RPC.Answer.code = 404 ; body = RPC.Answer.Empty }) in - let post_hook _ = - (find_static_file "not_found.html" >>= function - | Some (content_type, body) -> - Lwt.return (Some content_type, RPC.Answer.Single body) - | None -> - Lwt.return (None, RPC.Answer.Empty)) >>= fun (content_type, body) -> - Lwt.return (content_type, { RPC.Answer.code = 404 ; body }) in - RPC_server.launch ~pre_hook ~post_hook mode root [] [] - -let webclient_args cfg = - let open Client_commands in - [ - "-web-port", Arg.Int (fun x -> cfg := { !cfg with web_port = x }), - "The TCP port to point the web browser to.\n\ - default: " ^ string_of_int Client_commands.(default_cfg.web_port); - ] - -(* Where all the user friendliness starts *) -let () = - Pervasives.exit @@ Lwt_main.run - (Lwt.catch - (fun () -> - Client_config.parse_args - ~extra:webclient_args - (Cli_entries.usage ~commands: []) - (fun () -> function - | `Arg arg -> raise (Arg.Bad ("unexpected argument " ^ arg)) - | `End -> `Res (fun () -> Lwt.return ())) - Sys.argv Client_commands.ignore_context - >>= fun (_no_command, config) -> - Random.self_init () ; - Sodium.Random.stir () ; - (* TODO: add TLS? *) - http_proxy (`TCP (`Port Client_commands.(config.web_port))) - >>= fun _server -> - fst (Lwt.wait ())) - (function - | Arg.Help help -> - Format.eprintf "%s%!" help ; - Lwt.return 0 - | Arg.Bad help -> - Format.eprintf "%s%!" help ; - Lwt.return 1 - | Failure msg -> - Format.eprintf "Fatal error: %s\n%!" msg ; - Lwt.return 1 - | exn -> - Format.eprintf "Fatal internal error: %s\n%!" (Printexc.to_string exn) ; - Lwt.return 1)) diff --git a/src/webclient_static/index.html b/src/webclient_static/index.html deleted file mode 100644 index 2a9b178f2..000000000 --- a/src/webclient_static/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - Tezos Web Client - - - - -

Tezos Web client

-

-    
-
- ./tezos-client - -
- - - diff --git a/src/webclient_static/not_found.html b/src/webclient_static/not_found.html deleted file mode 100644 index d577c597d..000000000 --- a/src/webclient_static/not_found.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - Tezos Web Client - - - -

Not Found

- -