From d6b00db768562fd7b8e4de0aa22451f1915ab5d5 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Mon, 2 Apr 2018 12:15:30 -0500 Subject: [PATCH] Split explorer_web from explorer OTP app Co-authored-by: Alex Garibay --- .gitignore | 9 +- README.md | 8 +- apps/explorer/README.md | 36 +++++ apps/explorer/config/config.exs | 27 +--- apps/explorer/config/dev.exs | 54 -------- apps/explorer/config/dev.secret.exs.example | 4 - apps/explorer/config/prod.exs | 39 ------ apps/explorer/config/test.exs | 15 --- apps/explorer/lib/explorer/application.ex | 9 -- apps/explorer/mix.exs | 35 ++--- apps/explorer/test/test_helper.exs | 3 - apps/explorer_web/README.md | 48 +++++++ .../assets/.eslintrc | 0 .../assets/brunch-config.js | 0 .../assets/css/app.scss | 0 .../assets/css/components/_address.scss | 0 .../assets/css/components/_all.scss | 0 .../assets/css/components/_block.scss | 0 .../assets/css/components/_blocks.scss | 0 .../assets/css/components/_chain.scss | 0 .../assets/css/components/_container.scss | 0 .../assets/css/components/_dot.scss | 0 .../assets/css/components/_footer.scss | 0 .../assets/css/components/_header.scss | 0 .../css/components/_internal_transaction.scss | 0 .../assets/css/components/_pagination.scss | 0 .../assets/css/components/_section.scss | 0 .../assets/css/components/_transaction.scss | 0 .../css/components/_transaction_log.scss | 0 .../assets/css/components/_transactions.scss | 0 .../assets/css/explorer/_all.scss | 0 .../assets/css/explorer/_breakpoints.scss | 0 .../assets/css/explorer/_color.scss | 0 .../assets/css/explorer/_header.scss | 0 .../assets/css/explorer/_open_sans.scss | 0 .../assets/css/explorer/_paper.scss | 0 .../assets/css/explorer/_size.scss | 0 .../assets/css/explorer/_table.scss | 0 .../assets/css/explorer/_typography.scss | 0 .../assets/js/app.js | 0 .../assets/js/lib/block_subscription.js | 0 .../assets/js/lib/react_phoenix.js | 0 .../assets/js/socket.js | 0 .../assets/package-lock.json | 4 +- .../assets/package.json | 4 +- .../spec/lib/block_subscription_spec.js | 0 .../assets/spec/spec_helper.js | 0 .../assets/spec/support/jasmine.scss | 0 .../assets/static/favicon.ico | Bin .../assets/static/images/average_time.svg | 0 .../assets/static/images/block.svg | 0 .../assets/static/images/blocks.svg | 0 .../assets/static/images/last_block.svg | 0 .../assets/static/images/logo.svg | 0 .../assets/static/images/mgi.svg | 0 .../assets/static/images/transaction.svg | 0 .../assets/static/images/transactions.svg | 0 .../assets/static/robots.txt | 0 .../assets/yarn.lock | 4 +- apps/explorer_web/config/config.exs | 31 +++++ apps/explorer_web/config/dev.exs | 54 ++++++++ .../config/dev.secret.exs.example | 5 + apps/explorer_web/config/prod.exs | 31 +++++ apps/explorer_web/config/test.exs | 13 ++ .../lib/explorer_web.ex | 0 .../lib/explorer_web/application.ex | 33 +++++ .../lib/explorer_web/channels/user_socket.ex | 0 .../controllers/address_controller.ex | 0 .../address_transaction_from_controller.ex | 0 .../address_transaction_to_controller.ex | 0 .../controllers/block_controller.ex | 0 .../block_transaction_controller.ex | 0 .../controllers/chain_controller.ex | 0 .../internal_transaction_controller.ex | 0 .../pending_transaction_controller.ex | 0 .../controllers/transaction_controller.ex | 0 .../controllers/transaction_log_controller.ex | 0 .../lib/explorer_web/endpoint.ex | 8 +- .../lib/explorer_web}/forms/block_form.ex | 0 .../forms/pending_transaction_form.ex | 0 .../explorer_web}/forms/transaction_form.ex | 0 .../lib/explorer_web/gettext.ex | 2 +- .../lib/explorer_web/router.ex | 0 .../templates/address/show.html.eex | 0 .../address_transaction_from/index.html.eex | 0 .../address_transaction_to/index.html.eex | 0 .../templates/block/index.html.eex | 0 .../templates/block/show.html.eex | 0 .../block_transaction/index.html.eex | 0 .../templates/chain/show.html.eex | 0 .../internal_transaction/index.html.eex | 0 .../templates/layout/_footer.html.eex | 0 .../templates/layout/_header.html.eex | 0 .../templates/layout/app.html.eex | 0 .../pending_transaction/index.html.eex | 0 .../templates/transaction/index.html.eex | 0 .../templates/transaction/show.html.eex | 0 .../templates/transaction_log/index.html.eex | 0 .../views/address_transaction_from_view.ex | 0 .../views/address_transaction_to_view.ex | 0 .../lib/explorer_web/views/address_view.ex | 0 .../views/block_transaction_view.ex | 0 .../lib/explorer_web/views/block_view.ex | 0 .../lib/explorer_web/views/chain_view.ex | 0 .../lib/explorer_web/views/error_helpers.ex | 0 .../lib/explorer_web/views/error_view.ex | 0 .../views/internal_transaction_view.ex | 0 .../lib/explorer_web/views/layout_view.ex | 0 .../views/pending_transaction_view.ex | 0 .../views/transaction_log_view.ex | 0 .../explorer_web/views/transaction_view.ex | 0 apps/explorer_web/mix.exs | 123 ++++++++++++++++++ .../priv/gettext/default.pot | 0 .../priv/gettext/en/LC_MESSAGES/default.po | 0 .../priv/gettext/en/LC_MESSAGES/errors.po | 0 .../priv/gettext/errors.pot | 0 .../controllers/address_controller_test.exs | 0 ...dress_transaction_from_controller_test.exs | 0 ...address_transaction_to_controller_test.exs | 0 .../controllers/block_controller_test.exs | 0 .../block_transaction_controller_test.exs | 0 .../controllers/chain_controller_test.exs | 0 .../internal_transaction_controller_test.exs | 0 .../pending_transaction_controller_test.exs | 0 .../transaction_controller_test.exs | 0 .../transaction_log_controller_test.exs | 0 .../features/contributor_browsing_test.exs | 0 .../test/explorer_web/features/exq_test.exs | 0 .../explorer_web/features/javascript_test.exs | 0 .../explorer_web}/forms/block_form_test.exs | 0 .../forms/pending_transaction_form_test.exs | 0 .../forms/transaction_form_test.exs | 0 .../explorer_web/views/chain_view_test.exs | 0 .../explorer_web/views/error_view_test.exs | 0 .../explorer_web/views/layout_view_test.exs | 0 .../test/support/channel_case.ex | 0 .../test/support/conn_case.ex | 0 .../test/support/feature_case.ex | 0 apps/explorer_web/test/test_helper.exs | 9 ++ circle.yml | 8 +- config/config.exs | 2 + config/prod.exs | 6 + mix.exs | 2 +- 143 files changed, 428 insertions(+), 198 deletions(-) create mode 100644 apps/explorer/README.md create mode 100644 apps/explorer_web/README.md rename apps/{explorer => explorer_web}/assets/.eslintrc (100%) rename apps/{explorer => explorer_web}/assets/brunch-config.js (100%) rename apps/{explorer => explorer_web}/assets/css/app.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_address.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_all.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_block.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_blocks.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_chain.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_container.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_dot.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_footer.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_header.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_internal_transaction.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_pagination.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_section.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_transaction.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_transaction_log.scss (100%) rename apps/{explorer => explorer_web}/assets/css/components/_transactions.scss (100%) rename apps/{explorer => explorer_web}/assets/css/explorer/_all.scss (100%) rename apps/{explorer => explorer_web}/assets/css/explorer/_breakpoints.scss (100%) rename apps/{explorer => explorer_web}/assets/css/explorer/_color.scss (100%) rename apps/{explorer => explorer_web}/assets/css/explorer/_header.scss (100%) rename apps/{explorer => explorer_web}/assets/css/explorer/_open_sans.scss (100%) rename apps/{explorer => explorer_web}/assets/css/explorer/_paper.scss (100%) rename apps/{explorer => explorer_web}/assets/css/explorer/_size.scss (100%) rename apps/{explorer => explorer_web}/assets/css/explorer/_table.scss (100%) rename apps/{explorer => explorer_web}/assets/css/explorer/_typography.scss (100%) rename apps/{explorer => explorer_web}/assets/js/app.js (100%) rename apps/{explorer => explorer_web}/assets/js/lib/block_subscription.js (100%) rename apps/{explorer => explorer_web}/assets/js/lib/react_phoenix.js (100%) rename apps/{explorer => explorer_web}/assets/js/socket.js (100%) rename apps/{explorer => explorer_web}/assets/package-lock.json (99%) rename apps/{explorer => explorer_web}/assets/package.json (92%) rename apps/{explorer => explorer_web}/assets/spec/lib/block_subscription_spec.js (100%) rename apps/{explorer => explorer_web}/assets/spec/spec_helper.js (100%) rename apps/{explorer => explorer_web}/assets/spec/support/jasmine.scss (100%) rename apps/{explorer => explorer_web}/assets/static/favicon.ico (100%) rename apps/{explorer => explorer_web}/assets/static/images/average_time.svg (100%) rename apps/{explorer => explorer_web}/assets/static/images/block.svg (100%) rename apps/{explorer => explorer_web}/assets/static/images/blocks.svg (100%) rename apps/{explorer => explorer_web}/assets/static/images/last_block.svg (100%) rename apps/{explorer => explorer_web}/assets/static/images/logo.svg (100%) rename apps/{explorer => explorer_web}/assets/static/images/mgi.svg (100%) rename apps/{explorer => explorer_web}/assets/static/images/transaction.svg (100%) rename apps/{explorer => explorer_web}/assets/static/images/transactions.svg (100%) rename apps/{explorer => explorer_web}/assets/static/robots.txt (100%) rename apps/{explorer => explorer_web}/assets/yarn.lock (99%) create mode 100644 apps/explorer_web/config/config.exs create mode 100644 apps/explorer_web/config/dev.exs create mode 100644 apps/explorer_web/config/dev.secret.exs.example create mode 100644 apps/explorer_web/config/prod.exs create mode 100644 apps/explorer_web/config/test.exs rename apps/{explorer => explorer_web}/lib/explorer_web.ex (100%) create mode 100644 apps/explorer_web/lib/explorer_web/application.ex rename apps/{explorer => explorer_web}/lib/explorer_web/channels/user_socket.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/controllers/address_controller.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/controllers/address_transaction_from_controller.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/controllers/address_transaction_to_controller.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/controllers/block_controller.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/controllers/block_transaction_controller.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/controllers/chain_controller.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/controllers/internal_transaction_controller.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/controllers/pending_transaction_controller.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/controllers/transaction_controller.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/controllers/transaction_log_controller.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/endpoint.ex (89%) rename apps/{explorer/lib/explorer => explorer_web/lib/explorer_web}/forms/block_form.ex (100%) rename apps/{explorer/lib/explorer => explorer_web/lib/explorer_web}/forms/pending_transaction_form.ex (100%) rename apps/{explorer/lib/explorer => explorer_web/lib/explorer_web}/forms/transaction_form.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/gettext.ex (95%) rename apps/{explorer => explorer_web}/lib/explorer_web/router.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/address/show.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/address_transaction_from/index.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/address_transaction_to/index.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/block/index.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/block/show.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/block_transaction/index.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/chain/show.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/internal_transaction/index.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/layout/_footer.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/layout/_header.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/layout/app.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/pending_transaction/index.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/transaction/index.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/transaction/show.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/templates/transaction_log/index.html.eex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/address_transaction_from_view.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/address_transaction_to_view.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/address_view.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/block_transaction_view.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/block_view.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/chain_view.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/error_helpers.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/error_view.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/internal_transaction_view.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/layout_view.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/pending_transaction_view.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/transaction_log_view.ex (100%) rename apps/{explorer => explorer_web}/lib/explorer_web/views/transaction_view.ex (100%) create mode 100644 apps/explorer_web/mix.exs rename apps/{explorer => explorer_web}/priv/gettext/default.pot (100%) rename apps/{explorer => explorer_web}/priv/gettext/en/LC_MESSAGES/default.po (100%) rename apps/{explorer => explorer_web}/priv/gettext/en/LC_MESSAGES/errors.po (100%) rename apps/{explorer => explorer_web}/priv/gettext/errors.pot (100%) rename apps/{explorer => explorer_web}/test/explorer_web/controllers/address_controller_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/controllers/address_transaction_from_controller_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/controllers/address_transaction_to_controller_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/controllers/block_controller_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/controllers/block_transaction_controller_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/controllers/chain_controller_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/controllers/internal_transaction_controller_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/controllers/pending_transaction_controller_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/controllers/transaction_controller_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/controllers/transaction_log_controller_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/features/contributor_browsing_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/features/exq_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/features/javascript_test.exs (100%) rename apps/{explorer/test/explorer => explorer_web/test/explorer_web}/forms/block_form_test.exs (100%) rename apps/{explorer/test/explorer => explorer_web/test/explorer_web}/forms/pending_transaction_form_test.exs (100%) rename apps/{explorer/test/explorer => explorer_web/test/explorer_web}/forms/transaction_form_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/views/chain_view_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/views/error_view_test.exs (100%) rename apps/{explorer => explorer_web}/test/explorer_web/views/layout_view_test.exs (100%) rename apps/{explorer => explorer_web}/test/support/channel_case.ex (100%) rename apps/{explorer => explorer_web}/test/support/conn_case.ex (100%) rename apps/{explorer => explorer_web}/test/support/feature_case.ex (100%) create mode 100644 apps/explorer_web/test/test_helper.exs diff --git a/.gitignore b/.gitignore index 98f30b70bc..936a2006d1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,13 +10,16 @@ erl_crash.dump # Generated on crash by NPM npm-debug.log +# Generated on crash by Yarn +yarn-error.log + # Static artifacts -/assets/node_modules +/apps/explorer_web/assets/node_modules # Since we are building assets from assets/, # we ignore priv/static. You may want to comment # this depending on your deployment strategy. -/priv/static/ +/apps/*/priv/static/ # Files matching config/*.secret.exs pattern contain sensitive # data and you should not commit them into version control. @@ -24,7 +27,7 @@ npm-debug.log # Alternatively, you may comment the line below and commit the # secrets files as long as you replace their contents by environment # variables. -/apps/explorer/config/*.secret.exs +/apps/*/config/*.secret.exs # Wallaby screenshots screenshots/ diff --git a/README.md b/README.md index f6983d1c2c..c8d2dea21e 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ To get POA Explorer up and running locally: * Set up some default configuration with: `$ cp config/dev.secret.exs.example config/dev.secret.esx` * Install dependencies with `$ mix do deps.get, local.rebar, deps.compile, compile` * Create and migrate your database with `$ mix ecto.create && mix ecto.migrate` - * Install Node.js dependencies with `$ cd assets && npm install && cd ..` + * Install Node.js dependencies with `$ cd apps/explorer_web/assets && npm install && cd -` * Start Phoenix with `$ mix phx.server` Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. @@ -38,20 +38,20 @@ Configure your local CCMenu with the following url: [`https://circleci.com/gh/po ### Testing - * Build the assets: `$ cd assets && yarn build` + * Build the assets: `$ cd apps/explorer_web/assets && yarn build && cd -` * Format the Elixir code: `$ mix format` * Run the test suite: `$ mix test` * Lint the Elixir code: `$ mix credo --strict` * Run the dialyzer: `mix dialyzer --halt-exit-status` * Check the Elixir code for vulnerabilities: `$ mix sobelow --config` - * Lint the JavaScript code: `$ cd assets && yarn eslint` + * Lint the JavaScript code: `$ cd apps/explorer_web/assets && yarn eslint && cd -` ## Internationalization The app is currently internationalized. It is only localized to U.S. English. -To translate new strings, run `$ mix gettext.extract --merge` and edit the new strings in `priv/gettext/en/LC_MESSAGES/default.po`. +To translate new strings, run `$ cd apps/explorer_web; mix gettext.extract --merge` and edit the new strings in `apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po`. ## Contributing diff --git a/apps/explorer/README.md b/apps/explorer/README.md new file mode 100644 index 0000000000..40a69fc3c1 --- /dev/null +++ b/apps/explorer/README.md @@ -0,0 +1,36 @@ +# POA Explorer + +This is a tool for inspecting and analyzing the POA Network blockchain. + + +## Machine Requirements + +* Erlang/OTP 20.2+ +* Elixir 1.5+ +* Postgres 10.0 + + +## Required Accounts + +* Heroku for deployment +* Github for code storage + + +## Setup Instructions + +### Development + +To get POA Explorer up and running locally: + + * Set up some default configuration with: `$ cp config/dev.secret.exs.example config/dev.secret.esx` + * Install dependencies with `$ mix do deps.get, local.rebar, deps.compile, compile` + * Create and migrate your database with `$ mix ecto.create && mix ecto.migrate` + * Run IEx (Interactive Elixir) to access the index and explore: `$ iex -S mix` + +### Testing + + * Format the Elixir code: `$ mix format` + * Run the test suite: `$ mix test` + * Lint the Elixir code: `$ mix credo --strict` + * Run the dialyzer: `mix dialyzer --halt-exit-status` + * Check the Elixir code for vulnerabilities: `$ mix sobelow --config` diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index 3b20eda7c4..05c22ed3ba 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -5,34 +5,15 @@ # is restricted to this project. use Mix.Config +config :ethereumex, url: "http://localhost:8545" + # General application configuration config :explorer, ecto_repos: [Explorer.Repo] -# Configures gettext -config :explorer, ExplorerWeb.Gettext, locales: ~w(en), default_locale: "en" - -# Configures the endpoint -config :explorer, ExplorerWeb.Endpoint, - url: [host: "localhost"], - render_errors: [view: ExplorerWeb.ErrorView, accepts: ~w(html json)], - pubsub: [name: Explorer.PubSub, adapter: Phoenix.PubSub.PG2] +config :explorer, :ethereum, backend: Explorer.Ethereum.Live config :explorer, Explorer.Integrations.EctoLogger, query_time_ms_threshold: 2_000 -# Configures Elixir's Logger -config :logger, :console, - format: "$time $metadata[$level] $message\n", - metadata: [:request_id] - -config :ethereumex, url: "http://localhost:8545" - -config :new_relixir, active: false - -config :ex_cldr, - default_locale: "en", - locales: ["en"], - gettext: ExplorerWeb.Gettext - config :exq, host: "localhost", port: 6379, @@ -50,8 +31,6 @@ config :exq, {"receipts", 1} ] -config :explorer, :ethereum, backend: Explorer.Ethereum.Live - config :exq_ui, server: false # Import environment specific config. This must remain at the bottom diff --git a/apps/explorer/config/dev.exs b/apps/explorer/config/dev.exs index 082de0d9a8..59b7077b91 100644 --- a/apps/explorer/config/dev.exs +++ b/apps/explorer/config/dev.exs @@ -1,59 +1,5 @@ use Mix.Config -# For development, we disable any cache and enable -# debugging and code reloading. -# -# The watchers configuration can be used to run external -# watchers to your application. For example, we use it -# with brunch.io to recompile .js and .css sources. -config :explorer, ExplorerWeb.Endpoint, - http: [port: 4000], - debug_errors: true, - code_reloader: true, - check_origin: false, - watchers: [ - node: [ - "node_modules/brunch/bin/brunch", - "watch", - "--stdin", - cd: Path.expand("../assets", __DIR__) - ] - ] - -# ## SSL Support -# -# In order to use HTTPS in development, a self-signed -# certificate can be generated by running the following -# command from your terminal: -# -# openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout priv/server.key -out priv/server.pem -# -# The `http:` config above can be replaced with: -# -# https: [port: 4000, keyfile: "priv/server.key", certfile: "priv/server.pem"], -# -# If desired, both `http:` and `https:` keys can be -# configured to run both http and https servers on -# different ports. - -# Watch static and templates for browser reloading. -config :explorer, ExplorerWeb.Endpoint, - live_reload: [ - patterns: [ - ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$}, - ~r{priv/gettext/.*(po)$}, - ~r{lib/explorer_web/views/.*(ex)$}, - ~r{lib/explorer_web/templates/.*(eex)$} - ] - ] - -# Do not include metadata nor timestamps in development logs -config :logger, :console, format: "[$level] $message\n" - -# Set a higher stacktrace during development. Avoid configuring such -# in production as building large stacktraces may be expensive. -config :phoenix, :stacktrace_depth, 20 - # Configure your database config :explorer, Explorer.Repo, adapter: Ecto.Adapters.Postgres, diff --git a/apps/explorer/config/dev.secret.exs.example b/apps/explorer/config/dev.secret.exs.example index 8a5831fc7d..9a91a86f41 100644 --- a/apps/explorer/config/dev.secret.exs.example +++ b/apps/explorer/config/dev.secret.exs.example @@ -3,7 +3,3 @@ use Mix.Config # Configure ethereumex config :ethereumex, url: "http://localhost:8545" - -# Configures the endpoint -config :explorer, ExplorerWeb.Endpoint, - secret_key_base: "RMgI4C1HSkxsEjdhtGMfwAHfyT6CKWXOgzCboJflfSm4jeAlic52io05KB6mqzc5" diff --git a/apps/explorer/config/prod.exs b/apps/explorer/config/prod.exs index d66a3f5bb3..4f639639d1 100644 --- a/apps/explorer/config/prod.exs +++ b/apps/explorer/config/prod.exs @@ -1,38 +1,5 @@ use Mix.Config -# For production, we often load configuration from external -# sources, such as your system environment. For this reason, -# you won't find the :http configuration below, but set inside -# ExplorerWeb.Endpoint.init/2 when load_from_system_env is -# true. Any dynamic configuration should be done there. -# -# Don't forget to configure the url host to something meaningful, -# Phoenix uses this information when generating URLs. -# -# Finally, we also include the path to a cache manifest -# containing the digested version of static files. This -# manifest is generated by the mix phx.digest task -# which you typically run after static files are built. -config :explorer, ExplorerWeb.Endpoint, - cache_static_manifest: "priv/static/cache_manifest.json", - force_ssl: [rewrite_on: [:x_forwarded_proto]], - instrumenters: [NewRelixir.Instrumenters.Phoenix], - load_from_system_env: true, - pubsub: [ - adapter: Phoenix.PubSub.Redis, - url: System.get_env("REDIS_URL"), - node_name: System.get_env("DYNO") - ], - secret_key_base: System.get_env("SECRET_KEY_BASE"), - url: [ - scheme: "https", - host: Map.fetch!(System.get_env(), "HEROKU_APP_NAME") <> ".herokuapp.com", - port: 443 - ] - -# Do not print debug messages in production -config :logger, level: :info - # Configures the database config :explorer, Explorer.Repo, adapter: Ecto.Adapters.Postgres, @@ -43,12 +10,6 @@ config :explorer, Explorer.Repo, timeout: 60_000, pool_timeout: 60_000 -# Configure New Relic -config :new_relixir, - application_name: System.get_env("NEW_RELIC_APP_NAME"), - license_key: System.get_env("NEW_RELIC_LICENSE_KEY"), - active: true - # Configure Web3 config :ethereumex, url: System.get_env("ETHEREUM_URL") diff --git a/apps/explorer/config/test.exs b/apps/explorer/config/test.exs index 442717e8d5..a2dba4218e 100644 --- a/apps/explorer/config/test.exs +++ b/apps/explorer/config/test.exs @@ -1,17 +1,5 @@ use Mix.Config -# We don't run a server during test. If one is required, -# you can enable the server option below. -config :explorer, ExplorerWeb.Endpoint, - http: [port: 4001], - secret_key_base: "27Swe6KtEtmN37WyEYRjKWyxYULNtrxlkCEKur4qoV+Lwtk8lafsR16ifz1XBBYj", - server: true - -config :explorer, :sql_sandbox, true - -# Print only warnings and errors during test -config :logger, level: :warn - # Configure your database config :explorer, Explorer.Repo, adapter: Ecto.Adapters.Postgres, @@ -20,9 +8,6 @@ config :explorer, Explorer.Repo, pool: Ecto.Adapters.SQL.Sandbox, ownership_timeout: 60_000 -# Configure wallaby -config :wallaby, screenshot_on_failure: true - # Configure ethereumex config :ethereumex, url: "https://sokol-trace.poa.network" diff --git a/apps/explorer/lib/explorer/application.ex b/apps/explorer/lib/explorer/application.ex index c7b3a659a3..dcefcd8b3c 100644 --- a/apps/explorer/lib/explorer/application.ex +++ b/apps/explorer/lib/explorer/application.ex @@ -14,14 +14,6 @@ defmodule Explorer.Application do Supervisor.start_link(children(Mix.env()), opts) end - # Tell Phoenix to update the endpoint configuration - # whenever the application is updated. - def config_change(changed, _new, removed) do - alias ExplorerWeb.Endpoint - Endpoint.config_change(changed, removed) - :ok - end - defp children(:test), do: children() defp children(_) do @@ -40,7 +32,6 @@ defmodule Explorer.Application do [ supervisor(Explorer.Repo, []), - supervisor(ExplorerWeb.Endpoint, []) ] end end diff --git a/apps/explorer/mix.exs b/apps/explorer/mix.exs index 7f572fb660..5d6c9cf507 100644 --- a/apps/explorer/mix.exs +++ b/apps/explorer/mix.exs @@ -7,7 +7,6 @@ defmodule Explorer.Mixfile do app: :explorer, build_path: "../../_build", config_path: "../../config/config.exs", - compilers: [:phoenix, :gettext | Mix.compilers()], deps: deps(), deps_path: "../../deps", dialyzer: [ @@ -17,7 +16,7 @@ defmodule Explorer.Mixfile do ], elixir: "~> 1.4", elixirc_paths: elixirc_paths(Mix.env()), - lock_file: "../../mix.lock", + lockfile: "../../mix.lock", package: package(), start_permanent: Mix.env() == :prod, version: "0.0.1" @@ -48,18 +47,15 @@ defmodule Explorer.Mixfile do defp extra_applications, do: [ - :scrivener_ecto, - :scrivener_html, - :ex_cldr, - :ex_jasmine, - :ethereumex, - :timex, - :timex_ecto, :crontab, - :set_locale, + :ethereumex, :logger, + :mix, + :new_relixir, :runtime_tools, - :new_relixir + :scrivener_ecto, + :timex, + :timex_ecto ] # Specifies your project dependencies. @@ -67,42 +63,27 @@ defmodule Explorer.Mixfile do # Type `mix help deps` for examples and options. defp deps do [ - {:cowboy, "~> 1.0"}, {:credo, "~> 0.8", only: [:dev, :test], runtime: false}, {:crontab, "~> 1.1"}, {:dialyxir, "~> 0.5", only: [:dev, :test], runtime: false}, {:ethereumex, "~> 0.3"}, - {:ex_cldr_numbers, "~> 1.0"}, - {:ex_cldr_units, "~> 1.0"}, - {:ex_jasmine, github: "minifast/ex_jasmine", branch: "master"}, {:ex_machina, "~> 2.1", only: [:test]}, {:exq, "~> 0.9.1"}, {:exq_ui, "~> 0.9.0"}, {:exvcr, "~> 0.10", only: :test}, {:flow, "~> 0.12"}, - {:gettext, "~> 0.11"}, {:httpoison, "~> 1.0", override: true}, {:junit_formatter, ">= 0.0.0", only: [:test], runtime: false}, {:math, "~> 0.3.0"}, {:mock, "~> 0.3.0", only: [:test], runtime: false}, {:new_relixir, "~> 0.4"}, - {:phoenix, "~> 1.3.0"}, - {:phoenix_ecto, "~> 3.2"}, - {:phoenix_html, "~> 2.10"}, - {:phoenix_live_reload, "~> 1.0", only: [:dev]}, - {:phoenix_pubsub, "~> 1.0"}, - {:phoenix_pubsub_redis, "~> 2.1.0", only: [:prod]}, {:postgrex, ">= 0.0.0"}, {:quantum, "~> 2.2.1"}, - {:react_phoenix, "~> 0.5"}, {:scrivener_ecto, "~> 1.0"}, {:scrivener_html, "~> 1.7"}, - # Waiting on https://github.com/smeevil/set_locale/pull/9 - {:set_locale, github: "minifast/set_locale", branch: "master"}, {:sobelow, ">= 0.0.0", only: [:dev, :test], runtime: false}, {:timex, "~> 3.1.24"}, - {:timex_ecto, "~> 3.2.1"}, - {:wallaby, "~> 0.19.2", only: [:test], runtime: false} + {:timex_ecto, "~> 3.2.1"} ] end diff --git a/apps/explorer/test/test_helper.exs b/apps/explorer/test/test_helper.exs index 1e7133c111..299a2852c6 100644 --- a/apps/explorer/test/test_helper.exs +++ b/apps/explorer/test/test_helper.exs @@ -1,9 +1,6 @@ ExUnit.configure(formatters: [JUnitFormatter, ExUnit.CLIFormatter]) ExUnit.start() -{:ok, _} = Application.ensure_all_started(:wallaby) -Application.put_env(:wallaby, :base_url, ExplorerWeb.Endpoint.url()) - {:ok, _} = Application.ensure_all_started(:ex_machina) Ecto.Adapters.SQL.Sandbox.mode(Explorer.Repo, :manual) diff --git a/apps/explorer_web/README.md b/apps/explorer_web/README.md new file mode 100644 index 0000000000..53923689d5 --- /dev/null +++ b/apps/explorer_web/README.md @@ -0,0 +1,48 @@ +# POA Explorer Web + +This is a tool for inspecting and analyzing the POA Network blockchain from a web browser. + +## Machine Requirements + +* Erlang/OTP 20.2+ +* Elixir 1.5+ +* Postgres 10.0 + + +## Required Accounts + +* Heroku for deployment +* Github for code storage + + +## Setup Instructions + +### Development + +To get POA Explorer Web interface up and running locally: + + * Setup `../explorer` + * Set up some default configuration with: `$ cp config/dev.secret.exs.example config/dev.secret.esx` + * Install Node.js dependencies with `$ cd assets && npm install && cd ..` + * Start Phoenix with `$ mix phx.server` (This can be run from this directory or the project root: the project root is recommended.) + +Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. + +You can also run IEx (Interactive Elixir): `$ iex -S mix phx.server` (This can be run from this directory or the project root: the project root is recommended.) + +### Testing + + * Build the assets: `$ cd assets && yarn build` + * Format the Elixir code: `$ mix format` + * Run the test suite: `$ mix test` + * Lint the Elixir code: `$ mix credo --strict` + * Run the dialyzer: `mix dialyzer --halt-exit-status` + * Check the Elixir code for vulnerabilities: `$ mix sobelow --config` + * Lint the JavaScript code: `$ cd assets && yarn eslint` + + +## Internationalization + +The app is currently internationalized. It is only localized to U.S. English. + +To translate new strings, run `$ mix gettext.extract --merge` and edit the new strings in `priv/gettext/en/LC_MESSAGES/default.po`. diff --git a/apps/explorer/assets/.eslintrc b/apps/explorer_web/assets/.eslintrc similarity index 100% rename from apps/explorer/assets/.eslintrc rename to apps/explorer_web/assets/.eslintrc diff --git a/apps/explorer/assets/brunch-config.js b/apps/explorer_web/assets/brunch-config.js similarity index 100% rename from apps/explorer/assets/brunch-config.js rename to apps/explorer_web/assets/brunch-config.js diff --git a/apps/explorer/assets/css/app.scss b/apps/explorer_web/assets/css/app.scss similarity index 100% rename from apps/explorer/assets/css/app.scss rename to apps/explorer_web/assets/css/app.scss diff --git a/apps/explorer/assets/css/components/_address.scss b/apps/explorer_web/assets/css/components/_address.scss similarity index 100% rename from apps/explorer/assets/css/components/_address.scss rename to apps/explorer_web/assets/css/components/_address.scss diff --git a/apps/explorer/assets/css/components/_all.scss b/apps/explorer_web/assets/css/components/_all.scss similarity index 100% rename from apps/explorer/assets/css/components/_all.scss rename to apps/explorer_web/assets/css/components/_all.scss diff --git a/apps/explorer/assets/css/components/_block.scss b/apps/explorer_web/assets/css/components/_block.scss similarity index 100% rename from apps/explorer/assets/css/components/_block.scss rename to apps/explorer_web/assets/css/components/_block.scss diff --git a/apps/explorer/assets/css/components/_blocks.scss b/apps/explorer_web/assets/css/components/_blocks.scss similarity index 100% rename from apps/explorer/assets/css/components/_blocks.scss rename to apps/explorer_web/assets/css/components/_blocks.scss diff --git a/apps/explorer/assets/css/components/_chain.scss b/apps/explorer_web/assets/css/components/_chain.scss similarity index 100% rename from apps/explorer/assets/css/components/_chain.scss rename to apps/explorer_web/assets/css/components/_chain.scss diff --git a/apps/explorer/assets/css/components/_container.scss b/apps/explorer_web/assets/css/components/_container.scss similarity index 100% rename from apps/explorer/assets/css/components/_container.scss rename to apps/explorer_web/assets/css/components/_container.scss diff --git a/apps/explorer/assets/css/components/_dot.scss b/apps/explorer_web/assets/css/components/_dot.scss similarity index 100% rename from apps/explorer/assets/css/components/_dot.scss rename to apps/explorer_web/assets/css/components/_dot.scss diff --git a/apps/explorer/assets/css/components/_footer.scss b/apps/explorer_web/assets/css/components/_footer.scss similarity index 100% rename from apps/explorer/assets/css/components/_footer.scss rename to apps/explorer_web/assets/css/components/_footer.scss diff --git a/apps/explorer/assets/css/components/_header.scss b/apps/explorer_web/assets/css/components/_header.scss similarity index 100% rename from apps/explorer/assets/css/components/_header.scss rename to apps/explorer_web/assets/css/components/_header.scss diff --git a/apps/explorer/assets/css/components/_internal_transaction.scss b/apps/explorer_web/assets/css/components/_internal_transaction.scss similarity index 100% rename from apps/explorer/assets/css/components/_internal_transaction.scss rename to apps/explorer_web/assets/css/components/_internal_transaction.scss diff --git a/apps/explorer/assets/css/components/_pagination.scss b/apps/explorer_web/assets/css/components/_pagination.scss similarity index 100% rename from apps/explorer/assets/css/components/_pagination.scss rename to apps/explorer_web/assets/css/components/_pagination.scss diff --git a/apps/explorer/assets/css/components/_section.scss b/apps/explorer_web/assets/css/components/_section.scss similarity index 100% rename from apps/explorer/assets/css/components/_section.scss rename to apps/explorer_web/assets/css/components/_section.scss diff --git a/apps/explorer/assets/css/components/_transaction.scss b/apps/explorer_web/assets/css/components/_transaction.scss similarity index 100% rename from apps/explorer/assets/css/components/_transaction.scss rename to apps/explorer_web/assets/css/components/_transaction.scss diff --git a/apps/explorer/assets/css/components/_transaction_log.scss b/apps/explorer_web/assets/css/components/_transaction_log.scss similarity index 100% rename from apps/explorer/assets/css/components/_transaction_log.scss rename to apps/explorer_web/assets/css/components/_transaction_log.scss diff --git a/apps/explorer/assets/css/components/_transactions.scss b/apps/explorer_web/assets/css/components/_transactions.scss similarity index 100% rename from apps/explorer/assets/css/components/_transactions.scss rename to apps/explorer_web/assets/css/components/_transactions.scss diff --git a/apps/explorer/assets/css/explorer/_all.scss b/apps/explorer_web/assets/css/explorer/_all.scss similarity index 100% rename from apps/explorer/assets/css/explorer/_all.scss rename to apps/explorer_web/assets/css/explorer/_all.scss diff --git a/apps/explorer/assets/css/explorer/_breakpoints.scss b/apps/explorer_web/assets/css/explorer/_breakpoints.scss similarity index 100% rename from apps/explorer/assets/css/explorer/_breakpoints.scss rename to apps/explorer_web/assets/css/explorer/_breakpoints.scss diff --git a/apps/explorer/assets/css/explorer/_color.scss b/apps/explorer_web/assets/css/explorer/_color.scss similarity index 100% rename from apps/explorer/assets/css/explorer/_color.scss rename to apps/explorer_web/assets/css/explorer/_color.scss diff --git a/apps/explorer/assets/css/explorer/_header.scss b/apps/explorer_web/assets/css/explorer/_header.scss similarity index 100% rename from apps/explorer/assets/css/explorer/_header.scss rename to apps/explorer_web/assets/css/explorer/_header.scss diff --git a/apps/explorer/assets/css/explorer/_open_sans.scss b/apps/explorer_web/assets/css/explorer/_open_sans.scss similarity index 100% rename from apps/explorer/assets/css/explorer/_open_sans.scss rename to apps/explorer_web/assets/css/explorer/_open_sans.scss diff --git a/apps/explorer/assets/css/explorer/_paper.scss b/apps/explorer_web/assets/css/explorer/_paper.scss similarity index 100% rename from apps/explorer/assets/css/explorer/_paper.scss rename to apps/explorer_web/assets/css/explorer/_paper.scss diff --git a/apps/explorer/assets/css/explorer/_size.scss b/apps/explorer_web/assets/css/explorer/_size.scss similarity index 100% rename from apps/explorer/assets/css/explorer/_size.scss rename to apps/explorer_web/assets/css/explorer/_size.scss diff --git a/apps/explorer/assets/css/explorer/_table.scss b/apps/explorer_web/assets/css/explorer/_table.scss similarity index 100% rename from apps/explorer/assets/css/explorer/_table.scss rename to apps/explorer_web/assets/css/explorer/_table.scss diff --git a/apps/explorer/assets/css/explorer/_typography.scss b/apps/explorer_web/assets/css/explorer/_typography.scss similarity index 100% rename from apps/explorer/assets/css/explorer/_typography.scss rename to apps/explorer_web/assets/css/explorer/_typography.scss diff --git a/apps/explorer/assets/js/app.js b/apps/explorer_web/assets/js/app.js similarity index 100% rename from apps/explorer/assets/js/app.js rename to apps/explorer_web/assets/js/app.js diff --git a/apps/explorer/assets/js/lib/block_subscription.js b/apps/explorer_web/assets/js/lib/block_subscription.js similarity index 100% rename from apps/explorer/assets/js/lib/block_subscription.js rename to apps/explorer_web/assets/js/lib/block_subscription.js diff --git a/apps/explorer/assets/js/lib/react_phoenix.js b/apps/explorer_web/assets/js/lib/react_phoenix.js similarity index 100% rename from apps/explorer/assets/js/lib/react_phoenix.js rename to apps/explorer_web/assets/js/lib/react_phoenix.js diff --git a/apps/explorer/assets/js/socket.js b/apps/explorer_web/assets/js/socket.js similarity index 100% rename from apps/explorer/assets/js/socket.js rename to apps/explorer_web/assets/js/socket.js diff --git a/apps/explorer/assets/package-lock.json b/apps/explorer_web/assets/package-lock.json similarity index 99% rename from apps/explorer/assets/package-lock.json rename to apps/explorer_web/assets/package-lock.json index 9dd3ee6f2a..6e471ab0ee 100644 --- a/apps/explorer/assets/package-lock.json +++ b/apps/explorer_web/assets/package-lock.json @@ -5008,10 +5008,10 @@ } }, "phoenix": { - "version": "file:../deps/phoenix" + "version": "file:../../../deps/phoenix" }, "phoenix_html": { - "version": "file:../deps/phoenix_html" + "version": "file:../../../deps/phoenix_html" }, "pify": { "version": "2.3.0", diff --git a/apps/explorer/assets/package.json b/apps/explorer_web/assets/package.json similarity index 92% rename from apps/explorer/assets/package.json rename to apps/explorer_web/assets/package.json index 859ce03450..60d0793e20 100644 --- a/apps/explorer/assets/package.json +++ b/apps/explorer_web/assets/package.json @@ -25,8 +25,8 @@ "brunch": "2.10.9", "clean-css-brunch": "2.10.0", "normalize-scss": "^7.0.0", - "phoenix": "file:../deps/phoenix", - "phoenix_html": "file:../deps/phoenix_html", + "phoenix": "file:../../../deps/phoenix", + "phoenix_html": "file:../../../deps/phoenix_html", "react": "^16.2.0", "react-dom": "^16.2.0", "sass-brunch": "github:brunch/sass-brunch#7ffb2e6ebb7380f920a2f594476a3db0654b11b9", diff --git a/apps/explorer/assets/spec/lib/block_subscription_spec.js b/apps/explorer_web/assets/spec/lib/block_subscription_spec.js similarity index 100% rename from apps/explorer/assets/spec/lib/block_subscription_spec.js rename to apps/explorer_web/assets/spec/lib/block_subscription_spec.js diff --git a/apps/explorer/assets/spec/spec_helper.js b/apps/explorer_web/assets/spec/spec_helper.js similarity index 100% rename from apps/explorer/assets/spec/spec_helper.js rename to apps/explorer_web/assets/spec/spec_helper.js diff --git a/apps/explorer/assets/spec/support/jasmine.scss b/apps/explorer_web/assets/spec/support/jasmine.scss similarity index 100% rename from apps/explorer/assets/spec/support/jasmine.scss rename to apps/explorer_web/assets/spec/support/jasmine.scss diff --git a/apps/explorer/assets/static/favicon.ico b/apps/explorer_web/assets/static/favicon.ico similarity index 100% rename from apps/explorer/assets/static/favicon.ico rename to apps/explorer_web/assets/static/favicon.ico diff --git a/apps/explorer/assets/static/images/average_time.svg b/apps/explorer_web/assets/static/images/average_time.svg similarity index 100% rename from apps/explorer/assets/static/images/average_time.svg rename to apps/explorer_web/assets/static/images/average_time.svg diff --git a/apps/explorer/assets/static/images/block.svg b/apps/explorer_web/assets/static/images/block.svg similarity index 100% rename from apps/explorer/assets/static/images/block.svg rename to apps/explorer_web/assets/static/images/block.svg diff --git a/apps/explorer/assets/static/images/blocks.svg b/apps/explorer_web/assets/static/images/blocks.svg similarity index 100% rename from apps/explorer/assets/static/images/blocks.svg rename to apps/explorer_web/assets/static/images/blocks.svg diff --git a/apps/explorer/assets/static/images/last_block.svg b/apps/explorer_web/assets/static/images/last_block.svg similarity index 100% rename from apps/explorer/assets/static/images/last_block.svg rename to apps/explorer_web/assets/static/images/last_block.svg diff --git a/apps/explorer/assets/static/images/logo.svg b/apps/explorer_web/assets/static/images/logo.svg similarity index 100% rename from apps/explorer/assets/static/images/logo.svg rename to apps/explorer_web/assets/static/images/logo.svg diff --git a/apps/explorer/assets/static/images/mgi.svg b/apps/explorer_web/assets/static/images/mgi.svg similarity index 100% rename from apps/explorer/assets/static/images/mgi.svg rename to apps/explorer_web/assets/static/images/mgi.svg diff --git a/apps/explorer/assets/static/images/transaction.svg b/apps/explorer_web/assets/static/images/transaction.svg similarity index 100% rename from apps/explorer/assets/static/images/transaction.svg rename to apps/explorer_web/assets/static/images/transaction.svg diff --git a/apps/explorer/assets/static/images/transactions.svg b/apps/explorer_web/assets/static/images/transactions.svg similarity index 100% rename from apps/explorer/assets/static/images/transactions.svg rename to apps/explorer_web/assets/static/images/transactions.svg diff --git a/apps/explorer/assets/static/robots.txt b/apps/explorer_web/assets/static/robots.txt similarity index 100% rename from apps/explorer/assets/static/robots.txt rename to apps/explorer_web/assets/static/robots.txt diff --git a/apps/explorer/assets/yarn.lock b/apps/explorer_web/assets/yarn.lock similarity index 99% rename from apps/explorer/assets/yarn.lock rename to apps/explorer_web/assets/yarn.lock index edb6f97a7d..2a187ec9ee 100644 --- a/apps/explorer/assets/yarn.lock +++ b/apps/explorer_web/assets/yarn.lock @@ -3329,10 +3329,10 @@ performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" -"phoenix@file:../deps/phoenix": +"phoenix@file:../../../deps/phoenix": version "1.3.0" -"phoenix_html@file:../deps/phoenix_html": +"phoenix_html@file:../../../deps/phoenix_html": version "2.10.5" pify@^2.0.0: diff --git a/apps/explorer_web/config/config.exs b/apps/explorer_web/config/config.exs new file mode 100644 index 0000000000..265241847f --- /dev/null +++ b/apps/explorer_web/config/config.exs @@ -0,0 +1,31 @@ +# This file is responsible for configuring your application +# and its dependencies with the aid of the Mix.Config module. +# +# This configuration file is loaded before any dependency and +# is restricted to this project. +use Mix.Config + +# General application configuration +config :explorer_web, + namespace: ExplorerWeb, + ecto_repos: [Explorer.Repo] + +# Configures gettext +config :explorer_web, ExplorerWeb.Gettext, locales: ~w(en), default_locale: "en" + +# Configures the endpoint +config :explorer_web, ExplorerWeb.Endpoint, + url: [host: "localhost"], + render_errors: [view: ExplorerWeb.ErrorView, accepts: ~w(html json)], + pubsub: [name: ExplorerWeb.PubSub, adapter: Phoenix.PubSub.PG2] + +config :ex_cldr, + default_locale: "en", + locales: ["en"], + gettext: ExplorerWeb.Gettext + +config :exq_ui, server: false + +# Import environment specific config. This must remain at the bottom +# of this file so it overrides the configuration defined above. +import_config "#{Mix.env()}.exs" diff --git a/apps/explorer_web/config/dev.exs b/apps/explorer_web/config/dev.exs new file mode 100644 index 0000000000..5750a6b7fa --- /dev/null +++ b/apps/explorer_web/config/dev.exs @@ -0,0 +1,54 @@ +use Mix.Config + +# For development, we disable any cache and enable +# debugging and code reloading. +# +# The watchers configuration can be used to run external +# watchers to your application. For example, we use it +# with brunch.io to recompile .js and .css sources. +config :explorer_web, ExplorerWeb.Endpoint, + http: [port: 4000], + debug_errors: true, + code_reloader: true, + check_origin: false, + watchers: [ + node: [ + "node_modules/brunch/bin/brunch", + "watch", + "--stdin", + cd: Path.expand("../assets", __DIR__) + ] + ] + +# ## SSL Support +# +# In order to use HTTPS in development, a self-signed +# certificate can be generated by running the following +# command from your terminal: +# +# openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout priv/server.key -out priv/server.pem +# +# The `http:` config above can be replaced with: +# +# https: [port: 4000, keyfile: "priv/server.key", certfile: "priv/server.pem"], +# +# If desired, both `http:` and `https:` keys can be +# configured to run both http and https servers on +# different ports. + +# Watch static and templates for browser reloading. +config :explorer_web, ExplorerWeb.Endpoint, + live_reload: [ + patterns: [ + ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$}, + ~r{priv/gettext/.*(po)$}, + ~r{lib/explorer_web/views/.*(ex)$}, + ~r{lib/explorer_web/templates/.*(eex)$} + ] + ] + +# Set a higher stacktrace during development. Avoid configuring such +# in production as building large stacktraces may be expensive. +config :phoenix, :stacktrace_depth, 20 + +import_config "dev.secret.exs" diff --git a/apps/explorer_web/config/dev.secret.exs.example b/apps/explorer_web/config/dev.secret.exs.example new file mode 100644 index 0000000000..b7731be06e --- /dev/null +++ b/apps/explorer_web/config/dev.secret.exs.example @@ -0,0 +1,5 @@ +use Mix.Config + +# Configures the endpoint +config :explorer_web, ExplorerWeb.Endpoint, + secret_key_base: "RMgI4C1HSkxsEjdhtGMfwAHfyT6CKWXOgzCboJflfSm4jeAlic52io05KB6mqzc5" diff --git a/apps/explorer_web/config/prod.exs b/apps/explorer_web/config/prod.exs new file mode 100644 index 0000000000..b42990c5bd --- /dev/null +++ b/apps/explorer_web/config/prod.exs @@ -0,0 +1,31 @@ +use Mix.Config + +# For production, we often load configuration from external +# sources, such as your system environment. For this reason, +# you won't find the :http configuration below, but set inside +# ExplorerWeb.Endpoint.init/2 when load_from_system_env is +# true. Any dynamic configuration should be done there. +# +# Don't forget to configure the url host to something meaningful, +# Phoenix uses this information when generating URLs. +# +# Finally, we also include the path to a cache manifest +# containing the digested version of static files. This +# manifest is generated by the mix phx.digest task +# which you typically run after static files are built. +config :explorer_web, ExplorerWeb.Endpoint, + cache_static_manifest: "priv/static/cache_manifest.json", + force_ssl: [rewrite_on: [:x_forwarded_proto]], + instrumenters: [NewRelixir.Instrumenters.Phoenix], + load_from_system_env: true, + pubsub: [ + adapter: Phoenix.PubSub.Redis, + url: System.get_env("REDIS_URL"), + node_name: System.get_env("DYNO") + ], + secret_key_base: System.get_env("SECRET_KEY_BASE"), + url: [ + scheme: "https", + host: Map.fetch!(System.get_env(), "HEROKU_APP_NAME") <> ".herokuapp.com", + port: 443 + ] diff --git a/apps/explorer_web/config/test.exs b/apps/explorer_web/config/test.exs new file mode 100644 index 0000000000..dc2523f19b --- /dev/null +++ b/apps/explorer_web/config/test.exs @@ -0,0 +1,13 @@ +use Mix.Config + +config :explorer_web, :sql_sandbox, true + +# We don't run a server during test. If one is required, +# you can enable the server option below. +config :explorer_web, ExplorerWeb.Endpoint, + http: [port: 4001], + secret_key_base: "27Swe6KtEtmN37WyEYRjKWyxYULNtrxlkCEKur4qoV+Lwtk8lafsR16ifz1XBBYj", + server: true + +# Configure wallaby +config :wallaby, screenshot_on_failure: true diff --git a/apps/explorer/lib/explorer_web.ex b/apps/explorer_web/lib/explorer_web.ex similarity index 100% rename from apps/explorer/lib/explorer_web.ex rename to apps/explorer_web/lib/explorer_web.ex diff --git a/apps/explorer_web/lib/explorer_web/application.ex b/apps/explorer_web/lib/explorer_web/application.ex new file mode 100644 index 0000000000..53343ebde1 --- /dev/null +++ b/apps/explorer_web/lib/explorer_web/application.ex @@ -0,0 +1,33 @@ +defmodule ExplorerWeb.Application do + @moduledoc """ + Supervises `ExplorerWeb.Endpoint` in order to serve Web UI. + """ + + use Application + + alias ExplorerWeb.Endpoint + + def start(_type, _args) do + import Supervisor.Spec + + # Define workers and child supervisors to be supervised + children = [ + # Start the endpoint when the application starts + supervisor(Endpoint, []), + # Start your own worker by calling: PoaexpWeb.Worker.start_link(arg1, arg2, arg3) + # worker(PoaexpWeb.Worker, [arg1, arg2, arg3]), + ] + + # See https://hexdocs.pm/elixir/Supervisor.html + # for other strategies and supported options + opts = [strategy: :one_for_one, name: ExplorerWeb.Supervisor] + Supervisor.start_link(children, opts) + end + + # Tell Phoenix to update the endpoint configuration + # whenever the application is updated. + def config_change(changed, _new, removed) do + Endpoint.config_change(changed, removed) + :ok + end +end diff --git a/apps/explorer/lib/explorer_web/channels/user_socket.ex b/apps/explorer_web/lib/explorer_web/channels/user_socket.ex similarity index 100% rename from apps/explorer/lib/explorer_web/channels/user_socket.ex rename to apps/explorer_web/lib/explorer_web/channels/user_socket.ex diff --git a/apps/explorer/lib/explorer_web/controllers/address_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/address_controller.ex similarity index 100% rename from apps/explorer/lib/explorer_web/controllers/address_controller.ex rename to apps/explorer_web/lib/explorer_web/controllers/address_controller.ex diff --git a/apps/explorer/lib/explorer_web/controllers/address_transaction_from_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/address_transaction_from_controller.ex similarity index 100% rename from apps/explorer/lib/explorer_web/controllers/address_transaction_from_controller.ex rename to apps/explorer_web/lib/explorer_web/controllers/address_transaction_from_controller.ex diff --git a/apps/explorer/lib/explorer_web/controllers/address_transaction_to_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/address_transaction_to_controller.ex similarity index 100% rename from apps/explorer/lib/explorer_web/controllers/address_transaction_to_controller.ex rename to apps/explorer_web/lib/explorer_web/controllers/address_transaction_to_controller.ex diff --git a/apps/explorer/lib/explorer_web/controllers/block_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/block_controller.ex similarity index 100% rename from apps/explorer/lib/explorer_web/controllers/block_controller.ex rename to apps/explorer_web/lib/explorer_web/controllers/block_controller.ex diff --git a/apps/explorer/lib/explorer_web/controllers/block_transaction_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/block_transaction_controller.ex similarity index 100% rename from apps/explorer/lib/explorer_web/controllers/block_transaction_controller.ex rename to apps/explorer_web/lib/explorer_web/controllers/block_transaction_controller.ex diff --git a/apps/explorer/lib/explorer_web/controllers/chain_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/chain_controller.ex similarity index 100% rename from apps/explorer/lib/explorer_web/controllers/chain_controller.ex rename to apps/explorer_web/lib/explorer_web/controllers/chain_controller.ex diff --git a/apps/explorer/lib/explorer_web/controllers/internal_transaction_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/internal_transaction_controller.ex similarity index 100% rename from apps/explorer/lib/explorer_web/controllers/internal_transaction_controller.ex rename to apps/explorer_web/lib/explorer_web/controllers/internal_transaction_controller.ex diff --git a/apps/explorer/lib/explorer_web/controllers/pending_transaction_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/pending_transaction_controller.ex similarity index 100% rename from apps/explorer/lib/explorer_web/controllers/pending_transaction_controller.ex rename to apps/explorer_web/lib/explorer_web/controllers/pending_transaction_controller.ex diff --git a/apps/explorer/lib/explorer_web/controllers/transaction_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/transaction_controller.ex similarity index 100% rename from apps/explorer/lib/explorer_web/controllers/transaction_controller.ex rename to apps/explorer_web/lib/explorer_web/controllers/transaction_controller.ex diff --git a/apps/explorer/lib/explorer_web/controllers/transaction_log_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/transaction_log_controller.ex similarity index 100% rename from apps/explorer/lib/explorer_web/controllers/transaction_log_controller.ex rename to apps/explorer_web/lib/explorer_web/controllers/transaction_log_controller.ex diff --git a/apps/explorer/lib/explorer_web/endpoint.ex b/apps/explorer_web/lib/explorer_web/endpoint.ex similarity index 89% rename from apps/explorer/lib/explorer_web/endpoint.ex rename to apps/explorer_web/lib/explorer_web/endpoint.ex index 8d5b620928..baba534472 100644 --- a/apps/explorer/lib/explorer_web/endpoint.ex +++ b/apps/explorer_web/lib/explorer_web/endpoint.ex @@ -1,8 +1,8 @@ defmodule ExplorerWeb.Endpoint do - use Phoenix.Endpoint, otp_app: :explorer + use Phoenix.Endpoint, otp_app: :explorer_web - if Application.get_env(:explorer, :sql_sandbox) do - plug(Phoenix.Ecto.SQL.Sandbox) + if Application.get_env(:explorer_web, :sql_sandbox) do + plug(Phoenix.Ecto.SQL.Sandbox, repo: Explorer.Repo) end socket("/socket", ExplorerWeb.UserSocket) @@ -14,7 +14,7 @@ defmodule ExplorerWeb.Endpoint do plug( Plug.Static, at: "/", - from: :explorer, + from: :explorer_web, gzip: false, only: ~w(css fonts images js favicon.ico robots.txt) ) diff --git a/apps/explorer/lib/explorer/forms/block_form.ex b/apps/explorer_web/lib/explorer_web/forms/block_form.ex similarity index 100% rename from apps/explorer/lib/explorer/forms/block_form.ex rename to apps/explorer_web/lib/explorer_web/forms/block_form.ex diff --git a/apps/explorer/lib/explorer/forms/pending_transaction_form.ex b/apps/explorer_web/lib/explorer_web/forms/pending_transaction_form.ex similarity index 100% rename from apps/explorer/lib/explorer/forms/pending_transaction_form.ex rename to apps/explorer_web/lib/explorer_web/forms/pending_transaction_form.ex diff --git a/apps/explorer/lib/explorer/forms/transaction_form.ex b/apps/explorer_web/lib/explorer_web/forms/transaction_form.ex similarity index 100% rename from apps/explorer/lib/explorer/forms/transaction_form.ex rename to apps/explorer_web/lib/explorer_web/forms/transaction_form.ex diff --git a/apps/explorer/lib/explorer_web/gettext.ex b/apps/explorer_web/lib/explorer_web/gettext.ex similarity index 95% rename from apps/explorer/lib/explorer_web/gettext.ex rename to apps/explorer_web/lib/explorer_web/gettext.ex index fbf3093a7f..3d995ccfb2 100644 --- a/apps/explorer/lib/explorer_web/gettext.ex +++ b/apps/explorer_web/lib/explorer_web/gettext.ex @@ -20,7 +20,7 @@ defmodule ExplorerWeb.Gettext do See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. """ - use Gettext, otp_app: :explorer + use Gettext, otp_app: :explorer_web @dialyzer [ {:nowarn_function, "MACRO-dgettext": 3}, diff --git a/apps/explorer/lib/explorer_web/router.ex b/apps/explorer_web/lib/explorer_web/router.ex similarity index 100% rename from apps/explorer/lib/explorer_web/router.ex rename to apps/explorer_web/lib/explorer_web/router.ex diff --git a/apps/explorer/lib/explorer_web/templates/address/show.html.eex b/apps/explorer_web/lib/explorer_web/templates/address/show.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/address/show.html.eex rename to apps/explorer_web/lib/explorer_web/templates/address/show.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/address_transaction_from/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/address_transaction_from/index.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/address_transaction_from/index.html.eex rename to apps/explorer_web/lib/explorer_web/templates/address_transaction_from/index.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/address_transaction_to/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/address_transaction_to/index.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/address_transaction_to/index.html.eex rename to apps/explorer_web/lib/explorer_web/templates/address_transaction_to/index.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/block/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/block/index.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/block/index.html.eex rename to apps/explorer_web/lib/explorer_web/templates/block/index.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/block/show.html.eex b/apps/explorer_web/lib/explorer_web/templates/block/show.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/block/show.html.eex rename to apps/explorer_web/lib/explorer_web/templates/block/show.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/block_transaction/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/block_transaction/index.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/block_transaction/index.html.eex rename to apps/explorer_web/lib/explorer_web/templates/block_transaction/index.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/chain/show.html.eex b/apps/explorer_web/lib/explorer_web/templates/chain/show.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/chain/show.html.eex rename to apps/explorer_web/lib/explorer_web/templates/chain/show.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/internal_transaction/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/internal_transaction/index.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/internal_transaction/index.html.eex rename to apps/explorer_web/lib/explorer_web/templates/internal_transaction/index.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/layout/_footer.html.eex b/apps/explorer_web/lib/explorer_web/templates/layout/_footer.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/layout/_footer.html.eex rename to apps/explorer_web/lib/explorer_web/templates/layout/_footer.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/layout/_header.html.eex b/apps/explorer_web/lib/explorer_web/templates/layout/_header.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/layout/_header.html.eex rename to apps/explorer_web/lib/explorer_web/templates/layout/_header.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/layout/app.html.eex b/apps/explorer_web/lib/explorer_web/templates/layout/app.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/layout/app.html.eex rename to apps/explorer_web/lib/explorer_web/templates/layout/app.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/pending_transaction/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/pending_transaction/index.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/pending_transaction/index.html.eex rename to apps/explorer_web/lib/explorer_web/templates/pending_transaction/index.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/transaction/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/transaction/index.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/transaction/index.html.eex rename to apps/explorer_web/lib/explorer_web/templates/transaction/index.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/transaction/show.html.eex b/apps/explorer_web/lib/explorer_web/templates/transaction/show.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/transaction/show.html.eex rename to apps/explorer_web/lib/explorer_web/templates/transaction/show.html.eex diff --git a/apps/explorer/lib/explorer_web/templates/transaction_log/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/transaction_log/index.html.eex similarity index 100% rename from apps/explorer/lib/explorer_web/templates/transaction_log/index.html.eex rename to apps/explorer_web/lib/explorer_web/templates/transaction_log/index.html.eex diff --git a/apps/explorer/lib/explorer_web/views/address_transaction_from_view.ex b/apps/explorer_web/lib/explorer_web/views/address_transaction_from_view.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/address_transaction_from_view.ex rename to apps/explorer_web/lib/explorer_web/views/address_transaction_from_view.ex diff --git a/apps/explorer/lib/explorer_web/views/address_transaction_to_view.ex b/apps/explorer_web/lib/explorer_web/views/address_transaction_to_view.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/address_transaction_to_view.ex rename to apps/explorer_web/lib/explorer_web/views/address_transaction_to_view.ex diff --git a/apps/explorer/lib/explorer_web/views/address_view.ex b/apps/explorer_web/lib/explorer_web/views/address_view.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/address_view.ex rename to apps/explorer_web/lib/explorer_web/views/address_view.ex diff --git a/apps/explorer/lib/explorer_web/views/block_transaction_view.ex b/apps/explorer_web/lib/explorer_web/views/block_transaction_view.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/block_transaction_view.ex rename to apps/explorer_web/lib/explorer_web/views/block_transaction_view.ex diff --git a/apps/explorer/lib/explorer_web/views/block_view.ex b/apps/explorer_web/lib/explorer_web/views/block_view.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/block_view.ex rename to apps/explorer_web/lib/explorer_web/views/block_view.ex diff --git a/apps/explorer/lib/explorer_web/views/chain_view.ex b/apps/explorer_web/lib/explorer_web/views/chain_view.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/chain_view.ex rename to apps/explorer_web/lib/explorer_web/views/chain_view.ex diff --git a/apps/explorer/lib/explorer_web/views/error_helpers.ex b/apps/explorer_web/lib/explorer_web/views/error_helpers.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/error_helpers.ex rename to apps/explorer_web/lib/explorer_web/views/error_helpers.ex diff --git a/apps/explorer/lib/explorer_web/views/error_view.ex b/apps/explorer_web/lib/explorer_web/views/error_view.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/error_view.ex rename to apps/explorer_web/lib/explorer_web/views/error_view.ex diff --git a/apps/explorer/lib/explorer_web/views/internal_transaction_view.ex b/apps/explorer_web/lib/explorer_web/views/internal_transaction_view.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/internal_transaction_view.ex rename to apps/explorer_web/lib/explorer_web/views/internal_transaction_view.ex diff --git a/apps/explorer/lib/explorer_web/views/layout_view.ex b/apps/explorer_web/lib/explorer_web/views/layout_view.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/layout_view.ex rename to apps/explorer_web/lib/explorer_web/views/layout_view.ex diff --git a/apps/explorer/lib/explorer_web/views/pending_transaction_view.ex b/apps/explorer_web/lib/explorer_web/views/pending_transaction_view.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/pending_transaction_view.ex rename to apps/explorer_web/lib/explorer_web/views/pending_transaction_view.ex diff --git a/apps/explorer/lib/explorer_web/views/transaction_log_view.ex b/apps/explorer_web/lib/explorer_web/views/transaction_log_view.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/transaction_log_view.ex rename to apps/explorer_web/lib/explorer_web/views/transaction_log_view.ex diff --git a/apps/explorer/lib/explorer_web/views/transaction_view.ex b/apps/explorer_web/lib/explorer_web/views/transaction_view.ex similarity index 100% rename from apps/explorer/lib/explorer_web/views/transaction_view.ex rename to apps/explorer_web/lib/explorer_web/views/transaction_view.ex diff --git a/apps/explorer_web/mix.exs b/apps/explorer_web/mix.exs new file mode 100644 index 0000000000..fd85ba9589 --- /dev/null +++ b/apps/explorer_web/mix.exs @@ -0,0 +1,123 @@ +defmodule ExplorerWeb.Mixfile do + use Mix.Project + + def project do + [ + aliases: aliases(), + app: :explorer_web, + build_path: "../../_build", + config_path: "../../config/config.exs", + compilers: [:phoenix, :gettext | Mix.compilers()], + deps: deps(), + deps_path: "../../deps", + dialyzer: [ + plt_add_deps: :transitive, + ignore_warnings: "../../.dialyzer-ignore" + ], + elixir: "~> 1.4", + elixirc_paths: elixirc_paths(Mix.env()), + lockfile: "../../mix.lock", + package: package(), + start_permanent: Mix.env() == :prod, + version: "0.0.1" + ] + end + + # Configuration for the OTP application. + # + # Type `mix help compile.app` for more information. + def application do + [ + mod: {ExplorerWeb.Application, []}, + extra_applications: extra_applications(Mix.env()) + ] + end + + # Specifies which paths to compile per environment. + defp elixirc_paths(:test), do: ["test/support" | elixirc_paths()] + defp elixirc_paths(_), do: elixirc_paths() + defp elixirc_paths, do: ["lib"] + + # Specifies extra applications to start per environment + defp extra_applications(:prod), + do: [:phoenix_pubsub_redis, :exq, :exq_ui | extra_applications()] + + defp extra_applications(:dev), do: [:exq, :exq_ui | extra_applications()] + defp extra_applications(_), do: extra_applications() + + defp extra_applications, + do: [ + :scrivener_html, + :ex_cldr, + :ex_jasmine, + :timex, + :timex_ecto, + :crontab, + :set_locale, + :logger, + :runtime_tools, + :new_relixir + ] + + # Specifies your project dependencies. + # + # Type `mix help deps` for examples and options. + defp deps do + [ + {:cowboy, "~> 1.0"}, + {:credo, "~> 0.8", only: [:dev, :test], runtime: false}, + {:crontab, "~> 1.1"}, + {:dialyxir, "~> 0.5", only: [:dev, :test], runtime: false}, + {:ex_cldr_numbers, "~> 1.0"}, + {:ex_cldr_units, "~> 1.0"}, + {:ex_jasmine, github: "minifast/ex_jasmine", branch: "master"}, + {:ex_machina, "~> 2.1", only: [:test]}, + {:explorer, in_umbrella: true}, + {:exvcr, "~> 0.10", only: :test}, + {:flow, "~> 0.12"}, + {:gettext, "~> 0.11"}, + {:httpoison, "~> 1.0", override: true}, + {:junit_formatter, ">= 0.0.0", only: [:test], runtime: false}, + {:math, "~> 0.3.0"}, + {:mock, "~> 0.3.0", only: [:test], runtime: false}, + {:new_relixir, "~> 0.4"}, + {:phoenix, "~> 1.3.0"}, + {:phoenix_ecto, "~> 3.2"}, + {:phoenix_html, "~> 2.10"}, + {:phoenix_live_reload, "~> 1.0", only: [:dev]}, + {:phoenix_pubsub, "~> 1.0"}, + {:phoenix_pubsub_redis, "~> 2.1.0", only: [:prod]}, + {:postgrex, ">= 0.0.0"}, + {:react_phoenix, "~> 0.5"}, + {:scrivener_html, "~> 1.7"}, + # Waiting on https://github.com/smeevil/set_locale/pull/9 + {:set_locale, github: "minifast/set_locale", branch: "master"}, + {:sobelow, ">= 0.0.0", only: [:dev, :test], runtime: false}, + {:timex, "~> 3.1.24"}, + {:timex_ecto, "~> 3.2.1"}, + {:wallaby, "~> 0.19.2", only: [:test], runtime: false} + ] + end + + # Aliases are shortcuts or tasks specific to the current project. + # For example, to create, migrate and run the seeds file at once: + # + # $ mix ecto.setup + # + # See the documentation for `Mix` for more info on aliases. + defp aliases do + [ + "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], + "ecto.reset": ["ecto.drop", "ecto.setup"], + test: ["ecto.create --quiet", "ecto.migrate", "test"] + ] + end + + defp package do + [ + maintainers: ["POA Networks Ltd."], + licenses: ["GPL 3.0"], + links: %{"GitHub" => "https://github.com/poanetwork/poa-explorer"} + ] + end +end diff --git a/apps/explorer/priv/gettext/default.pot b/apps/explorer_web/priv/gettext/default.pot similarity index 100% rename from apps/explorer/priv/gettext/default.pot rename to apps/explorer_web/priv/gettext/default.pot diff --git a/apps/explorer/priv/gettext/en/LC_MESSAGES/default.po b/apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po similarity index 100% rename from apps/explorer/priv/gettext/en/LC_MESSAGES/default.po rename to apps/explorer_web/priv/gettext/en/LC_MESSAGES/default.po diff --git a/apps/explorer/priv/gettext/en/LC_MESSAGES/errors.po b/apps/explorer_web/priv/gettext/en/LC_MESSAGES/errors.po similarity index 100% rename from apps/explorer/priv/gettext/en/LC_MESSAGES/errors.po rename to apps/explorer_web/priv/gettext/en/LC_MESSAGES/errors.po diff --git a/apps/explorer/priv/gettext/errors.pot b/apps/explorer_web/priv/gettext/errors.pot similarity index 100% rename from apps/explorer/priv/gettext/errors.pot rename to apps/explorer_web/priv/gettext/errors.pot diff --git a/apps/explorer/test/explorer_web/controllers/address_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/address_controller_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/controllers/address_controller_test.exs rename to apps/explorer_web/test/explorer_web/controllers/address_controller_test.exs diff --git a/apps/explorer/test/explorer_web/controllers/address_transaction_from_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/address_transaction_from_controller_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/controllers/address_transaction_from_controller_test.exs rename to apps/explorer_web/test/explorer_web/controllers/address_transaction_from_controller_test.exs diff --git a/apps/explorer/test/explorer_web/controllers/address_transaction_to_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/address_transaction_to_controller_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/controllers/address_transaction_to_controller_test.exs rename to apps/explorer_web/test/explorer_web/controllers/address_transaction_to_controller_test.exs diff --git a/apps/explorer/test/explorer_web/controllers/block_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/block_controller_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/controllers/block_controller_test.exs rename to apps/explorer_web/test/explorer_web/controllers/block_controller_test.exs diff --git a/apps/explorer/test/explorer_web/controllers/block_transaction_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/block_transaction_controller_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/controllers/block_transaction_controller_test.exs rename to apps/explorer_web/test/explorer_web/controllers/block_transaction_controller_test.exs diff --git a/apps/explorer/test/explorer_web/controllers/chain_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/chain_controller_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/controllers/chain_controller_test.exs rename to apps/explorer_web/test/explorer_web/controllers/chain_controller_test.exs diff --git a/apps/explorer/test/explorer_web/controllers/internal_transaction_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/internal_transaction_controller_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/controllers/internal_transaction_controller_test.exs rename to apps/explorer_web/test/explorer_web/controllers/internal_transaction_controller_test.exs diff --git a/apps/explorer/test/explorer_web/controllers/pending_transaction_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/pending_transaction_controller_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/controllers/pending_transaction_controller_test.exs rename to apps/explorer_web/test/explorer_web/controllers/pending_transaction_controller_test.exs diff --git a/apps/explorer/test/explorer_web/controllers/transaction_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/transaction_controller_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/controllers/transaction_controller_test.exs rename to apps/explorer_web/test/explorer_web/controllers/transaction_controller_test.exs diff --git a/apps/explorer/test/explorer_web/controllers/transaction_log_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/transaction_log_controller_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/controllers/transaction_log_controller_test.exs rename to apps/explorer_web/test/explorer_web/controllers/transaction_log_controller_test.exs diff --git a/apps/explorer/test/explorer_web/features/contributor_browsing_test.exs b/apps/explorer_web/test/explorer_web/features/contributor_browsing_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/features/contributor_browsing_test.exs rename to apps/explorer_web/test/explorer_web/features/contributor_browsing_test.exs diff --git a/apps/explorer/test/explorer_web/features/exq_test.exs b/apps/explorer_web/test/explorer_web/features/exq_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/features/exq_test.exs rename to apps/explorer_web/test/explorer_web/features/exq_test.exs diff --git a/apps/explorer/test/explorer_web/features/javascript_test.exs b/apps/explorer_web/test/explorer_web/features/javascript_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/features/javascript_test.exs rename to apps/explorer_web/test/explorer_web/features/javascript_test.exs diff --git a/apps/explorer/test/explorer/forms/block_form_test.exs b/apps/explorer_web/test/explorer_web/forms/block_form_test.exs similarity index 100% rename from apps/explorer/test/explorer/forms/block_form_test.exs rename to apps/explorer_web/test/explorer_web/forms/block_form_test.exs diff --git a/apps/explorer/test/explorer/forms/pending_transaction_form_test.exs b/apps/explorer_web/test/explorer_web/forms/pending_transaction_form_test.exs similarity index 100% rename from apps/explorer/test/explorer/forms/pending_transaction_form_test.exs rename to apps/explorer_web/test/explorer_web/forms/pending_transaction_form_test.exs diff --git a/apps/explorer/test/explorer/forms/transaction_form_test.exs b/apps/explorer_web/test/explorer_web/forms/transaction_form_test.exs similarity index 100% rename from apps/explorer/test/explorer/forms/transaction_form_test.exs rename to apps/explorer_web/test/explorer_web/forms/transaction_form_test.exs diff --git a/apps/explorer/test/explorer_web/views/chain_view_test.exs b/apps/explorer_web/test/explorer_web/views/chain_view_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/views/chain_view_test.exs rename to apps/explorer_web/test/explorer_web/views/chain_view_test.exs diff --git a/apps/explorer/test/explorer_web/views/error_view_test.exs b/apps/explorer_web/test/explorer_web/views/error_view_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/views/error_view_test.exs rename to apps/explorer_web/test/explorer_web/views/error_view_test.exs diff --git a/apps/explorer/test/explorer_web/views/layout_view_test.exs b/apps/explorer_web/test/explorer_web/views/layout_view_test.exs similarity index 100% rename from apps/explorer/test/explorer_web/views/layout_view_test.exs rename to apps/explorer_web/test/explorer_web/views/layout_view_test.exs diff --git a/apps/explorer/test/support/channel_case.ex b/apps/explorer_web/test/support/channel_case.ex similarity index 100% rename from apps/explorer/test/support/channel_case.ex rename to apps/explorer_web/test/support/channel_case.ex diff --git a/apps/explorer/test/support/conn_case.ex b/apps/explorer_web/test/support/conn_case.ex similarity index 100% rename from apps/explorer/test/support/conn_case.ex rename to apps/explorer_web/test/support/conn_case.ex diff --git a/apps/explorer/test/support/feature_case.ex b/apps/explorer_web/test/support/feature_case.ex similarity index 100% rename from apps/explorer/test/support/feature_case.ex rename to apps/explorer_web/test/support/feature_case.ex diff --git a/apps/explorer_web/test/test_helper.exs b/apps/explorer_web/test/test_helper.exs new file mode 100644 index 0000000000..1e7133c111 --- /dev/null +++ b/apps/explorer_web/test/test_helper.exs @@ -0,0 +1,9 @@ +ExUnit.configure(formatters: [JUnitFormatter, ExUnit.CLIFormatter]) +ExUnit.start() + +{:ok, _} = Application.ensure_all_started(:wallaby) +Application.put_env(:wallaby, :base_url, ExplorerWeb.Endpoint.url()) + +{:ok, _} = Application.ensure_all_started(:ex_machina) + +Ecto.Adapters.SQL.Sandbox.mode(Explorer.Repo, :manual) diff --git a/circle.yml b/circle.yml index 96ac70eca3..309383a746 100644 --- a/circle.yml +++ b/circle.yml @@ -45,12 +45,12 @@ dependencies: - bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 - mix dialyzer --plt: timeout: 3600 - - cd assets && yarn install && yarn build && cd .. + - cd apps/explorer_web/assets && yarn install && yarn build && cd - cache_directories: - ~/.asdf - _build - deps - - assets/node_modules + - apps/explorer_web/assets/node_modules - vendor/bundle test: @@ -60,8 +60,8 @@ test: - mix sobelow --config - mix dialyzer --halt-exit-status - bundle exec license_finder --project-path=. --decisions-file=doc/dependency_decisions.yml - - cd assets && bundle exec license_finder --decisions-file=../doc/dependency_decisions.yml && cd .. - - cd assets && yarn eslint --format=junit --output-file="$CIRCLE_TEST_REPORTS/eslint/junit.xml" && cd .. + - cd apps/explorer_web/assets && bundle exec license_finder --decisions-file=../../..//doc/dependency_decisions.yml && cd - + - cd apps/explorer_web/assets && yarn eslint --format=junit --output-file="$CIRCLE_TEST_REPORTS/eslint/junit.xml" && cd - override: - mix test post: diff --git a/config/config.exs b/config/config.exs index 883acdfde1..583d0ed94e 100644 --- a/config/config.exs +++ b/config/config.exs @@ -14,6 +14,8 @@ config :logger, :console, format: "$time $metadata[$level] $message\n", metadata: [:request_id] +config :new_relixir, active: false + # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --git a/config/prod.exs b/config/prod.exs index 6ca4472984..9f7c564a19 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -2,3 +2,9 @@ use Mix.Config # Do not print debug messages in production config :logger, level: :info + +# Configure New Relic +config :new_relixir, + application_name: System.get_env("NEW_RELIC_APP_NAME"), + license_key: System.get_env("NEW_RELIC_LICENSE_KEY"), + active: true diff --git a/mix.exs b/mix.exs index 77ea6e0c3a..9cf38d65fd 100644 --- a/mix.exs +++ b/mix.exs @@ -1,4 +1,4 @@ -defmodule Explorer.Umbrella.Mixfile do +defmodule ExplorerUmbrella.Mixfile do use Mix.Project def project do