├── assets
├── @types
│ ├── .gitkeep
│ ├── topbar.d.ts
│ └── notified_phoenix.d.ts
├── babel.config.js
├── static
│ ├── favicon.ico
│ ├── images
│ │ └── phoenix.png
│ └── robots.txt
├── js
│ ├── components.tsx
│ ├── hooks.tsx
│ └── app.ts
├── css
│ └── app.css
├── postcss.config.js
├── tsconfig.json
├── package.json
├── webpack.config.js
└── tailwind.config.js
├── .iex.exs
├── test
├── test_helper.exs
├── slurpee_web
│ └── views
│ │ ├── layout_view_test.exs
│ │ └── error_view_test.exs
└── support
│ ├── data_case.ex
│ ├── channel_case.ex
│ └── conn_case.ex
├── docs
├── blockchains.png
├── log-subscriptions.png
├── new-head-subscriptions.png
├── recent-blocks-and-events.png
└── BUILT_WITH_SLURPEE.md
├── lib
├── slurpee_web
│ ├── views
│ │ ├── layout_view.ex
│ │ ├── error_view.ex
│ │ └── error_helpers.ex
│ ├── templates
│ │ └── layout
│ │ │ ├── app.html.eex
│ │ │ ├── live.html.leex
│ │ │ └── root.html.leex
│ ├── view_helpers
│ │ ├── ellipsis_helper.ex
│ │ ├── explorer_url_helper.ex
│ │ └── search_query_helper.ex
│ ├── components
│ │ └── block_number_component.ex
│ ├── live
│ │ ├── transaction_subscription_live.ex
│ │ ├── transaction_subscription_live.html.leex
│ │ ├── new_head_subscription_live.html.leex
│ │ ├── new_head_subscription_live.ex
│ │ ├── log_subscription_live.ex
│ │ ├── log_subscription_live.html.leex
│ │ ├── home_live.ex
│ │ ├── home_live.html.leex
│ │ ├── blockchain_live.html.leex
│ │ └── blockchain_live.ex
│ ├── gettext.ex
│ ├── router.ex
│ ├── channels
│ │ └── user_socket.ex
│ ├── telemetry.ex
│ └── endpoint.ex
├── slurpee.ex
├── slurpee
│ ├── new_head_handler.ex
│ ├── event_handler.ex
│ ├── application.ex
│ ├── recent_heads.ex
│ ├── recent_events.ex
│ └── blockchain_statistics.ex
└── slurpee_web.ex
├── examples
├── erc20
│ └── approval.ex
└── event_handler.ex
├── config
├── config.exs
└── runtime.exs
├── .formatter.exs
├── Dockerfile
├── .github
├── dependabot.yml
└── workflows
│ └── test.yml
├── docker-compose.yml
├── .gitignore
├── LICENSE
├── mix.exs
├── priv
└── gettext
│ ├── en
│ └── LC_MESSAGES
│ │ └── errors.po
│ └── errors.pot
├── README.md
└── mix.lock
/assets/@types/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.iex.exs:
--------------------------------------------------------------------------------
1 | import Slurp.IEx
2 |
--------------------------------------------------------------------------------
/test/test_helper.exs:
--------------------------------------------------------------------------------
1 | ExUnit.start()
2 |
--------------------------------------------------------------------------------
/assets/@types/topbar.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'topbar'
2 |
--------------------------------------------------------------------------------
/assets/@types/notified_phoenix.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'notified_phoenix'
2 |
--------------------------------------------------------------------------------
/docs/blockchains.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fremantle-industries/slurpee/HEAD/docs/blockchains.png
--------------------------------------------------------------------------------
/lib/slurpee_web/views/layout_view.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.LayoutView do
2 | use SlurpeeWeb, :view
3 | end
4 |
--------------------------------------------------------------------------------
/assets/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ["@babel/preset-react", "@babel/preset-env"]
3 | };
4 |
--------------------------------------------------------------------------------
/assets/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fremantle-industries/slurpee/HEAD/assets/static/favicon.ico
--------------------------------------------------------------------------------
/docs/log-subscriptions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fremantle-industries/slurpee/HEAD/docs/log-subscriptions.png
--------------------------------------------------------------------------------
/assets/js/components.tsx:
--------------------------------------------------------------------------------
1 | import TimeAgo from 'react-timeago'
2 |
3 | export const Components = {
4 | TimeAgo,
5 | };
6 |
--------------------------------------------------------------------------------
/examples/erc20/approval.ex:
--------------------------------------------------------------------------------
1 | defmodule Examples.Erc20.Events.Approval do
2 | defstruct ~w[owner spender value]a
3 | end
4 |
--------------------------------------------------------------------------------
/assets/css/app.css:
--------------------------------------------------------------------------------
1 | @import 'tailwindcss/base';
2 | @import 'tailwindcss/components';
3 | @import 'tailwindcss/utilities';
4 |
--------------------------------------------------------------------------------
/assets/static/images/phoenix.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fremantle-industries/slurpee/HEAD/assets/static/images/phoenix.png
--------------------------------------------------------------------------------
/config/config.exs:
--------------------------------------------------------------------------------
1 | import Config
2 |
3 | # Use Jason for JSON parsing in Phoenix
4 | config :phoenix, :json_library, Jason
5 |
--------------------------------------------------------------------------------
/docs/new-head-subscriptions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fremantle-industries/slurpee/HEAD/docs/new-head-subscriptions.png
--------------------------------------------------------------------------------
/docs/recent-blocks-and-events.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fremantle-industries/slurpee/HEAD/docs/recent-blocks-and-events.png
--------------------------------------------------------------------------------
/assets/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | "postcss-import": {},
4 | tailwindcss: {},
5 | autoprefixer: {},
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/lib/slurpee_web/templates/layout/app.html.eex:
--------------------------------------------------------------------------------
1 |
<%= get_flash(@conn, :info) %>
2 | <%= get_flash(@conn, :error) %>
3 | <%= @inner_content %>
4 |
--------------------------------------------------------------------------------
/.formatter.exs:
--------------------------------------------------------------------------------
1 | [
2 | import_deps: [:ecto, :phoenix],
3 | inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
4 | subdirectories: ["priv/*/migrations"]
5 | ]
6 |
--------------------------------------------------------------------------------
/assets/static/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/lib/slurpee_web/templates/layout/live.html.leex:
--------------------------------------------------------------------------------
1 | <%= live_flash(@flash, :info) %>
2 | <%= live_flash(@flash, :error) %>
3 | <%= @inner_content %>
4 |
--------------------------------------------------------------------------------
/assets/js/hooks.tsx:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | import LiveReact from "phoenix_live_react"
3 | // @ts-ignore
4 | // TODO: Include type definitions
5 | import {NotifiedPhoenix} from "notified_phoenix"
6 |
7 | export const hooks = {
8 | NotifiedPhoenix: NotifiedPhoenix,
9 | LiveReact: LiveReact,
10 | }
11 |
--------------------------------------------------------------------------------
/lib/slurpee.ex:
--------------------------------------------------------------------------------
1 | defmodule Slurpee do
2 | @moduledoc """
3 | Slurpee keeps the contexts that define your domain
4 | and business logic.
5 |
6 | Contexts are also responsible for managing your data, regardless
7 | if it comes from the database, an external API or others.
8 | """
9 | end
10 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM bitwalker/alpine-elixir-phoenix:latest
2 |
3 | WORKDIR /app
4 |
5 | COPY mix.exs .
6 | COPY mix.lock .
7 |
8 | RUN mkdir assets
9 |
10 | COPY assets/package.json assets
11 | COPY assets/package-lock.json assets
12 |
13 | CMD mix deps.get && cd assets && npm install && cd .. && mix phx.server
14 |
--------------------------------------------------------------------------------
/lib/slurpee_web/view_helpers/ellipsis_helper.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.ViewHelpers.EllipsisHelper do
2 | def ellipsis(str, max_len) do
3 | if String.length(str) > max_len do
4 | range = Range.new(0, max_len)
5 | "#{String.slice(str, range)}..."
6 | else
7 | str
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/assets/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "outDir": "./dist/",
4 | "noImplicitAny": true,
5 | "module": "CommonJS",
6 | "esModuleInterop": true,
7 | "target": "ES5",
8 | "lib": [
9 | "ES2020",
10 | "DOM"
11 | ],
12 | "jsx": "react",
13 | "allowJs": true
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/test/slurpee_web/views/layout_view_test.exs:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.LayoutViewTest do
2 | use SlurpeeWeb.ConnCase, async: true
3 |
4 | # When testing helpers, you may want to import Phoenix.HTML and
5 | # use functions such as safe_to_string() to convert the helper
6 | # result into an HTML string.
7 | # import Phoenix.HTML
8 | end
9 |
--------------------------------------------------------------------------------
/examples/event_handler.ex:
--------------------------------------------------------------------------------
1 | defmodule Examples.EventHandler do
2 | require Logger
3 |
4 | def handle_event(_blockchain, %{"blockNumber" => hex_block_number}= _log, event) do
5 | {:ok, block_number} = Slurp.Utils.hex_to_integer(hex_block_number)
6 | Logger.info "received event: #{inspect event}, block_number: #{block_number}"
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/slurpee_web/view_helpers/explorer_url_helper.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.ViewHelpers.ExplorerUrlHelper do
2 | import Stylish.ExternalLink, only: [external_link: 1]
3 |
4 | def explorer_url({explorer_adapter, endpoint}) do
5 | url = explorer_adapter.home_url(endpoint)
6 | external_link(to: url)
7 | end
8 |
9 | def explorer_url(nil) do
10 | "-"
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/slurpee_web/components/block_number_component.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.BlockNumberComponent do
2 | use Phoenix.HTML
3 | import Phoenix.LiveView.Helpers, only: [sigil_H: 2]
4 |
5 | def pill(assigns) do
6 | ~H"""
7 |
8 | <%= @block_number %>
9 |
10 | """
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/slurpee_web/live/transaction_subscription_live.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.TransactionSubscriptionLive do
2 | use SlurpeeWeb, :live_view
3 |
4 | @impl true
5 | def mount(_params, _session, socket) do
6 | transaction_subscriptions = []
7 |
8 | socket =
9 | socket
10 | |> assign(transaction_subscriptions: transaction_subscriptions)
11 |
12 | {:ok, socket}
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/docs/BUILT_WITH_SLURPEE.md:
--------------------------------------------------------------------------------
1 | # Built with Slurpee
2 |
3 | [Built with Slurpee](./BUILT_WITH_SLURPEE.md) | [Install](../README.md#install)
4 |
5 | ## [Rube](https://github.com/fremantle-industries/rube)
6 |
7 | A multi-chain DeFi development toolkit for Elixir
8 |
9 | [](https://youtu.be/f2phGFZrh80)
10 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: mix
4 | directory: "/"
5 | schedule:
6 | interval: monthly
7 | open-pull-requests-limit: 10
8 | - package-ecosystem: npm
9 | directory: "/assets"
10 | schedule:
11 | interval: monthly
12 | open-pull-requests-limit: 10
13 | - package-ecosystem: github-actions
14 | directory: "/"
15 | schedule:
16 | interval: monthly
17 | open-pull-requests-limit: 10
18 |
--------------------------------------------------------------------------------
/lib/slurpee_web/view_helpers/search_query_helper.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.ViewHelpers.SearchQueryHelper do
2 | def assign_search_query(conn, params) do
3 | query = extract_query(params, conn)
4 | Phoenix.LiveView.assign(conn, :query, query)
5 | end
6 |
7 | defp extract_query(params, conn) do
8 | case Map.get(params, "query") do
9 | "" -> nil
10 | nil -> conn.assigns.query
11 | query -> query
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/test/slurpee_web/views/error_view_test.exs:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.ErrorViewTest do
2 | use SlurpeeWeb.ConnCase, async: true
3 |
4 | # Bring render/3 and render_to_string/3 for testing custom views
5 | import Phoenix.View
6 |
7 | test "renders 404.html" do
8 | assert render_to_string(SlurpeeWeb.ErrorView, "404.html", []) == "Not Found"
9 | end
10 |
11 | test "renders 500.html" do
12 | assert render_to_string(SlurpeeWeb.ErrorView, "500.html", []) == "Internal Server Error"
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/slurpee_web/views/error_view.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.ErrorView do
2 | use SlurpeeWeb, :view
3 |
4 | # If you want to customize a particular status code
5 | # for a certain format, you may uncomment below.
6 | # def render("500.html", _assigns) do
7 | # "Internal Server Error"
8 | # end
9 |
10 | # By default, Phoenix returns the status message from
11 | # the template name. For example, "404.html" becomes
12 | # "Not Found".
13 | def template_not_found(template, _assigns) do
14 | Phoenix.Controller.status_message_from_template(template)
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/lib/slurpee/new_head_handler.ex:
--------------------------------------------------------------------------------
1 | defmodule Slurpee.NewHeadHandler do
2 | @type blockchain :: Slurp.Blockchains.Blockchain.id()
3 | @type block_number :: Slurp.Adapter.block_number()
4 |
5 | @callback handle_new_head(blockchain, block_number) :: no_return
6 |
7 | require Logger
8 |
9 | def handle_new_head(blockchain, block_number) do
10 | Logger.info("received new head: #{block_number}")
11 |
12 | Phoenix.PubSub.broadcast(
13 | Slurpee.PubSub,
14 | "heads:new_head_received",
15 | {"heads:new_head_received", blockchain.id, block_number}
16 | )
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/lib/slurpee/event_handler.ex:
--------------------------------------------------------------------------------
1 | defmodule Slurpee.EventHandler do
2 | require Logger
3 |
4 | def handle_event(
5 | blockchain,
6 | %{"blockNumber" => hex_block_number, "blockHash" => block_hash, "address" => address},
7 | event
8 | ) do
9 | {:ok, block_number} = Slurp.Utils.hex_to_integer(hex_block_number)
10 | Logger.info "received event: #{inspect event}, block_number: #{block_number}"
11 |
12 | Phoenix.PubSub.broadcast(
13 | Slurpee.PubSub,
14 | "events:event_received",
15 | {"events:event_received", blockchain.id, block_number, block_hash, address, event}
16 | )
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/lib/slurpee/application.ex:
--------------------------------------------------------------------------------
1 | defmodule Slurpee.Application do
2 | @moduledoc false
3 |
4 | use Application
5 |
6 | def start(_type, _args) do
7 | Confex.resolve_env!(:slurpee)
8 |
9 | children = [
10 | SlurpeeWeb.Telemetry,
11 | {Phoenix.PubSub, name: Slurpee.PubSub},
12 | Slurpee.RecentHeads,
13 | Slurpee.RecentEvents,
14 | Slurpee.BlockchainStatistics,
15 | SlurpeeWeb.Endpoint
16 | ]
17 |
18 | opts = [strategy: :one_for_one, name: Slurpee.Supervisor]
19 | Supervisor.start_link(children, opts)
20 | end
21 |
22 | # Tell Phoenix to update the endpoint configuration
23 | # whenever the application is updated.
24 | def config_change(changed, _new, removed) do
25 | SlurpeeWeb.Endpoint.config_change(changed, removed)
26 | :ok
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/lib/slurpee_web/gettext.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.Gettext do
2 | @moduledoc """
3 | A module providing Internationalization with a gettext-based API.
4 |
5 | By using [Gettext](https://hexdocs.pm/gettext),
6 | your module gains a set of macros for translations, for example:
7 |
8 | import SlurpeeWeb.Gettext
9 |
10 | # Simple translation
11 | gettext("Here is the string to translate")
12 |
13 | # Plural translation
14 | ngettext("Here is the string to translate",
15 | "Here are the strings to translate",
16 | 3)
17 |
18 | # Domain-based translation
19 | dgettext("errors", "Here is the error message to translate")
20 |
21 | See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
22 | """
23 | use Gettext, otp_app: :slurpee
24 | end
25 |
--------------------------------------------------------------------------------
/test/support/data_case.ex:
--------------------------------------------------------------------------------
1 | defmodule Slurpee.DataCase do
2 | @moduledoc """
3 | This module defines the setup for tests requiring
4 | access to the application's data layer.
5 |
6 | You may define functions here to be used as helpers in
7 | your tests.
8 |
9 | Finally, if the test case interacts with the database,
10 | we enable the SQL sandbox, so changes done to the database
11 | are reverted at the end of every test. If you are using
12 | PostgreSQL, you can even run database tests asynchronously
13 | by setting `use Slurpee.DataCase, async: true`, although
14 | this option is not recommended for other databases.
15 | """
16 |
17 | use ExUnit.CaseTemplate
18 |
19 | using do
20 | quote do
21 | import Slurpee.DataCase
22 | end
23 | end
24 |
25 | setup _tags do
26 | :ok
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.8'
2 |
3 | services:
4 | web:
5 | build: .
6 | environment:
7 | MIX_ENV: dev
8 | env_file:
9 | - .env
10 | ports:
11 | - '4000:4000'
12 | volumes:
13 | - web_build:/app/_build
14 | - ./.env:/app/.env
15 | - ./mix.exs:/app/mix.exs
16 | - ./mix.lock:/app/mix.lock
17 | - ./assets/css:/app/assets/css
18 | - ./assets/js:/app/assets/js
19 | - ./assets/static:/app/assets/static
20 | - ./assets/package.json:/app/assets/package.json
21 | - ./assets/package-lock.json:/app/assets/package-lock.json
22 | - ./assets/webpack.config.js:/app/assets/webpack.config.js
23 | - ./deps:/app/deps
24 | - ./config:/app/config
25 | - ./lib:/app/lib
26 | - ./priv:/app/priv
27 | - ./test:/app/test
28 |
29 | volumes:
30 | db_data:
31 | web_build:
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # The directory Mix will write compiled artifacts to.
2 | /_build/
3 |
4 | # If you run "mix test --cover", coverage assets end up here.
5 | /cover/
6 |
7 | # The directory Mix downloads your dependencies sources to.
8 | /deps/
9 |
10 | # Where 3rd-party dependencies like ExDoc output generated docs.
11 | /doc/
12 |
13 | # Ignore .fetch files in case you like to edit your project deps locally.
14 | /.fetch
15 |
16 | # If the VM crashes, it generates a dump, let's ignore it too.
17 | erl_crash.dump
18 |
19 | # Also ignore archive artifacts (built via "mix archive.build").
20 | *.ez
21 |
22 | # Ignore package tarball (built via "mix hex.build").
23 | slurpee-*.tar
24 |
25 | # If NPM crashes, it generates a log, let's ignore it too.
26 | npm-debug.log
27 |
28 | # The directory NPM downloads your dependencies sources to.
29 | /assets/node_modules/
30 |
31 | # Since we are building assets from assets/,
32 | # we ignore priv/static. You may want to comment
33 | # this depending on your deployment strategy.
34 | /priv/static/
35 |
36 | # Environment switcher
37 | .envrc
38 |
39 | # Logs
40 | log/*
41 |
--------------------------------------------------------------------------------
/test/support/channel_case.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.ChannelCase do
2 | @moduledoc """
3 | This module defines the test case to be used by
4 | channel tests.
5 |
6 | Such tests rely on `Phoenix.ChannelTest` and also
7 | import other functionality to make it easier
8 | to build common data structures and query the data layer.
9 |
10 | Finally, if the test case interacts with the database,
11 | we enable the SQL sandbox, so changes done to the database
12 | are reverted at the end of every test. If you are using
13 | PostgreSQL, you can even run database tests asynchronously
14 | by setting `use SlurpeeWeb.ChannelCase, async: true`, although
15 | this option is not recommended for other databases.
16 | """
17 |
18 | use ExUnit.CaseTemplate
19 |
20 | using do
21 | quote do
22 | # Import conveniences for testing with channels
23 | import Phoenix.ChannelTest
24 | import SlurpeeWeb.ChannelCase
25 |
26 | # The default endpoint for testing
27 | @endpoint SlurpeeWeb.Endpoint
28 | end
29 | end
30 |
31 | setup _tags do
32 | :ok
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Fremantle Industries Inc.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/lib/slurpee_web/router.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.Router do
2 | use SlurpeeWeb, :router
3 | import Redirect
4 |
5 | pipeline :browser do
6 | plug :accepts, ["html"]
7 | plug :fetch_session
8 | plug :fetch_live_flash
9 | plug :put_root_layout, {SlurpeeWeb.LayoutView, :root}
10 | plug :protect_from_forgery
11 | plug :put_secure_browser_headers
12 | end
13 |
14 | pipeline :api do
15 | plug :accepts, ["json"]
16 | end
17 |
18 | redirect "/", "/home", :permanent
19 |
20 | scope "/", SlurpeeWeb do
21 | pipe_through :browser
22 |
23 | live_session :default do
24 | live "/home", HomeLive, :index
25 | live "/blockchains", BlockchainLive, :index
26 | live "/log_subscriptions", LogSubscriptionLive, :index
27 | live "/new_head_subscriptions", NewHeadSubscriptionLive, :index
28 | live "/transactions", TransactionSubscriptionLive, :index
29 | end
30 | end
31 |
32 | scope "/", NotifiedPhoenix do
33 | pipe_through :browser
34 |
35 | live_session :notifications, root_layout: {SlurpeeWeb.LayoutView, :root} do
36 | live("/notifications", ListLive, :index, as: :notification)
37 | end
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/lib/slurpee_web/templates/layout/root.html.leex:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | <%= csrf_meta_tag() %>
8 | <%= live_title_tag assigns[:page_title] || "Slurpee", suffix: " · Fremantle Industries" %>
9 | "/>
10 |
11 |
12 |
13 |
14 |
15 |
21 |
22 | <%= @inner_content %>
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/test/support/conn_case.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.ConnCase do
2 | @moduledoc """
3 | This module defines the test case to be used by
4 | tests that require setting up a connection.
5 |
6 | Such tests rely on `Phoenix.ConnTest` and also
7 | import other functionality to make it easier
8 | to build common data structures and query the data layer.
9 |
10 | Finally, if the test case interacts with the database,
11 | we enable the SQL sandbox, so changes done to the database
12 | are reverted at the end of every test. If you are using
13 | PostgreSQL, you can even run database tests asynchronously
14 | by setting `use SlurpeeWeb.ConnCase, async: true`, although
15 | this option is not recommended for other databases.
16 | """
17 |
18 | use ExUnit.CaseTemplate
19 |
20 | using do
21 | quote do
22 | # Import conveniences for testing with connections
23 | import Plug.Conn
24 | import Phoenix.ConnTest
25 | import SlurpeeWeb.ConnCase
26 |
27 | alias SlurpeeWeb.Router.Helpers, as: Routes
28 |
29 | # The default endpoint for testing
30 | @endpoint SlurpeeWeb.Endpoint
31 | end
32 | end
33 |
34 | setup _tags do
35 | {:ok, conn: Phoenix.ConnTest.build_conn()}
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/lib/slurpee_web/channels/user_socket.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.UserSocket do
2 | use Phoenix.Socket
3 |
4 | ## Channels
5 | # channel "room:*", SlurpeeWeb.RoomChannel
6 |
7 | # Socket params are passed from the client and can
8 | # be used to verify and authenticate a user. After
9 | # verification, you can put default assigns into
10 | # the socket that will be set for all channels, ie
11 | #
12 | # {:ok, assign(socket, :user_id, verified_user_id)}
13 | #
14 | # To deny connection, return `:error`.
15 | #
16 | # See `Phoenix.Token` documentation for examples in
17 | # performing token verification on connect.
18 | @impl true
19 | def connect(_params, socket, _connect_info) do
20 | {:ok, socket}
21 | end
22 |
23 | # Socket id's are topics that allow you to identify all sockets for a given user:
24 | #
25 | # def id(socket), do: "user_socket:#{socket.assigns.user_id}"
26 | #
27 | # Would allow you to broadcast a "disconnect" event and terminate
28 | # all active sockets and channels for a given user:
29 | #
30 | # SlurpeeWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
31 | #
32 | # Returning `nil` makes this socket anonymous.
33 | @impl true
34 | def id(_socket), do: nil
35 | end
36 |
--------------------------------------------------------------------------------
/lib/slurpee/recent_heads.ex:
--------------------------------------------------------------------------------
1 | defmodule Slurpee.RecentHeads do
2 | use GenServer
3 |
4 | def start_link(_) do
5 | queue = Deque.new(100)
6 | GenServer.start_link(__MODULE__, queue, name: __MODULE__)
7 | end
8 |
9 | def queue do
10 | GenServer.call(__MODULE__, :queue)
11 | end
12 |
13 | @impl true
14 | def init(state) do
15 | {:ok, state, {:continue, :subscribe_new_heads}}
16 | end
17 |
18 | @impl true
19 | def handle_continue(:subscribe_new_heads, state) do
20 | Phoenix.PubSub.subscribe(Slurpee.PubSub, "heads:new_head_received")
21 | {:noreply, state}
22 | end
23 |
24 | @impl true
25 | def handle_continue(:publish_recent_head_received, state) do
26 | Phoenix.PubSub.broadcast(
27 | Slurpee.PubSub,
28 | "recent_heads:new_head_received",
29 | {"recent_heads:new_head_received", state}
30 | )
31 |
32 | {:noreply, state}
33 | end
34 |
35 | @impl true
36 | def handle_info({"heads:new_head_received", blockchain_id, block_number}, state) do
37 | state =
38 | state
39 | |> Deque.appendleft({blockchain_id, block_number})
40 |
41 | {:noreply, state, {:continue, :publish_recent_head_received}}
42 | end
43 |
44 | @impl true
45 | def handle_call(:queue, _from, state) do
46 | {:reply, state, state}
47 | end
48 | end
49 |
--------------------------------------------------------------------------------
/lib/slurpee_web/live/transaction_subscription_live.html.leex:
--------------------------------------------------------------------------------
1 | Transaction Subscriptions
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 | Blockchain ID
13 | Enabled
14 | Handler
15 |
16 |
17 |
18 | <%= if Enum.any?(@transaction_subscriptions) do %>
19 | <%= for s <- @transaction_subscriptions do %>
20 |
21 | <%= s.blockchain_id %>
22 | "><%= s.enabled %>
23 | "><%= s.handler |> inspect %>
24 |
25 | <% end %>
26 | <% else %>
27 |
28 | no transaction subscriptions configured
29 |
30 | <% end %>
31 |
32 |
33 |
--------------------------------------------------------------------------------
/lib/slurpee/recent_events.ex:
--------------------------------------------------------------------------------
1 | defmodule Slurpee.RecentEvents do
2 | use GenServer
3 | require Logger
4 |
5 | def start_link(_) do
6 | queue = Deque.new(100)
7 | GenServer.start_link(__MODULE__, queue, name: __MODULE__)
8 | end
9 |
10 | def queue do
11 | GenServer.call(__MODULE__, :queue)
12 | end
13 |
14 | @impl true
15 | def init(state) do
16 | {:ok, state, {:continue, :receive_events}}
17 | end
18 |
19 | @impl true
20 | def handle_continue(:receive_events, state) do
21 | Phoenix.PubSub.subscribe(Slurpee.PubSub, "events:event_received")
22 | {:noreply, state}
23 | end
24 |
25 | @impl true
26 | def handle_continue(:publish_recent_event_received, state) do
27 | Phoenix.PubSub.broadcast(
28 | Slurpee.PubSub,
29 | "recent_events:event_received",
30 | {"recent_events:event_received", state}
31 | )
32 |
33 | {:noreply, state}
34 | end
35 |
36 | @impl true
37 | def handle_info(
38 | {"events:event_received", blockchain_id, block_number, block_hash, address, event},
39 | state
40 | ) do
41 | state =
42 | state
43 | |> Deque.appendleft({blockchain_id, block_number, block_hash, address, event})
44 |
45 | {:noreply, state, {:continue, :publish_recent_event_received}}
46 | end
47 |
48 | @impl true
49 | def handle_call(:queue, _from, state) do
50 | {:reply, state, state}
51 | end
52 | end
53 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: test
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | pull_request:
8 | branches:
9 | - '*'
10 |
11 | jobs:
12 | test:
13 | runs-on: ubuntu-latest
14 | name: Test OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
15 |
16 | strategy:
17 | matrix:
18 | otp: [22.x, 23.x, 24.x]
19 | elixir: [1.11.x, 1.12.x]
20 |
21 | steps:
22 | - uses: actions/checkout@v3
23 |
24 | - uses: erlef/setup-beam@v1.13
25 | with:
26 | otp-version: ${{matrix.otp}}
27 | elixir-version: ${{matrix.elixir}}
28 |
29 | - name: Cache Dependencies
30 | uses: actions/cache@v3.0.9
31 | with:
32 | path: |
33 | deps
34 | _build/dev
35 | _build/test
36 | key: elixir-cache-${{secrets.CACHE_VERSION}}-${{matrix.elixir}}-otp-${{matrix.otp}}-${{runner.os}}-${{hashFiles('mix.lock')}}-${{hashFiles('assets/package-lock.json')}}-${{github.ref}}
37 | restore-keys: |
38 | elixir-cache-${{secrets.CACHE_VERSION}}-${{matrix.elixir}}-otp-${{matrix.otp}}-${{runner.os}}-${{hashFiles('mix.lock')}}-${{hashFiles('assets/package-lock.json')}}
39 | elixir-cache-${{secrets.CACHE_VERSION}}-${{matrix.elixir}}-otp-${{matrix.otp}}-${{runner.os}}-
40 |
41 | - name: Install Dependencies
42 | run: mix deps.get
43 |
44 | - name: Test
45 | run: mix test
46 |
47 | - name: Dialyzer
48 | run: mix dialyzer
49 |
--------------------------------------------------------------------------------
/lib/slurpee_web/telemetry.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.Telemetry do
2 | use Supervisor
3 | import Telemetry.Metrics
4 |
5 | def start_link(arg) do
6 | Supervisor.start_link(__MODULE__, arg, name: __MODULE__)
7 | end
8 |
9 | @impl true
10 | def init(_arg) do
11 | children = [
12 | {:telemetry_poller, measurements: periodic_measurements(), period: 10_000},
13 | {TelemetryMetricsPrometheus,
14 | [
15 | metrics: metrics(),
16 | name: prometheus_metrics_name(),
17 | port: prometheus_metrics_port(),
18 | options: [ref: :"TelemetryMetricsPrometheus.Router.HTTP_#{prometheus_metrics_port()}"]
19 | ]}
20 | ]
21 |
22 | Supervisor.init(children, strategy: :one_for_one)
23 | end
24 |
25 | def metrics do
26 | [
27 | # Slurp Metrics
28 | last_value("slurp.blockchains.start", tags: [:id]),
29 | last_value("slurp.blockchains.stop", tags: [:id]),
30 |
31 | # Phoenix Metrics
32 | last_value("phoenix.endpoint.stop.duration",
33 | unit: {:native, :millisecond}
34 | ),
35 | last_value("phoenix.router_dispatch.stop.duration",
36 | tags: [:route],
37 | unit: {:native, :millisecond}
38 | )
39 | ]
40 | end
41 |
42 | defp prometheus_metrics_name do
43 | Application.get_env(:slurpee, :metrics_name, :slurpee_prometheus_metrics)
44 | end
45 |
46 | defp prometheus_metrics_port do
47 | Application.get_env(:slurpee, :prometheus_metrics_port, 9568)
48 | end
49 |
50 | defp periodic_measurements do
51 | []
52 | end
53 | end
54 |
--------------------------------------------------------------------------------
/lib/slurpee_web/live/new_head_subscription_live.html.leex:
--------------------------------------------------------------------------------
1 | New Head Subscriptions
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 | Blockchain ID
13 | Enabled
14 | Handler
15 |
16 |
17 |
18 | <%= if Enum.any?(@new_head_subscriptions) do %>
19 | <%= for s <- @new_head_subscriptions do %>
20 |
21 | <%= s.blockchain_id %>
22 | "><%= s.enabled %>
23 | "><%= s.handler |> inspect %>
24 |
25 | <% end %>
26 | <% else %>
27 |
28 |
29 | <%= if @query == nil do %>
30 | no new head subscriptions configured
31 | <% else %>
32 | no search results
33 | <% end %>
34 |
35 |
36 | <% end %>
37 |
38 |
39 |
--------------------------------------------------------------------------------
/lib/slurpee_web/endpoint.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.Endpoint do
2 | use Phoenix.Endpoint, otp_app: :slurpee
3 |
4 | # The session will be stored in the cookie and signed,
5 | # this means its contents can be read but not tampered with.
6 | # Set :encryption_salt if you would also like to encrypt it.
7 | @session_options [
8 | store: :cookie,
9 | key: "_slurpee_key",
10 | signing_salt: "CFkUdk0A"
11 | ]
12 |
13 | socket "/socket", SlurpeeWeb.UserSocket,
14 | websocket: true,
15 | longpoll: false
16 |
17 | socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]]
18 |
19 | # Serve at "/" the static files from "priv/static" directory.
20 | #
21 | # You should set gzip to true if you are running phx.digest
22 | # when deploying your static files in production.
23 | plug Plug.Static,
24 | at: "/",
25 | from: :slurpee,
26 | gzip: false,
27 | only: ~w(css fonts images js favicon.ico robots.txt)
28 |
29 | # Code reloading can be explicitly enabled under the
30 | # :code_reloader configuration of your endpoint.
31 | if code_reloading? do
32 | socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
33 | plug Phoenix.LiveReloader
34 | plug Phoenix.CodeReloader
35 | end
36 |
37 | plug Plug.RequestId
38 | plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
39 |
40 | plug Plug.Parsers,
41 | parsers: [:urlencoded, :multipart, :json],
42 | pass: ["*/*"],
43 | json_decoder: Phoenix.json_library()
44 |
45 | plug Plug.MethodOverride
46 | plug Plug.Head
47 | plug Plug.Session, @session_options
48 | plug SlurpeeWeb.Router
49 | end
50 |
--------------------------------------------------------------------------------
/lib/slurpee_web/views/error_helpers.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.ErrorHelpers do
2 | @moduledoc """
3 | Conveniences for translating and building error messages.
4 | """
5 |
6 | use Phoenix.HTML
7 |
8 | @doc """
9 | Generates tag for inlined form input errors.
10 | """
11 | def error_tag(form, field) do
12 | Enum.map(Keyword.get_values(form.errors, field), fn error ->
13 | content_tag(:span, translate_error(error),
14 | class: "invalid-feedback",
15 | phx_feedback_for: input_id(form, field)
16 | )
17 | end)
18 | end
19 |
20 | @doc """
21 | Translates an error message using gettext.
22 | """
23 | def translate_error({msg, opts}) do
24 | # When using gettext, we typically pass the strings we want
25 | # to translate as a static argument:
26 | #
27 | # # Translate "is invalid" in the "errors" domain
28 | # dgettext("errors", "is invalid")
29 | #
30 | # # Translate the number of files with plural rules
31 | # dngettext("errors", "1 file", "%{count} files", count)
32 | #
33 | # Because the error messages we show in our forms and APIs
34 | # are defined inside Ecto, we need to translate them dynamically.
35 | # This requires us to call the Gettext module passing our gettext
36 | # backend as first argument.
37 | #
38 | # Note we use the "errors" domain, which means translations
39 | # should be written to the errors.po file. The :count option is
40 | # set by Ecto and indicates we should also apply plural rules.
41 | if count = opts[:count] do
42 | Gettext.dngettext(SlurpeeWeb.Gettext, "errors", msg, msg, count, opts)
43 | else
44 | Gettext.dgettext(SlurpeeWeb.Gettext, "errors", msg, opts)
45 | end
46 | end
47 | end
48 |
--------------------------------------------------------------------------------
/assets/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "repository": {},
3 | "description": " ",
4 | "license": "MIT",
5 | "scripts": {
6 | "deploy": "NODE_ENV=production webpack --mode production",
7 | "watch": "NODE_ENV=development webpack --mode development --watch"
8 | },
9 | "dependencies": {
10 | "@popperjs/core": "^2.11.6",
11 | "notified_phoenix": "file:../deps/notified_phoenix",
12 | "phoenix": "file:../deps/phoenix",
13 | "phoenix_html": "file:../deps/phoenix_html",
14 | "phoenix_live_react": "file:../deps/phoenix_live_react",
15 | "phoenix_live_view": "file:../deps/phoenix_live_view",
16 | "react": "^18.2.0",
17 | "react-dom": "^18.2.0",
18 | "react-timeago": "^7.1.0",
19 | "topbar": "^1.0.1"
20 | },
21 | "devDependencies": {
22 | "@babel/core": "^7.19.3",
23 | "@babel/preset-env": "^7.19.3",
24 | "@babel/preset-react": "^7.18.6",
25 | "@tailwindcss/forms": "^0.5.3",
26 | "@types/react": "^18.0.21",
27 | "@types/react-dom": "^18.0.6",
28 | "@types/react-timeago": "^4.1.3",
29 | "@types/phoenix": "^1.5.4",
30 | "@types/phoenix_live_view": "^0.15.1",
31 | "autoprefixer": "^10.4.12",
32 | "babel-loader": "^8.2.5",
33 | "copy-webpack-plugin": "^11.0.0",
34 | "css-loader": "^6.7.1",
35 | "hard-source-webpack-plugin": "^0.13.1",
36 | "mini-css-extract-plugin": "^2.6.1",
37 | "optimize-css-assets-webpack-plugin": "^6.0.1",
38 | "postcss": "^8.4.17",
39 | "postcss-import": "^15.0.0",
40 | "postcss-loader": "^7.0.1",
41 | "postcss-preset-env": "^7.8.2",
42 | "tailwindcss": "^3.1.8",
43 | "tailwindcss-empty-pseudo-class": "^1.0.0",
44 | "terser-webpack-plugin": "^5.3.6",
45 | "ts-loader": "^9.4.1",
46 | "typescript": "^4.8.4",
47 | "webpack": "5.74.0",
48 | "webpack-cli": "^4.10.0"
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/assets/js/app.ts:
--------------------------------------------------------------------------------
1 | // We need to import the CSS so that webpack will load it.
2 | // The MiniCssExtractPlugin is used to separate it out into
3 | // its own CSS file.
4 | import "../css/app.css"
5 |
6 | // webpack automatically bundles all modules in your
7 | // entry points. Those entry points can be configured
8 | // in "webpack.config.js".
9 | //
10 | // Import deps with the dep name or local files with a relative path, for example:
11 | //
12 | // import {Socket} from "phoenix"
13 | // import socket from "./socket"
14 | //
15 | import "phoenix_html"
16 | import {Socket} from "phoenix"
17 | import * as topbar from "topbar"
18 | import {LiveSocket} from "phoenix_live_view"
19 |
20 | // LiveReact
21 | // @ts-ignore
22 | import {initLiveReact} from "phoenix_live_react"
23 | import {Components} from "./components"
24 | // @ts-ignore
25 | window.Components = Components
26 | document.addEventListener("DOMContentLoaded", () => initLiveReact())
27 |
28 | import {hooks} from "./hooks"
29 | let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
30 | let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}, hooks})
31 |
32 | // Show progress bar on live navigation and form submits
33 | topbar.config({barColors: {0: "#29d"}, shadowColor: "rgba(0, 0, 0, .3)"})
34 | window.addEventListener("phx:page-loading-start", () => topbar.show())
35 | window.addEventListener("phx:page-loading-stop", () => topbar.hide())
36 |
37 | // connect if there are any LiveViews on the page
38 | liveSocket.connect()
39 |
40 | // expose liveSocket on window for web console debug logs and latency simulation:
41 | // >> liveSocket.enableDebug()
42 | // >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
43 | // >> liveSocket.disableLatencySim()
44 | // window.liveSocket = liveSocket
45 |
--------------------------------------------------------------------------------
/lib/slurpee_web/live/new_head_subscription_live.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.NewHeadSubscriptionLive do
2 | use SlurpeeWeb, :live_view
3 | import SlurpeeWeb.ViewHelpers.SearchQueryHelper, only: [assign_search_query: 2]
4 |
5 | @impl true
6 | def mount(_params, _session, socket) do
7 | socket =
8 | socket
9 | |> assign(:query, nil)
10 |
11 | {:ok, socket}
12 | end
13 |
14 | @impl true
15 | def handle_params(params, _uri, socket) do
16 | socket =
17 | socket
18 | |> assign_search_query(params)
19 | |> assign_search()
20 |
21 | {:noreply, socket}
22 | end
23 |
24 | @impl true
25 | def handle_event("search", params, socket) do
26 | socket =
27 | socket
28 | |> assign_search_query(params)
29 | |> send_search_after(200)
30 |
31 | {:noreply, socket}
32 | end
33 |
34 | @impl true
35 | def handle_info(:search, socket) do
36 | socket =
37 | socket
38 | |> assign(:search_timer, nil)
39 | |> assign_search()
40 |
41 | {:noreply, socket}
42 | end
43 |
44 | defp send_search_after(socket, after_ms) do
45 | if socket.assigns[:search_timer] do
46 | socket
47 | else
48 | timer = Process.send_after(self(), :search, after_ms)
49 | assign(socket, :search_timer, timer)
50 | end
51 | end
52 |
53 | defp assign_search(socket) do
54 | socket
55 | |> assign(new_head_subscriptions: search_new_head_subscriptions(socket.assigns.query))
56 | end
57 |
58 | defp search_new_head_subscriptions(search_term) do
59 | []
60 | |> Slurp.Commander.new_head_subscriptions()
61 | |> search_new_head_subscriptions(search_term)
62 | end
63 |
64 | defp search_new_head_subscriptions(new_head_subscriptions, nil) do
65 | new_head_subscriptions
66 | end
67 |
68 | defp search_new_head_subscriptions(new_head_subscriptions, search_term) do
69 | new_head_subscriptions
70 | |> Enum.filter(fn s ->
71 | String.contains?(s.blockchain_id, search_term) ||
72 | String.contains?(s.enabled |> to_string(), search_term) ||
73 | String.contains?(s.handler |> inspect(), search_term)
74 | end)
75 | end
76 | end
77 |
--------------------------------------------------------------------------------
/lib/slurpee_web/live/log_subscription_live.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.LogSubscriptionLive do
2 | use SlurpeeWeb, :live_view
3 | import SlurpeeWeb.ViewHelpers.SearchQueryHelper, only: [assign_search_query: 2]
4 | import SlurpeeWeb.ViewHelpers.EllipsisHelper, only: [ellipsis: 2]
5 |
6 | @impl true
7 | def mount(_params, _session, socket) do
8 | socket =
9 | socket
10 | |> assign(:query, nil)
11 |
12 | {:ok, socket}
13 | end
14 |
15 | @impl true
16 | def handle_params(params, _uri, socket) do
17 | socket =
18 | socket
19 | |> assign_search_query(params)
20 | |> assign_search()
21 |
22 | {:noreply, socket}
23 | end
24 |
25 | @impl true
26 | def handle_event("search", params, socket) do
27 | socket =
28 | socket
29 | |> assign_search_query(params)
30 | |> send_search_after(200)
31 |
32 | {:noreply, socket}
33 | end
34 |
35 | @impl true
36 | def handle_info(:search, socket) do
37 | socket =
38 | socket
39 | |> assign(:search_timer, nil)
40 | |> assign_search()
41 |
42 | {:noreply, socket}
43 | end
44 |
45 | defp send_search_after(socket, after_ms) do
46 | if socket.assigns[:search_timer] do
47 | socket
48 | else
49 | timer = Process.send_after(self(), :search, after_ms)
50 | assign(socket, :search_timer, timer)
51 | end
52 | end
53 |
54 | defp assign_search(socket) do
55 | socket
56 | |> assign(log_subscriptions: search_log_subscriptions(socket.assigns.query))
57 | end
58 |
59 | defp search_log_subscriptions(search_term) do
60 | []
61 | |> Slurp.Commander.log_subscriptions()
62 | |> search_log_subscriptions(search_term)
63 | end
64 |
65 | defp search_log_subscriptions(log_subscriptions, nil) do
66 | log_subscriptions
67 | end
68 |
69 | defp search_log_subscriptions(log_subscriptions, search_term) do
70 | log_subscriptions
71 | |> Enum.filter(fn s ->
72 | String.contains?(s.blockchain_id, search_term) ||
73 | String.contains?(s.event_signature, search_term) ||
74 | String.contains?(s.hashed_event_signature, search_term) ||
75 | String.contains?(s.enabled |> to_string(), search_term) ||
76 | String.contains?(s.handler |> inspect(), search_term)
77 | end)
78 | end
79 | end
80 |
--------------------------------------------------------------------------------
/assets/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const glob = require('glob');
3 | const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4 | const TerserPlugin = require('terser-webpack-plugin');
5 | const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
6 | const CopyWebpackPlugin = require('copy-webpack-plugin');
7 |
8 | module.exports = (_env, options) => {
9 | const devMode = options.mode !== 'production';
10 |
11 | return {
12 | mode: options.mode || 'development',
13 |
14 | optimization: {
15 | minimizer: [
16 | new TerserPlugin({parallel: true}),
17 | new OptimizeCSSAssetsPlugin({})
18 | ]
19 | },
20 | entry: {
21 | 'app': glob.sync('./vendor/**/*.js').concat(['./js/app.ts'])
22 | },
23 | output: {
24 | filename: '[name].js',
25 | path: path.resolve(__dirname, '../priv/static/js'),
26 | publicPath: '/js/'
27 | },
28 | devtool: devMode ? 'eval-cheap-module-source-map' : undefined,
29 |
30 | module: {
31 | rules: [
32 | {
33 | test: /\.tsx?$/,
34 | use: 'ts-loader',
35 | exclude: /node_modules/,
36 | },
37 |
38 | {
39 | test: /\.css$/,
40 | use: [
41 | MiniCssExtractPlugin.loader,
42 | 'css-loader',
43 | {
44 | loader: "postcss-loader",
45 | options: {
46 | postcssOptions: {
47 | plugins: [
48 | [
49 | "postcss-preset-env",
50 | {
51 | // Options
52 | },
53 | ],
54 | ],
55 | },
56 | },
57 | }
58 | ],
59 | }
60 | ]
61 | },
62 |
63 | resolve: {
64 | extensions: [".ts", ".tsx", ".js"],
65 | alias: {
66 | react: path.resolve(__dirname, './node_modules/react'),
67 | 'react-dom': path.resolve(__dirname, './node_modules/react-dom')
68 | }
69 | },
70 |
71 | plugins: [
72 | new MiniCssExtractPlugin({filename: '../css/app.css'}),
73 | new CopyWebpackPlugin({
74 | patterns: [
75 | {from: "static/", to: "../"}
76 | ]
77 | })
78 | ]
79 | }
80 | };
81 |
--------------------------------------------------------------------------------
/mix.exs:
--------------------------------------------------------------------------------
1 | defmodule Slurpee.MixProject do
2 | use Mix.Project
3 |
4 | def project do
5 | [
6 | app: :slurpee,
7 | version: "0.0.18",
8 | elixir: "~> 1.11",
9 | elixirc_paths: elixirc_paths(Mix.env()),
10 | compilers: [:phoenix, :gettext] ++ Mix.compilers(),
11 | start_permanent: Mix.env() == :prod,
12 | aliases: aliases(),
13 | deps: deps(),
14 | description: description(),
15 | package: package()
16 | ]
17 | end
18 |
19 | def application do
20 | [
21 | mod: {Slurpee.Application, []},
22 | extra_applications: [:logger, :runtime_tools]
23 | ]
24 | end
25 |
26 | defp elixirc_paths(:dev), do: ["lib", "examples"]
27 | defp elixirc_paths(:test), do: ["lib", "examples", "test/support"]
28 | defp elixirc_paths(_), do: ["lib"]
29 |
30 | defp deps do
31 | [
32 | {:confex, "~> 3.5"},
33 | {:deque, "~> 1.0"},
34 | {:gettext, "~> 0.11"},
35 | {:jason, "~> 1.0"},
36 | {:navigator, "~> 0.0.8"},
37 | {:notified_phoenix, "~> 0.0.7"},
38 | {:phoenix, "~> 1.6.0"},
39 | {:phoenix_html, "~> 3.0"},
40 | {:phoenix_live_react, "~> 0.4.1"},
41 | {:phoenix_live_view, "~> 0.17"},
42 | {:plug_cowboy, "~> 2.0"},
43 | {:redirect, "~> 0.3"},
44 | # {:slurp, github: "fremantle-industries/slurp", branch: "main"},
45 | {:slurp, "~> 0.0.12"},
46 | # {:stylish, github: "fremantle-industries/stylish", branch: "main"},
47 | {:stylish, "~> 0.0.9"},
48 | {:telemetry_metrics, "~> 0.4"},
49 | {:telemetry_poller, "~> 1.0"},
50 | {:excoveralls, "~> 0.8", only: :test},
51 | {:ex_unit_notifier, "~> 1.0", only: :test},
52 | {:floki, ">= 0.27.0", only: :test},
53 | {:phoenix_live_reload, "~> 1.2", only: :dev},
54 | {:dialyxir, "~> 1.0", only: :dev, runtime: false},
55 | {:mix_test_watch, "~> 1.0", only: :dev, runtime: false},
56 | {:logger_file_backend, "~> 0.0.10", only: [:dev, :test]}
57 | ]
58 | end
59 |
60 | defp aliases do
61 | [
62 | setup: ["deps.get", "cmd npm install --prefix assets"]
63 | ]
64 | end
65 |
66 | defp description do
67 | "A GUI to manage EVM blockchain ingestion"
68 | end
69 |
70 | defp package do
71 | %{
72 | licenses: ["MIT"],
73 | maintainers: ["Alex Kwiatkowski"],
74 | links: %{"GitHub" => "https://github.com/fremantle-industries/slurpee"}
75 | }
76 | end
77 | end
78 |
--------------------------------------------------------------------------------
/lib/slurpee_web/live/log_subscription_live.html.leex:
--------------------------------------------------------------------------------
1 | Log Subscriptions
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 | Blockchain ID
13 | Event Signature
14 | Hashed Event Signature
15 | Enabled
16 | Handler
17 | Events
18 |
19 |
20 |
21 | <%= if Enum.any?(@log_subscriptions) do %>
22 | <%= for s <- @log_subscriptions do %>
23 |
24 | ">
25 | <%= s.blockchain_id %>
26 |
27 | ">
28 | <%= ellipsis(s.event_signature, 50) %>
29 |
30 | ">
31 | <%= s.hashed_event_signature |> String.slice(0..18) %>...
32 |
33 | ">
34 | <%= s.enabled %>
35 |
36 | ">
37 | <%= s.handler |> inspect %>
38 |
39 | ">
40 | <%= s.event_mappings |> Enum.map(fn {s, _abi} -> Atom.to_string(s) end) |> Enum.join(", ") %>
41 |
42 |
43 | <% end %>
44 | <% else %>
45 |
46 |
47 | <%= if @query == nil do %>
48 | no log subscriptions configured
49 | <% else %>
50 | no search results
51 | <% end %>
52 |
53 |
54 | <% end %>
55 |
56 |
57 |
--------------------------------------------------------------------------------
/lib/slurpee_web/live/home_live.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.HomeLive do
2 | use SlurpeeWeb, :live_view
3 |
4 | @impl true
5 | def mount(_params, _session, socket) do
6 | Phoenix.PubSub.subscribe(Slurpee.PubSub, "events:event_received")
7 | Phoenix.PubSub.subscribe(Slurpee.PubSub, "recent_heads:new_head_received")
8 | Phoenix.PubSub.subscribe(Slurpee.PubSub, "blockchain_statistics:new_stats")
9 | stats = Slurpee.BlockchainStatistics.get()
10 |
11 | socket =
12 | socket
13 | |> assign(last_head_received_at: stats.last_head_received_at)
14 | |> assign(block_cadence_seconds: stats.block_cadence_seconds)
15 | |> assign(events_per_second: stats.events_per_second)
16 | |> assign(recent_blocks: Slurpee.RecentHeads.queue())
17 | |> assign(recent_events: Slurpee.RecentEvents.queue())
18 |
19 | {:ok, socket}
20 | end
21 |
22 | @impl true
23 | def handle_info(
24 | {"events:event_received", blockchain_id, block_number, block_hash, address, event},
25 | socket
26 | ) do
27 | recent_events =
28 | socket.assigns.recent_events
29 | |> Deque.appendleft({blockchain_id, block_number, block_hash, address, event})
30 |
31 | socket =
32 | socket
33 | |> assign(recent_events: recent_events)
34 |
35 | {:noreply, socket}
36 | end
37 |
38 | @impl true
39 | def handle_info({"recent_heads:new_head_received", recent_heads}, socket) do
40 | socket =
41 | socket
42 | |> assign(recent_blocks: recent_heads)
43 |
44 | {:noreply, socket}
45 | end
46 |
47 | @impl true
48 | def handle_info(
49 | {"blockchain_statistics:new_stats", stats},
50 | socket
51 | ) do
52 | socket =
53 | socket
54 | |> assign(last_head_received_at: stats.last_head_received_at)
55 | |> assign(block_cadence_seconds: stats.block_cadence_seconds)
56 | |> assign(events_per_second: stats.events_per_second)
57 |
58 | {:noreply, socket}
59 | end
60 |
61 | defp last_head_received_at(nil), do: nil
62 |
63 | defp last_head_received_at(received_at) when is_integer(received_at) do
64 | received_latency =
65 | System.convert_time_unit(System.monotonic_time() - received_at, :native, :millisecond)
66 |
67 | unix_now = "Etc/UTC" |> DateTime.now!() |> DateTime.to_unix(:millisecond)
68 | unix_now - received_latency
69 | end
70 |
71 | defp format_event_attr(value) when is_binary(value) and byte_size(value) == 20 do
72 | value |> Base.encode16(case: :lower) |> ExW3.Utils.to_checksum_address()
73 | end
74 |
75 | defp format_event_attr(value), do: value |> inspect
76 | end
77 |
--------------------------------------------------------------------------------
/priv/gettext/en/LC_MESSAGES/errors.po:
--------------------------------------------------------------------------------
1 | ## `msgid`s in this file come from POT (.pot) files.
2 | ##
3 | ## Do not add, change, or remove `msgid`s manually here as
4 | ## they're tied to the ones in the corresponding POT file
5 | ## (with the same domain).
6 | ##
7 | ## Use `mix gettext.extract --merge` or `mix gettext.merge`
8 | ## to merge POT files into PO files.
9 | msgid ""
10 | msgstr ""
11 | "Language: en\n"
12 |
13 | ## From Ecto.Changeset.cast/4
14 | msgid "can't be blank"
15 | msgstr ""
16 |
17 | ## From Ecto.Changeset.unique_constraint/3
18 | msgid "has already been taken"
19 | msgstr ""
20 |
21 | ## From Ecto.Changeset.put_change/3
22 | msgid "is invalid"
23 | msgstr ""
24 |
25 | ## From Ecto.Changeset.validate_acceptance/3
26 | msgid "must be accepted"
27 | msgstr ""
28 |
29 | ## From Ecto.Changeset.validate_format/3
30 | msgid "has invalid format"
31 | msgstr ""
32 |
33 | ## From Ecto.Changeset.validate_subset/3
34 | msgid "has an invalid entry"
35 | msgstr ""
36 |
37 | ## From Ecto.Changeset.validate_exclusion/3
38 | msgid "is reserved"
39 | msgstr ""
40 |
41 | ## From Ecto.Changeset.validate_confirmation/3
42 | msgid "does not match confirmation"
43 | msgstr ""
44 |
45 | ## From Ecto.Changeset.no_assoc_constraint/3
46 | msgid "is still associated with this entry"
47 | msgstr ""
48 |
49 | msgid "are still associated with this entry"
50 | msgstr ""
51 |
52 | ## From Ecto.Changeset.validate_length/3
53 | msgid "should be %{count} character(s)"
54 | msgid_plural "should be %{count} character(s)"
55 | msgstr[0] ""
56 | msgstr[1] ""
57 |
58 | msgid "should have %{count} item(s)"
59 | msgid_plural "should have %{count} item(s)"
60 | msgstr[0] ""
61 | msgstr[1] ""
62 |
63 | msgid "should be at least %{count} character(s)"
64 | msgid_plural "should be at least %{count} character(s)"
65 | msgstr[0] ""
66 | msgstr[1] ""
67 |
68 | msgid "should have at least %{count} item(s)"
69 | msgid_plural "should have at least %{count} item(s)"
70 | msgstr[0] ""
71 | msgstr[1] ""
72 |
73 | msgid "should be at most %{count} character(s)"
74 | msgid_plural "should be at most %{count} character(s)"
75 | msgstr[0] ""
76 | msgstr[1] ""
77 |
78 | msgid "should have at most %{count} item(s)"
79 | msgid_plural "should have at most %{count} item(s)"
80 | msgstr[0] ""
81 | msgstr[1] ""
82 |
83 | ## From Ecto.Changeset.validate_number/3
84 | msgid "must be less than %{number}"
85 | msgstr ""
86 |
87 | msgid "must be greater than %{number}"
88 | msgstr ""
89 |
90 | msgid "must be less than or equal to %{number}"
91 | msgstr ""
92 |
93 | msgid "must be greater than or equal to %{number}"
94 | msgstr ""
95 |
96 | msgid "must be equal to %{number}"
97 | msgstr ""
98 |
--------------------------------------------------------------------------------
/priv/gettext/errors.pot:
--------------------------------------------------------------------------------
1 | ## This is a PO Template file.
2 | ##
3 | ## `msgid`s here are often extracted from source code.
4 | ## Add new translations manually only if they're dynamic
5 | ## translations that can't be statically extracted.
6 | ##
7 | ## Run `mix gettext.extract` to bring this file up to
8 | ## date. Leave `msgstr`s empty as changing them here has no
9 | ## effect: edit them in PO (`.po`) files instead.
10 |
11 | ## From Ecto.Changeset.cast/4
12 | msgid "can't be blank"
13 | msgstr ""
14 |
15 | ## From Ecto.Changeset.unique_constraint/3
16 | msgid "has already been taken"
17 | msgstr ""
18 |
19 | ## From Ecto.Changeset.put_change/3
20 | msgid "is invalid"
21 | msgstr ""
22 |
23 | ## From Ecto.Changeset.validate_acceptance/3
24 | msgid "must be accepted"
25 | msgstr ""
26 |
27 | ## From Ecto.Changeset.validate_format/3
28 | msgid "has invalid format"
29 | msgstr ""
30 |
31 | ## From Ecto.Changeset.validate_subset/3
32 | msgid "has an invalid entry"
33 | msgstr ""
34 |
35 | ## From Ecto.Changeset.validate_exclusion/3
36 | msgid "is reserved"
37 | msgstr ""
38 |
39 | ## From Ecto.Changeset.validate_confirmation/3
40 | msgid "does not match confirmation"
41 | msgstr ""
42 |
43 | ## From Ecto.Changeset.no_assoc_constraint/3
44 | msgid "is still associated with this entry"
45 | msgstr ""
46 |
47 | msgid "are still associated with this entry"
48 | msgstr ""
49 |
50 | ## From Ecto.Changeset.validate_length/3
51 | msgid "should be %{count} character(s)"
52 | msgid_plural "should be %{count} character(s)"
53 | msgstr[0] ""
54 | msgstr[1] ""
55 |
56 | msgid "should have %{count} item(s)"
57 | msgid_plural "should have %{count} item(s)"
58 | msgstr[0] ""
59 | msgstr[1] ""
60 |
61 | msgid "should be at least %{count} character(s)"
62 | msgid_plural "should be at least %{count} character(s)"
63 | msgstr[0] ""
64 | msgstr[1] ""
65 |
66 | msgid "should have at least %{count} item(s)"
67 | msgid_plural "should have at least %{count} item(s)"
68 | msgstr[0] ""
69 | msgstr[1] ""
70 |
71 | msgid "should be at most %{count} character(s)"
72 | msgid_plural "should be at most %{count} character(s)"
73 | msgstr[0] ""
74 | msgstr[1] ""
75 |
76 | msgid "should have at most %{count} item(s)"
77 | msgid_plural "should have at most %{count} item(s)"
78 | msgstr[0] ""
79 | msgstr[1] ""
80 |
81 | ## From Ecto.Changeset.validate_number/3
82 | msgid "must be less than %{number}"
83 | msgstr ""
84 |
85 | msgid "must be greater than %{number}"
86 | msgstr ""
87 |
88 | msgid "must be less than or equal to %{number}"
89 | msgstr ""
90 |
91 | msgid "must be greater than or equal to %{number}"
92 | msgstr ""
93 |
94 | msgid "must be equal to %{number}"
95 | msgstr ""
96 |
--------------------------------------------------------------------------------
/lib/slurpee_web/live/home_live.html.leex:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | last block:
5 | <%= if @last_head_received_at do %>
6 | <%= live_react_component(
7 | "Components.TimeAgo",
8 | [date: last_head_received_at(@last_head_received_at), maxPeriod: 1],
9 | receiver_tag: "span",
10 | container_tag: "span",
11 | id: "last-block-received-at"
12 | ) %>
13 | <% else %>
14 | -
15 | <% end %>
16 |
17 |
18 |
19 |
20 | block cadence: <%= @block_cadence_seconds %>s
21 |
22 |
23 |
24 |
25 | events/s: <%= @events_per_second %>
26 |
27 |
28 |
29 |
30 |
31 |
32 |
Recent Blocks
33 |
49 |
50 |
51 |
Recent Events
52 | <%= if Enum.any?(@recent_events) do %>
53 | <%= for {blockchain_id, block_number, block_hash, address, %event_name{} = event} <- @recent_events do %>
54 |
55 |
<%= event_name %>
56 |
57 | <%= blockchain_id %>
58 | <%= component &SlurpeeWeb.BlockNumberComponent.pill/1, block_number: block_number %>
59 |
60 |
61 | block hash: <%= block_hash %>
62 | address: <%= address %>
63 | <%= for k <- Map.keys(event) do %>
64 | <%= if k != :__struct__ do %>
65 | <%= k %>: <%= event |> Map.get(k) |> format_event_attr %>
66 | <% end %>
67 | <% end %>
68 |
69 |
70 | <% end %>
71 | <% else %>
72 |
waiting for new event logs...
73 | <% end %>
74 |
75 |
76 |
--------------------------------------------------------------------------------
/lib/slurpee/blockchain_statistics.ex:
--------------------------------------------------------------------------------
1 | defmodule Slurpee.BlockchainStatistics do
2 | use GenServer
3 |
4 | defmodule State do
5 | defstruct ~w[last_head_received_at new_heads_received_total events_received_total started_at]a
6 | end
7 |
8 | defmodule Stats do
9 | defstruct ~w[last_head_received_at block_cadence_seconds events_per_second]a
10 | end
11 |
12 | def start_link(_) do
13 | state = %State{
14 | new_heads_received_total: 0,
15 | events_received_total: 0,
16 | started_at: System.monotonic_time()
17 | }
18 |
19 | GenServer.start_link(__MODULE__, state, name: __MODULE__)
20 | end
21 |
22 | def get do
23 | GenServer.call(__MODULE__, :get)
24 | end
25 |
26 | @impl true
27 | def init(state) do
28 | {:ok, state, {:continue, :subscribe}}
29 | end
30 |
31 | @impl true
32 | def handle_continue(:subscribe, state) do
33 | Phoenix.PubSub.subscribe(Slurpee.PubSub, "heads:new_head_received")
34 | Phoenix.PubSub.subscribe(Slurpee.PubSub, "events:event_received")
35 | {:noreply, state}
36 | end
37 |
38 | @impl true
39 | def handle_continue(:publish_new_stats, state) do
40 | Phoenix.PubSub.broadcast(
41 | Slurpee.PubSub,
42 | "blockchain_statistics:new_stats",
43 | {"blockchain_statistics:new_stats", build_stats(state)}
44 | )
45 |
46 | {:noreply, state}
47 | end
48 |
49 | @impl true
50 | def handle_info({"heads:new_head_received", _blockchain_id, _block_number}, state) do
51 | state = %{
52 | state
53 | | last_head_received_at: System.monotonic_time(),
54 | new_heads_received_total: state.new_heads_received_total + 1
55 | }
56 |
57 | {:noreply, state, {:continue, :publish_new_stats}}
58 | end
59 |
60 | @impl true
61 | def handle_info(
62 | {"events:event_received", _blockchain_id, _block_number, _block_hash, _address, _event},
63 | state
64 | ) do
65 | state = %{state | events_received_total: state.events_received_total + 1}
66 | {:noreply, state, {:continue, :publish_new_stats}}
67 | end
68 |
69 | @impl true
70 | def handle_call(:get, _from, state) do
71 | {:reply, build_stats(state), state}
72 | end
73 |
74 | defp build_stats(state) do
75 | %Stats{
76 | last_head_received_at: state.last_head_received_at,
77 | block_cadence_seconds: block_cadence_seconds(state),
78 | events_per_second: events_per_second(state)
79 | }
80 | end
81 |
82 | defp block_cadence_seconds(%State{new_heads_received_total: 0}), do: 0
83 |
84 | defp block_cadence_seconds(state) do
85 | now = System.monotonic_time()
86 |
87 | seconds_passed =
88 | System.convert_time_unit(now - state.started_at, :native, :millisecond) / 1000
89 |
90 | Float.round(seconds_passed / state.new_heads_received_total, 2)
91 | end
92 |
93 | defp events_per_second(%State{events_received_total: 0}), do: 0
94 |
95 | defp events_per_second(state) do
96 | now = System.monotonic_time()
97 |
98 | seconds_passed =
99 | System.convert_time_unit(now - state.started_at, :native, :millisecond) / 1000
100 |
101 | Float.round(state.events_received_total / seconds_passed, 2)
102 | end
103 | end
104 |
--------------------------------------------------------------------------------
/lib/slurpee_web.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb do
2 | @moduledoc """
3 | The entrypoint for defining your web interface, such
4 | as controllers, views, channels and so on.
5 |
6 | This can be used in your application as:
7 |
8 | use SlurpeeWeb, :controller
9 | use SlurpeeWeb, :view
10 |
11 | The definitions below will be executed for every view,
12 | controller, etc, so keep them short and clean, focused
13 | on imports, uses and aliases.
14 |
15 | Do NOT define functions inside the quoted expressions
16 | below. Instead, define any helper function in modules
17 | and import those modules here.
18 | """
19 |
20 | def controller do
21 | quote do
22 | use Phoenix.Controller, namespace: SlurpeeWeb
23 |
24 | import Plug.Conn
25 | import SlurpeeWeb.Gettext
26 | alias SlurpeeWeb.Router.Helpers, as: Routes
27 | end
28 | end
29 |
30 | # def view do
31 | # quote do
32 | # use Phoenix.View,
33 | # root: "lib/slurpee_web/templates",
34 | # namespace: SlurpeeWeb
35 |
36 | # # Import convenience functions from controllers
37 | # import Phoenix.Controller,
38 | # only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]
39 |
40 | # # Include shared imports and aliases for views
41 | # unquote(view_helpers())
42 | # end
43 | # end
44 |
45 | def view(opts \\ [root: "lib/slurpee_web/templates", namespace: SlurpeeWeb]) do
46 | quote do
47 | use Phoenix.View, unquote(opts)
48 |
49 | # Import convenience functions from controllers
50 | import Phoenix.Controller,
51 | only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]
52 |
53 | # Include shared imports and aliases for views
54 | unquote(view_helpers())
55 | end
56 | end
57 |
58 | def live_view do
59 | quote do
60 | use Phoenix.LiveView,
61 | layout: {SlurpeeWeb.LayoutView, "live.html"}
62 |
63 | unquote(view_helpers())
64 | end
65 | end
66 |
67 | def live_component do
68 | quote do
69 | use Phoenix.LiveComponent
70 |
71 | unquote(view_helpers())
72 | end
73 | end
74 |
75 | def router do
76 | quote do
77 | use Phoenix.Router
78 |
79 | import Plug.Conn
80 | import Phoenix.Controller
81 | import Phoenix.LiveView.Router
82 | end
83 | end
84 |
85 | def channel do
86 | quote do
87 | use Phoenix.Channel
88 | import SlurpeeWeb.Gettext
89 | end
90 | end
91 |
92 | defp view_helpers do
93 | quote do
94 | # Use all HTML functionality (forms, tags, etc)
95 | use Phoenix.HTML
96 |
97 | # Import LiveView helpers (live_render, live_component, live_patch, etc)
98 | import Phoenix.LiveView.Helpers
99 |
100 | # Import LiveReact helpers (live_react_component, etc)
101 | import PhoenixLiveReact
102 |
103 | # Import basic rendering functionality (render, render_layout, etc)
104 | import Phoenix.View
105 |
106 | import SlurpeeWeb.ErrorHelpers
107 | import SlurpeeWeb.Gettext
108 | alias SlurpeeWeb.Router.Helpers, as: Routes
109 | end
110 | end
111 |
112 | @doc """
113 | When used, dispatch to the appropriate controller/view/etc.
114 | """
115 | defmacro __using__(which) when is_atom(which) do
116 | apply(__MODULE__, which, [])
117 | end
118 | defmacro __using__({which, opts}) when is_atom(which) do
119 | apply(__MODULE__, which, [opts])
120 | end
121 | end
122 |
--------------------------------------------------------------------------------
/assets/tailwind.config.js:
--------------------------------------------------------------------------------
1 | const defaultTheme = require('tailwindcss/defaultTheme')
2 |
3 | module.exports = {
4 | mode: 'jit',
5 | purge: [
6 | '../config/runtime.exs',
7 | '../lib/**/*.ex',
8 | '../lib/**/*.leex',
9 | '../lib/**/*.eex',
10 | '../deps/**/*.ex',
11 | '../deps/**/*.leex',
12 | '../deps/**/*.eex',
13 | './js/**/*.js',
14 | './js/**/*.jsx',
15 | './js/**/*.ts',
16 | './js/**/*.tsx'
17 | ],
18 | darkMode: false, // or 'media' or 'class'
19 | theme: {
20 | extend: {
21 | fontFamily: {
22 | // Free Proxima Nova alternative
23 | sans: ['Montserrat', ...defaultTheme.fontFamily.sans],
24 | },
25 | width: {
26 | // /24
27 | '1/24': '4.16666666667%',
28 | '2/24': '8.33333333333%',
29 | '3/24': '12.5%',
30 | '4/24': '16.6666666667%',
31 | '5/24': '20.8333333333%',
32 | '6/24': '25%',
33 | '7/24': '29.1666666667%',
34 | '8/24': '33.3333333333%',
35 | '9/24': '37.5%',
36 | '10/24': '41.6666666667%',
37 | '11/24': '45.8333333333%',
38 | '12/24': '50%',
39 | '13/24': '54.16666666675%',
40 | '14/24': '58.3333333333%',
41 | '15/24': '62.5%',
42 | '16/24': '66.6666666667%',
43 | '17/24': '70.8333333333%',
44 | '18/24': '75%',
45 | '19/24': '79.1666666667%',
46 | '20/24': '83.3333333333%',
47 | '21/24': '87.5%',
48 | '22/24': '91.6666666667%',
49 | '23/24': '95.8333333333%',
50 | // /36
51 | '1/36': '2.77777777778%',
52 | '2/36': '5.55555555556%',
53 | '3/36': '8.33333333333%',
54 | '4/36': '11.1111111111%',
55 | '5/36': '13.8888888889%',
56 | '6/36': '16.6666666667%',
57 | '7/36': '19.4444444444%',
58 | '8/36': '22.2222222222%',
59 | '9/36': '25%',
60 | '10/36': '27.7777777778%',
61 | '11/36': '30.5555555556%',
62 | '12/36': '33.3333333333%',
63 | '13/36': '36.1111111111%',
64 | '14/36': '38.8888888889%',
65 | '15/36': '41.6666666667%',
66 | '16/36': '44.4444444444%',
67 | '17/36': '47.2222222222%',
68 | '18/36': '50%',
69 | '19/36': '52.7777777778%',
70 | '20/36': '55.5555555556%',
71 | '21/36': '58.3333333333%',
72 | '22/36': '61.1111111111%',
73 | '23/36': '63.8888888889%',
74 | '24/36': '66.6666666667%',
75 | '25/36': '69.4444444444%',
76 | '26/36': '72.2222222222%',
77 | '27/36': '75%',
78 | '28/36': '77.7777777778%',
79 | '29/36': '80.5555555556%',
80 | '30/36': '83.3333333333%',
81 | '31/36': '86.1111111111%',
82 | '32/36': '88.8888888889%',
83 | '33/36': '91.6666666667%',
84 | '34/36': '94.4444444444%',
85 | '35/36': '97.2222222222%',
86 | }
87 | },
88 | },
89 | variants: {
90 | display: ['responsive', 'empty'],
91 | extend: {
92 | opacity: ['disabled'],
93 | visibility: ['group-hover'],
94 | },
95 | },
96 | plugins: [
97 | require('@tailwindcss/forms'),
98 | require('tailwindcss-empty-pseudo-class')()
99 | ],
100 | }
101 |
--------------------------------------------------------------------------------
/lib/slurpee_web/live/blockchain_live.html.leex:
--------------------------------------------------------------------------------
1 | Blockchains
2 |
3 |
4 |
7 |
8 |
9 | <%= content_tag(
10 | :button,
11 | "start all",
12 | class: "bg-green-400 hover:bg-green-500 text-white disabled:opacity-25 font-bold group-hover:visible py-2 px-4 rounded",
13 | disabled: all_running?(@blockchains),
14 | "phx-click": "start-all"
15 | ) %>
16 | <%= content_tag(
17 | :button,
18 | "stop all",
19 | class: "bg-red-600 hover:bg-red-700 text-white disabled:opacity-25 font-bold group-hover:visible py-2 px-4 rounded",
20 | disabled: none_running?(@blockchains),
21 | "phx-click": "stop-all"
22 | ) %>
23 |
24 |
25 |
26 |
27 |
28 |
29 | ID
30 | Name
31 | Status
32 | Network ID
33 | Chain ID
34 | Chain
35 | Testnet
36 | RPC
37 | Explorer
38 | Latest Block
39 | Actions
40 |
41 |
42 |
43 | <%= if Enum.any?(@blockchains) do %>
44 | <%= for b <- @blockchains do %>
45 |
46 | "><%= b.id %>
47 | "><%= b.name %>
48 | "><%= b.status %>
49 | "><%= b.network_id %>
50 | "><%= b.chain_id %>
51 | "><%= b.chain %>
52 | "><%= b.testnet %>
53 | "><%= b.rpc %>
54 | ">
55 | <%= explorer_url(b.explorer) %>
56 |
57 | ">-
58 |
59 | <%= content_tag(
60 | :button,
61 | "start",
62 | class: "text-green-500 disabled:opacity-25 font-bold invisible group-hover:visible",
63 | disabled: b.status == :running,
64 | "phx-click": "start",
65 | "phx-value-id": b.id
66 | ) %>
67 |
68 | <%= content_tag(
69 | :button,
70 | "stop",
71 | class: "text-red-500 disabled:opacity-25 font-bold invisible group-hover:visible ml-4",
72 | disabled: b.status != :running,
73 | "phx-click": "stop",
74 | "phx-value-id": b.id
75 | ) %>
76 |
77 |
78 | <% end %>
79 | <% else %>
80 |
81 |
82 | <%= if @query == nil do %>
83 | no blockchains configured
84 | <% else %>
85 | no search results
86 | <% end %>
87 |
88 |
89 | <% end %>
90 |
91 |
92 |
--------------------------------------------------------------------------------
/lib/slurpee_web/live/blockchain_live.ex:
--------------------------------------------------------------------------------
1 | defmodule SlurpeeWeb.BlockchainLive do
2 | use SlurpeeWeb, :live_view
3 | import SlurpeeWeb.ViewHelpers.SearchQueryHelper, only: [assign_search_query: 2]
4 | import SlurpeeWeb.ViewHelpers.ExplorerUrlHelper, only: [explorer_url: 1]
5 |
6 | @impl true
7 | def mount(_params, _session, socket) do
8 | Phoenix.PubSub.subscribe(Slurpee.PubSub, "new_head_received")
9 |
10 | socket =
11 | socket
12 | |> assign(:query, nil)
13 | |> assign(latest_blocks: %{})
14 |
15 | {:ok, socket}
16 | end
17 |
18 | @impl true
19 | def handle_params(params, _uri, socket) do
20 | socket =
21 | socket
22 | |> assign_search_query(params)
23 | |> assign_search()
24 |
25 | {:noreply, socket}
26 | end
27 |
28 | @impl true
29 | def handle_event("search", params, socket) do
30 | socket =
31 | socket
32 | |> assign_search_query(params)
33 | |> send_search_after(200)
34 |
35 | {:noreply, socket}
36 | end
37 |
38 | @impl true
39 | def handle_event("start", %{"id" => blockchain_id}, socket) do
40 | Slurp.Commander.start_blockchains(where: [id: blockchain_id])
41 | blockchains = Slurp.Commander.blockchains([])
42 |
43 | socket =
44 | socket
45 | |> assign(blockchains: blockchains)
46 |
47 | {:noreply, socket}
48 | end
49 |
50 | @impl true
51 | def handle_event("stop", %{"id" => blockchain_id}, socket) do
52 | Slurp.Commander.stop_blockchains(where: [id: blockchain_id])
53 | blockchains = Slurp.Commander.blockchains([])
54 |
55 | socket =
56 | socket
57 | |> assign(blockchains: blockchains)
58 |
59 | {:noreply, socket}
60 | end
61 |
62 | @impl true
63 | def handle_event("start-all", _, socket) do
64 | Slurp.Commander.start_blockchains([])
65 | blockchains = Slurp.Commander.blockchains([])
66 |
67 | socket =
68 | socket
69 | |> assign(blockchains: blockchains)
70 |
71 | {:noreply, socket}
72 | end
73 |
74 | @impl true
75 | def handle_event("stop-all", _, socket) do
76 | Slurp.Commander.stop_blockchains([])
77 | blockchains = Slurp.Commander.blockchains([])
78 |
79 | socket =
80 | socket
81 | |> assign(blockchains: blockchains)
82 |
83 | {:noreply, socket}
84 | end
85 |
86 | @impl true
87 | def handle_info(:search, socket) do
88 | socket =
89 | socket
90 | |> assign(:search_timer, nil)
91 | |> assign_search()
92 |
93 | {:noreply, socket}
94 | end
95 |
96 | @impl true
97 | def handle_info({"new_head_received", blockchain_id, block_number}, socket) do
98 | latest_blocks =
99 | socket.assigns.latest_blocks
100 | |> Map.put(blockchain_id, block_number)
101 |
102 | {:noreply, assign(socket, latest_blocks: latest_blocks)}
103 | end
104 |
105 | defp send_search_after(socket, after_ms) do
106 | if socket.assigns[:search_timer] do
107 | socket
108 | else
109 | timer = Process.send_after(self(), :search, after_ms)
110 | assign(socket, :search_timer, timer)
111 | end
112 | end
113 |
114 | defp assign_search(socket) do
115 | socket
116 | |> assign(blockchains: search_blockchains(socket.assigns.query))
117 | end
118 |
119 | defp search_blockchains(search_term) do
120 | []
121 | |> Slurp.Commander.blockchains()
122 | |> search_blockchains(search_term)
123 | end
124 |
125 | defp search_blockchains(blockchains, nil) do
126 | blockchains
127 | end
128 |
129 | defp search_blockchains(blockchains, search_term) do
130 | blockchains
131 | |> Enum.filter(fn b ->
132 | String.contains?(b.id, search_term) ||
133 | String.contains?(b.name, search_term) ||
134 | String.contains?(b.status |> Atom.to_string(), search_term) ||
135 | String.contains?(b.network_id |> to_string(), search_term) ||
136 | String.contains?(b.chain_id |> to_string(), search_term) ||
137 | String.contains?(b.chain, search_term) ||
138 | String.contains?(b.testnet |> to_string(), search_term)
139 | end)
140 | end
141 |
142 | defp running?(%Slurp.Commander.Blockchains.ListItem{status: :running}), do: true
143 | defp running?(_), do: false
144 |
145 | defp none_running?(blockchains), do: running_count(blockchains) == 0
146 |
147 | defp all_running?(blockchains), do: running_count(blockchains) == length(blockchains)
148 |
149 | defp running_count(blockchains) do
150 | blockchains
151 | |> Enum.filter(&running?/1)
152 | |> Enum.count()
153 | end
154 | end
155 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Slurpee
2 | [](https://github.com/fremantle-industries/slurpee/actions?query=workflow%3Atest)
3 | [](https://coveralls.io/github/fremantle-industries/slurpee?branch=main)
4 | [](https://hex.pm/packages/slurpee)
5 |
6 | A GUI frontend to manage blockchain ingestion with [`slurp`](https://github.com/fremantle-industries/slurp)
7 |
8 | [Built with Slurpee](./docs/BUILT_WITH_SLURPEE.md) | [Install](#install)
9 |
10 | 
11 |
12 | 
13 |
14 | 
15 |
16 | 
17 |
18 | ## Install
19 |
20 | Add `slurpee` to your list of dependencies in `mix.exs`
21 |
22 | ```elixir
23 | def deps do
24 | [
25 | {:slurpee, "~> 0.0.18"}
26 | ]
27 | end
28 | ```
29 |
30 | ## Running slurpee as a standalone endpoint
31 |
32 | Add the slurpee phoenix endpoint to your config
33 |
34 | ```elixir
35 | config :slurpee, SlurpeeWeb.Endpoint,
36 | http: [port: 4000],
37 | url: [host: "slurpee.localhost", port: "4000"],
38 | ```
39 |
40 | ## Embedding slurpee in your own Elixir project
41 |
42 | There are two options for running `slurpee` along side your existing Elixir projects
43 |
44 | 1. Plug & Phoenix provide the ability to host multiple endpoints
45 | as servers on different ports
46 |
47 | ```elixir
48 | # config/config.exs
49 | # Phoenix endpoints
50 | config :my_app, MyAppWeb.Endpoint,
51 | pubsub_server: MyApp.PubSub,
52 | http: [port: 4000],
53 | url: [host: "my-app.localhost", port: "4000"],
54 | live_view: [signing_salt: "aolmUusQ6//zaa5GZHu7DG2V3YAgOoP/"],
55 | secret_key_base: "vKt36v4Gi2Orw8b8iBRg6ZFdzXKLvcRYkk1AaMLYX0+ry7k5XaJXd/LY/itmoxPP",
56 | server: true
57 |
58 | config :slurpee, SlurpeeWeb.Endpoint,
59 | pubsub_server: Slurpee.PubSub,
60 | http: [port: 4001],
61 | url: [host: "slurpee.localhost", port: "4001"],
62 | live_view: [signing_salt: "aolmUusQ6//zaa5GZHu7DG2V3YAgOoP/"],
63 | secret_key_base: "xKt36v4Gi2Orw8b8iBRg6ZFdzXKLvcRYkk1AaMLYX0+ry7k5XaJXd/LY/itmoxPP",
64 | server: true
65 | ```
66 |
67 | 2. Use a proxy to host multiple endpoints on the same port [https://github.com/jesseshieh/master_proxy](https://github.com/jesseshieh/master_proxy)
68 |
69 | ```elixir
70 | # mix.exs
71 | def deps do
72 | [
73 | {:master_proxy, "~> 0.1"}
74 | ]
75 | end
76 | ```
77 |
78 | ```elixir
79 | # config/config.exs
80 | # Phoenix endpoints
81 | config :niex, MyAppWeb.Endpoint,
82 | pubsub_server: MyApp.PubSub,
83 | live_view: [signing_salt: "aolmUusQ6//zaa5GZHu7DG2V3YAgOoP/"],
84 | secret_key_base: "vKt36v4Gi2Orw8b8iBRg6ZFdzXKLvcRYkk1AaMLYX0+ry7k5XaJXd/LY/itmoxPP",
85 | server: false,
86 | debug_errors: true,
87 | check_origin: false
88 |
89 | config :slurpee, SlurpeeWeb.Endpoint,
90 | pubsub_server: Slurpee.PubSub,
91 | live_view: [signing_salt: "polmUusQ6//zaa5GZHu7DG2V3YAgOoP/"],
92 | secret_key_base: "xKt36v4Gi2Orw8b8iBRg6ZFdzXKLvcRYkk1AaMLYX0+ry7k5XaJXd/LY/itmoxPP",
93 | server: false,
94 | debug_errors: true,
95 | check_origin: false
96 |
97 |
98 | # Master Proxy
99 | config :master_proxy,
100 | # any Cowboy options are allowed
101 | http: [:inet6, port: 4000],
102 | # https: [:inet6, port: 4443],
103 | backends: [
104 | %{
105 | host: ~r/my-app.localhost/,
106 | phoenix_endpoint: MyAppWeb.Endpoint
107 | },
108 | %{
109 | host: ~r/slurpee.localhost/,
110 | phoenix_endpoint: SlurpeeWeb.Endpoint
111 | }
112 | ]
113 | ```
114 |
115 | ## Development
116 |
117 | You can run the app natively on the host
118 |
119 | ```bash
120 | $ mix setup
121 | $ mix phx.server
122 | ```
123 |
124 | Or within `docker-compose`
125 |
126 | ```
127 | $ docker-compose up
128 | ```
129 |
130 | Wait a few seconds for the app to boot and you should be able to view the app at `http://slurpee.localhost:4000`
131 |
132 | ## Test
133 |
134 | ```bash
135 | $ mix test
136 | ```
137 |
138 | ## Help Wanted :)
139 |
140 | If you think this `slurpee` thing might be worthwhile and you don't see a feature
141 | we would love your contributions to add them! Feel free to drop us an email or open
142 | a Github issue.
143 |
144 | ## Authors
145 |
146 | * [Alex Kwiatkowski](https://github.com/rupurt) - alex+git@fremantle.io
147 |
148 | ## License
149 |
150 | `slurpee` is released under the [MIT license](./LICENSE.md)
151 |
--------------------------------------------------------------------------------
/config/runtime.exs:
--------------------------------------------------------------------------------
1 | import Config
2 |
3 | # Shared variables
4 | env = config_env() |> Atom.to_string()
5 | http_port = (System.get_env("HTTP_PORT") || "4000") |> String.to_integer()
6 | host = System.get_env("RUBE_HOST") || "slurpee.localhost"
7 |
8 | secret_key_base =
9 | System.get_env("SECRET_KEY_BASE") ||
10 | "aklUQV064QnGvw4oQ9e+Sp5fmTlkig09P/bxk3AfCSsYHQPDVeHfL9h08XUnr9xY"
11 |
12 | live_view_signing_salt = System.get_env("LIVE_VIEW_SIGNING_SALT") || "ecn/jrqJ"
13 |
14 | # Slurpee
15 | config :slurpee, SlurpeeWeb.Endpoint,
16 | http: [port: http_port],
17 | url: [host: host, port: http_port],
18 | secret_key_base: secret_key_base,
19 | render_errors: [view: SlurpeeWeb.ErrorView, accepts: ~w(html json), layout: false],
20 | pubsub_server: Slurpee.PubSub,
21 | live_view: [signing_salt: live_view_signing_salt]
22 |
23 | config :slurpee,
24 | :prometheus_metrics_port,
25 | {:system, :integer, "SLURPEE_PROMETHEUS_METRICS_PORT", 9568}
26 |
27 | # Blockchain Connections
28 | # TODO: The aim is to not need this at all. It should be dynamically configured
29 | config :ethereumex, client_type: :http
30 |
31 | # Slurp
32 | config :slurp, blockchains: %{}
33 | config :slurp, new_head_subscriptions: %{}
34 | config :slurp, log_subscriptions: %{}
35 |
36 | # Navigation
37 | config :navigator, base_class: "text-black border-b-2 border-transparent hover:text-opacity-75"
38 | config :navigator, active_class: "border-b-2 border-black"
39 |
40 | config :navigator,
41 | links: %{
42 | slurpee: [
43 | %{
44 | label: "Slurpee",
45 | to: {SlurpeeWeb.Router.Helpers, :redirect_path, [SlurpeeWeb.Endpoint, [to: "/home", type: :permanent]]},
46 | class: "text-4xl"
47 | },
48 | %{
49 | label: "Home",
50 | to: {SlurpeeWeb.Router.Helpers, :home_path, [SlurpeeWeb.Endpoint, :index]}
51 | },
52 | %{
53 | label: "Blockchains",
54 | to: {SlurpeeWeb.Router.Helpers, :blockchain_path, [SlurpeeWeb.Endpoint, :index]}
55 | },
56 | %{
57 | label: "Log Subscriptions",
58 | to: {SlurpeeWeb.Router.Helpers, :log_subscription_path, [SlurpeeWeb.Endpoint, :index]}
59 | },
60 | %{
61 | label: "New Head Subscriptions",
62 | to:
63 | {SlurpeeWeb.Router.Helpers, :new_head_subscription_path, [SlurpeeWeb.Endpoint, :index]}
64 | },
65 | %{
66 | label: "Transaction Subscriptions",
67 | to:
68 | {SlurpeeWeb.Router.Helpers, :transaction_subscription_path,
69 | [SlurpeeWeb.Endpoint, :index]}
70 | }
71 | ]
72 | }
73 |
74 | # Notifications
75 | config :notified, pubsub_server: Slurpee.PubSub
76 | config :notified, receivers: []
77 |
78 | config :notified_phoenix,
79 | to_list: {SlurpeeWeb.Router.Helpers, :notification_path, [SlurpeeWeb.Endpoint, :index]}
80 |
81 | # Configures Elixir's Logger
82 | # config :logger, :console,
83 | # format: "$time $metadata[$level] $message\n",
84 | # metadata: [:request_id]
85 | config :logger, backends: [{LoggerFileBackend, :file_log}]
86 | config :logger, :file_log, path: "./log/#{config_env()}.log", metadata: [:blockchain_id]
87 |
88 | if System.get_env("DEBUG") == "true" do
89 | config :logger, :file_log, level: :debug
90 | else
91 | config :logger, :file_log, level: :info
92 | end
93 |
94 | # Optional Configuration
95 | if config_env() == :dev do
96 | # Set a higher stacktrace during development. Avoid configuring such
97 | # in production as building large stacktraces may be expensive.
98 | config :phoenix, :stacktrace_depth, 20
99 |
100 | # Initialize plugs at runtime for faster development compilation
101 | config :phoenix, :plug_init_mode, :runtime
102 |
103 | # For development, we disable any cache and enable
104 | # debugging and code reloading.
105 | #
106 | # The watchers configuration can be used to run external
107 | # watchers to your application. For example, we use it
108 | # with webpack to recompile .js and .css sources.
109 | config :slurpee, SlurpeeWeb.Endpoint,
110 | debug_errors: true,
111 | code_reloader: true,
112 | check_origin: false,
113 | watchers: [
114 | npm: [
115 | "run",
116 | "watch",
117 | cd: Path.expand("../assets", __DIR__)
118 | ]
119 | ]
120 |
121 | # ## SSL Support
122 | #
123 | # In order to use HTTPS in development, a self-signed
124 | # certificate can be generated by running the following
125 | # Mix task:
126 | #
127 | # mix phx.gen.cert
128 | #
129 | # Note that this task requires Erlang/OTP 20 or later.
130 | # Run `mix help phx.gen.cert` for more information.
131 | #
132 | # The `http:` config above can be replaced with:
133 | #
134 | # https: [
135 | # port: 4001,
136 | # cipher_suite: :strong,
137 | # keyfile: "priv/cert/selfsigned_key.pem",
138 | # certfile: "priv/cert/selfsigned.pem"
139 | # ],
140 | #
141 | # If desired, both `http:` and `https:` keys can be
142 | # configured to run both http and https servers on
143 | # different ports.
144 |
145 | # Watch static and templates for browser reloading.
146 | config :slurpee, SlurpeeWeb.Endpoint,
147 | live_reload: [
148 | patterns: [
149 | ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
150 | ~r"priv/gettext/.*(po)$",
151 | ~r"lib/slurpee_web/(live|views)/.*(ex)$",
152 | ~r"lib/slurpee_web/templates/.*(eex)$"
153 | ]
154 | ]
155 |
156 | # Slurp
157 | config :slurp,
158 | blockchains: %{
159 | "eth-mainnet" => %{
160 | start_on_boot: true,
161 | name: "Ethereum Mainnet",
162 | adapter: Slurp.Adapters.Evm,
163 | network_id: 1,
164 | chain_id: 1,
165 | chain: "ETH",
166 | testnet: false,
167 | timeout: 5000,
168 | new_head_initial_history: 0,
169 | poll_interval_ms: 2_500,
170 | explorer: {Slurp.ExplorerAdapters.Etherscan, "https://etherscan.io"},
171 | rpc: [
172 | "https://api.mycryptoapi.com/eth"
173 | ]
174 | },
175 | "bsc-mainnet" => %{
176 | start_on_boot: false,
177 | name: "Binance Smart Chain Mainnet",
178 | adapter: Slurp.Adapters.Evm,
179 | network_id: 56,
180 | chain_id: 56,
181 | chain: "BSC",
182 | testnet: false,
183 | new_head_initial_history: 0,
184 | poll_interval_ms: 1_000,
185 | explorer: {Slurp.ExplorerAdapters.BscScan, "https://bscscan.com"},
186 | rpc: [
187 | "https://bsc-dataseed1.binance.org"
188 | ]
189 | },
190 | "matic-mainnet" => %{
191 | start_on_boot: false,
192 | name: "Matic Mainnet",
193 | adapter: Slurp.Adapters.Evm,
194 | network_id: 137,
195 | chain_id: 137,
196 | chain: "Matic",
197 | testnet: false,
198 | timeout: 5000,
199 | new_head_initial_history: 0,
200 | poll_interval_ms: 2_500,
201 | explorer: {Slurp.ExplorerAdapters.Polygonscan, "https://polygonscan.com"},
202 | rpc: [
203 | "https://rpc-mainnet.matic.network"
204 | ]
205 | },
206 | "avalanche-mainnet" => %{
207 | start_on_boot: false,
208 | name: "Avalanche Mainnet",
209 | adapter: Slurp.Adapters.Evm,
210 | network_id: 43114,
211 | chain_id: 43114,
212 | chain: "Avax",
213 | testnet: false,
214 | timeout: 5000,
215 | new_head_initial_history: 0,
216 | poll_interval_ms: 2_500,
217 | explorer: {Slurp.ExplorerAdapters.Avascan, "https://avascan.info"},
218 | rpc: [
219 | "https://api.avax.network/ext/bc/C/rpc"
220 | ]
221 | }
222 | }
223 |
224 | config :slurp,
225 | new_head_subscriptions: %{
226 | "*" => [
227 | %{
228 | enabled: true,
229 | handler: {Slurpee.NewHeadHandler, :handle_new_head, []}
230 | }
231 | ]
232 | }
233 |
234 | config :slurp,
235 | log_subscriptions: %{
236 | "*" => %{
237 | # ERC20
238 | "Approval(address,address,uint256)" => [
239 | %{
240 | enabled: true,
241 | handler: {Slurpee.EventHandler, :handle_event, []},
242 | event_mappings: [
243 | {
244 | Examples.Erc20.Events.Approval,
245 | %{
246 | "anonymous" => false,
247 | "inputs" => [
248 | %{
249 | "indexed" => true,
250 | "name" => "owner",
251 | "type" => "address"
252 | },
253 | %{
254 | "indexed" => true,
255 | "name" => "spender",
256 | "type" => "address"
257 | },
258 | %{
259 | "indexed" => false,
260 | "name" => "value",
261 | "type" => "uint256"
262 | }
263 | ],
264 | "name" => "Approval",
265 | "type" => "event"
266 | }
267 | }
268 | ]
269 | }
270 | ]
271 | }
272 | }
273 | end
274 |
275 | if config_env() == :test do
276 | # We don't run a server during test. If one is required,
277 | # you can enable the server option below.
278 | config :slurpee, SlurpeeWeb.Endpoint,
279 | http: [port: 4002],
280 | server: false
281 |
282 | # Print only warnings and errors during test
283 | config :logger, level: :warn
284 | end
285 |
--------------------------------------------------------------------------------
/mix.lock:
--------------------------------------------------------------------------------
1 | %{
2 | "bamboo": {:hex, :bamboo, "2.2.0", "f10a406d2b7f5123eb1f02edfa043c259db04b47ab956041f279eaac776ef5ce", [:mix], [{:hackney, ">= 1.15.2", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.4", [hex: :mime, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "8c3b14ba7d2f40cb4be04128ed1e2aff06d91d9413d38bafb4afccffa3ade4fc"},
3 | "bamboo_smtp": {:hex, :bamboo_smtp, "4.1.0", "ba547be4146ae592f63af05c6c7b7b5195b2b6ca57eeea9d80070b38eacd528b", [:mix], [{:bamboo, "~> 2.2.0", [hex: :bamboo, repo: "hexpm", optional: false]}, {:gen_smtp, "~> 1.1.1", [hex: :gen_smtp, repo: "hexpm", optional: false]}], "hexpm", "cb1a2856ab0507d10df609428314aa5e18231e8b1801a5bc6e42f319eeb50ad9"},
4 | "castore": {:hex, :castore, "0.1.18", "deb5b9ab02400561b6f5708f3e7660fc35ca2d51bfc6a940d2f513f89c2975fc", [:mix], [], "hexpm", "61bbaf6452b782ef80b33cdb45701afbcf0a918a45ebe7e73f1130d661e66a06"},
5 | "certifi": {:hex, :certifi, "2.9.0", "6f2a475689dd47f19fb74334859d460a2dc4e3252a3324bd2111b8f0429e7e21", [:rebar3], [], "hexpm", "266da46bdb06d6c6d35fde799bcb28d36d985d424ad7c08b5bb48f5b5cdd4641"},
6 | "confex": {:hex, :confex, "3.5.0", "163857c73dd8f88a3815663f4bc00bee1b9c65daf40aa6e0d6ef272757fd22c7", [:mix], [], "hexpm", "34a9e31230c7fbb3dbe60db00341d0c84ee44ba3caf84b498f501c0bc8563570"},
7 | "connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"},
8 | "cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"},
9 | "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
10 | "cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"},
11 | "db_connection": {:hex, :db_connection, "2.4.1", "6411f6e23f1a8b68a82fa3a36366d4881f21f47fc79a9efb8c615e62050219da", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ea36d226ec5999781a9a8ad64e5d8c4454ecedc7a4d643e4832bf08efca01f00"},
12 | "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
13 | "deque": {:hex, :deque, "1.2.0", "30404b86264be3eeb4e8331d88ef67d0fdc77e006b2fa7872be03923a47245b7", [:mix], [], "hexpm", "cbc965c2c04654fee7ed875bf5efb5c925e1c98b0351bf1cca10670a024fbd5a"},
14 | "dialyxir": {:hex, :dialyxir, "1.2.0", "58344b3e87c2e7095304c81a9ae65cb68b613e28340690dfe1a5597fd08dec37", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "61072136427a851674cab81762be4dbeae7679f85b1272b6d25c3a839aff8463"},
15 | "earmark_parser": {:hex, :earmark_parser, "1.4.20", "89970db71b11b6b89759ce16807e857df154f8df3e807b2920a8c39834a9e5cf", [:mix], [], "hexpm", "1eb0d2dabeeeff200e0d17dc3048a6045aab271f73ebb82e416464832eb57bdd"},
16 | "ecto": {:hex, :ecto, "3.7.1", "a20598862351b29f80f285b21ec5297da1181c0442687f9b8329f0445d228892", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d36e5b39fc479e654cffd4dbe1865d9716e4a9b6311faff799b6f90ab81b8638"},
17 | "ecto_sql": {:hex, :ecto_sql, "3.7.1", "8de624ef50b2a8540252d8c60506379fbbc2707be1606853df371cf53df5d053", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2b42a32e2ce92f64aba5c88617891ab3b0ba34f3f3a503fa20009eae1a401c81"},
18 | "enumerati": {:hex, :enumerati, "0.0.8", "382d1c1a2c90888c17de1566876bbbf0266c64d7d469bc23421a559fd5eacdc8", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "7d13fa0837446a1cf3db310aaaf351dfcf3533f09073e7ce91b923569a18457c"},
19 | "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
20 | "ethereumex": {:hex, :ethereumex, "0.7.1", "9a376d072be0f318d2685fadf87877cf58884e382e00ccaee7834f3327ade0a8", [:mix], [{:httpoison, "~> 1.7", [hex: :httpoison, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "58ba04d235cfb6e8ced3fd79443ea1bde78f24cb6719538572fab89fdc8427b8"},
21 | "etso": {:hex, :etso, "0.1.6", "174b6d66c4a509e1a205564a8a4103e3a342dc05d8669a320275a1a154b14b8b", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}], "hexpm", "664431097b2e2abf6c8827e806f7bce03eaff73c7811b96d270711836a4132f3"},
22 | "ex_abi": {:hex, :ex_abi, "0.5.11", "a53307cf796231bf068a9941d57fbcb8654e72042c2a113a49f08dfb248875fb", [:mix], [{:ex_keccak, "~> 0.4.0", [hex: :ex_keccak, repo: "hexpm", optional: false]}, {:jason, "~> 1.3", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e128577740bdc0f05ed6841cbb1c88bb80377613970ed870fa052b780870655a"},
23 | "ex_doc": {:hex, :ex_doc, "0.28.2", "e031c7d1a9fc40959da7bf89e2dc269ddc5de631f9bd0e326cbddf7d8085a9da", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "51ee866993ffbd0e41c084a7677c570d0fc50cb85c6b5e76f8d936d9587fa719"},
24 | "ex_keccak": {:hex, :ex_keccak, "0.4.0", "4eb8620c8a20a546e2d297b5ce3de150a90db0fdc4ba1dd88c854ace9ee47603", [:mix], [{:rustler, "~> 0.24", [hex: :rustler, repo: "hexpm", optional: false]}], "hexpm", "209ec5591d3cf79f9bdcdedf39c3d7a1fb208321e2b6de2660801117ae386f10"},
25 | "ex_unit_notifier": {:hex, :ex_unit_notifier, "1.2.0", "73ced2ecee0f2da0705e372c21ce61e4e5d927ddb797f73928e52818b9cc1754", [:mix], [], "hexpm", "f38044c9d50de68ad7f0aec4d781a10d9f1c92c62b36bf0227ec0aaa96aee332"},
26 | "excoveralls": {:hex, :excoveralls, "0.14.6", "610e921e25b180a8538229ef547957f7e04bd3d3e9a55c7c5b7d24354abbba70", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "0eceddaa9785cfcefbf3cd37812705f9d8ad34a758e513bb975b081dce4eb11e"},
27 | "exw3": {:hex, :exw3, "0.6.1", "67b5ed4fae2a8dd13f23f74000399ae5a8fdc6206b320101610a805c4f9cf753", [:mix], [{:ethereumex, "~> 0.7.0", [hex: :ethereumex, repo: "hexpm", optional: false]}, {:ex_abi, "~> 0.5.4", [hex: :ex_abi, repo: "hexpm", optional: false]}, {:ex_keccak, "~> 0.2", [hex: :ex_keccak, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "24535d96c6ab6c75c34eee9c4b1a2ce7372a42ce37481b2ddde51cb0c7433745"},
28 | "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
29 | "floki": {:hex, :floki, "0.33.1", "f20f1eb471e726342b45ccb68edb9486729e7df94da403936ea94a794f072781", [:mix], [{:html_entities, "~> 0.5.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm", "461035fd125f13fdf30f243c85a0b1e50afbec876cbf1ceefe6fddd2e6d712c6"},
30 | "gen_smtp": {:hex, :gen_smtp, "1.1.1", "bf9303c31735100631b1d708d629e4c65944319d1143b5c9952054f4a1311d85", [:rebar3], [{:hut, "1.3.0", [hex: :hut, repo: "hexpm", optional: false]}, {:ranch, ">= 1.7.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "51bc50cc017efd4a4248cbc39ea30fb60efa7d4a49688986fafad84434ff9ab7"},
31 | "gettext": {:hex, :gettext, "0.20.0", "75ad71de05f2ef56991dbae224d35c68b098dd0e26918def5bb45591d5c8d429", [:mix], [], "hexpm", "1c03b177435e93a47441d7f681a7040bd2a816ece9e2666d1c9001035121eb3d"},
32 | "hackney": {:hex, :hackney, "1.18.1", "f48bf88f521f2a229fc7bae88cf4f85adc9cd9bcf23b5dc8eb6a1788c662c4f6", [:rebar3], [{:certifi, "~>2.9.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a4ecdaff44297e9b5894ae499e9a070ea1888c84afdd1fd9b7b2bc384950128e"},
33 | "html_entities": {:hex, :html_entities, "0.5.2", "9e47e70598da7de2a9ff6af8758399251db6dbb7eebe2b013f2bbd2515895c3c", [:mix], [], "hexpm", "c53ba390403485615623b9531e97696f076ed415e8d8058b1dbaa28181f4fdcc"},
34 | "httpoison": {:hex, :httpoison, "1.8.0", "6b85dea15820b7804ef607ff78406ab449dd78bed923a49c7160e1886e987a3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "28089eaa98cf90c66265b6b5ad87c59a3729bea2e74e9d08f9b51eb9729b3c3a"},
35 | "hut": {:hex, :hut, "1.3.0", "71f2f054e657c03f959cf1acc43f436ea87580696528ca2a55c8afb1b06c85e7", [:"erlang.mk", :rebar, :rebar3], [], "hexpm", "7e15d28555d8a1f2b5a3a931ec120af0753e4853a4c66053db354f35bf9ab563"},
36 | "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
37 | "jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"},
38 | "juice": {:hex, :juice, "0.0.3", "a7cb03a05ecd860eef19864e6a3c1776f0e6611eec589ee812911868a4ea6874", [:mix], [], "hexpm", "c4a8a7bb169031a56ed66e003f1c7454e7748cf446ef249ba57df4971fbd3574"},
39 | "logger_file_backend": {:hex, :logger_file_backend, "0.0.13", "df07b14970e9ac1f57362985d76e6f24e3e1ab05c248055b7d223976881977c2", [:mix], [], "hexpm", "71a453a7e6e899ae4549fb147b1c6621f4233f8f48f58ca10a64ec67b6c50018"},
40 | "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
41 | "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"},
42 | "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
43 | "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
44 | "mime": {:hex, :mime, "1.6.0", "dabde576a497cef4bbdd60aceee8160e02a6c89250d6c0b29e56c0dfb00db3d2", [:mix], [], "hexpm", "31a1a8613f8321143dde1dafc36006a17d28d02bdfecb9e95a880fa7aabd19a7"},
45 | "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
46 | "mix_test_watch": {:hex, :mix_test_watch, "1.1.0", "330bb91c8ed271fe408c42d07e0773340a7938d8a0d281d57a14243eae9dc8c3", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "52b6b1c476cbb70fd899ca5394506482f12e5f6b0d6acff9df95c7f1e0812ec3"},
47 | "navigator": {:hex, :navigator, "0.0.8", "fb91cb753bf2a86ad484595b9dcdb97007cda42f94d48ca8d5de7c2dbfec0408", [:mix], [{:ordered_nary_tree, "~> 0.0.4", [hex: :ordered_nary_tree, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.17", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:stored, "~> 0.0.8", [hex: :stored, repo: "hexpm", optional: false]}], "hexpm", "1b88a9c0a2d888490c8be89e6742afef76b0355af6b2fa90f8a3cbffb786792d"},
48 | "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
49 | "notified": {:hex, :notified, "0.0.6", "b02a0fb24345595b8bc5cd42aabd111dfb6a825835ca9b90f726305a932e31a8", [:mix], [{:bamboo, "~> 2.1", [hex: :bamboo, repo: "hexpm", optional: false]}, {:bamboo_smtp, "~> 4.0", [hex: :bamboo_smtp, repo: "hexpm", optional: false]}, {:confex, "~> 3.5", [hex: :confex, repo: "hexpm", optional: false]}, {:ecto, "~> 3.6", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.6", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:etso, "~> 0.1.6", [hex: :etso, repo: "hexpm", optional: false]}, {:paged_query, "~> 0.0.2", [hex: :paged_query, repo: "hexpm", optional: false]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}], "hexpm", "7af87660cb0d95d950e22c51dbcc61715e3140938869f686d467689e19e17ddd"},
50 | "notified_phoenix": {:hex, :notified_phoenix, "0.0.7", "6259a28e1530140f394e51bd375eb4267ffe3e3e66fd5cda5d27567db96e1225", [:mix], [{:notified, "~> 0.0.6", [hex: :notified, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.17", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "8c67ff0e7f0b73970593039f851c3b85d0255fa886962377b7b9ff18e5a104fa"},
51 | "ordered_nary_tree": {:hex, :ordered_nary_tree, "0.0.4", "c896faba787967507ea3e2a7b5f1405b529369617a10d324e2df9f05afa31bb3", [:mix], [], "hexpm", "6199dce4748b319f1ea623d8d905b13309b7e6f7c0b571acfbdb936c29ac7c57"},
52 | "paged_query": {:hex, :paged_query, "0.0.2", "657c9f48a28caf4e8b214a59271ef3da2db7c62f3242fa43b359a1249d6d7c8d", [:mix], [{:ecto, "~> 3.6", [hex: :ecto, repo: "hexpm", optional: false]}], "hexpm", "b6c5fbee31b5bea881814c7e35c89c85b6cdbbb80ae0b665cccedfb2d58b1bec"},
53 | "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
54 | "phoenix": {:hex, :phoenix, "1.6.13", "5b3152907afdb8d3a6cdafb4b149e8aa7aabbf1422fd9f7ef4c2a67ead57d24a", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "13d8806c31176e2066da4df2d7443c144211305c506ed110ad4044335b90171d"},
55 | "phoenix_html": {:hex, :phoenix_html, "3.2.0", "1c1219d4b6cb22ac72f12f73dc5fad6c7563104d083f711c3fcd8551a1f4ae11", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "36ec97ba56d25c0136ef1992c37957e4246b649d620958a1f9fa86165f8bc54f"},
56 | "phoenix_live_react": {:hex, :phoenix_live_react, "0.4.1", "dfe40f02fe545e2faa2b2523ed9e825a35bff58425dd764dcc3356eaaaa646b4", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.11 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm", "acb3ca86387e70ead27e631457185ddc31d828cbd0cbbd6ed51d9072398c2727"},
57 | "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.3.3", "3a53772a6118d5679bf50fc1670505a290e32a1d195df9e069d8c53ab040c054", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "766796676e5f558dbae5d1bdb066849673e956005e3730dfd5affd7a6da4abac"},
58 | "phoenix_live_view": {:hex, :phoenix_live_view, "0.17.12", "74f4c0ad02d7deac2d04f50b52827a5efdc5c6e7fac5cede145f5f0e4183aedc", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6.0 or ~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.1", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "af6dd5e0aac16ff43571f527a8e0616d62cb80b10eb87aac82170243e50d99c8"},
59 | "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.1", "ba04e489ef03763bf28a17eb2eaddc2c20c6d217e2150a61e3298b0f4c2012b5", [:mix], [], "hexpm", "81367c6d1eea5878ad726be80808eb5a787a23dee699f96e72b1109c57cdd8d9"},
60 | "phoenix_view": {:hex, :phoenix_view, "1.1.2", "1b82764a065fb41051637872c7bd07ed2fdb6f5c3bd89684d4dca6e10115c95a", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "7ae90ad27b09091266f6adbb61e1d2516a7c3d7062c6789d46a7554ec40f3a56"},
61 | "plug": {:hex, :plug, "1.13.6", "187beb6b67c6cec50503e940f0434ea4692b19384d47e5fdfd701e93cadb4cc2", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "02b9c6b9955bce92c829f31d6284bf53c591ca63c4fb9ff81dfd0418667a34ff"},
62 | "plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"},
63 | "plug_crypto": {:hex, :plug_crypto, "1.2.3", "8f77d13aeb32bfd9e654cb68f0af517b371fb34c56c9f2b58fe3df1235c1251a", [:mix], [], "hexpm", "b5672099c6ad5c202c45f5a403f21a3411247f164e4a8fab056e5cd8a290f4a2"},
64 | "poolboy": {:hex, :poolboy, "1.5.2", "392b007a1693a64540cead79830443abf5762f5d30cf50bc95cb2c1aaafa006b", [:rebar3], [], "hexpm", "dad79704ce5440f3d5a3681c8590b9dc25d1a561e8f5a9c995281012860901e3"},
65 | "proper_case": {:hex, :proper_case, "1.3.1", "5f51cabd2d422a45f374c6061b7379191d585b5154456b371432d0fa7cb1ffda", [:mix], [], "hexpm", "6cc715550cc1895e61608060bbe67aef0d7c9cf55d7ddb013c6d7073036811dd"},
66 | "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
67 | "redirect": {:hex, :redirect, "0.3.0", "f24f2cd41ea85d68c99290ef41655dfae06905e1aa96ee9b025b6b58e82a0776", [:mix], [{:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:plug, "~> 1.8.3 or ~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "3108e611ded985a88efc37c4f17e543d39606f17271c4c549c38edfde0c0d66e"},
68 | "rustler": {:hex, :rustler, "0.24.0", "b8362a2fee1c9d2c7373b0bfdc98f75bbc02864efcec50df173fe6c4f72d4cc4", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:toml, "~> 0.6", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "2773167fca68a6525822ad977b41368ea3c2af876c42ebaa7c9d6bb69b67f1ce"},
69 | "slurp": {:hex, :slurp, "0.0.12", "571f9bbdb864ce76bb3d258ee9e739fdda4679c7e365dc99bfc5976e5289b5a8", [:mix], [{:enumerati, "~> 0.0.8", [hex: :enumerati, repo: "hexpm", optional: false]}, {:ex_abi, "~> 0.5.5", [hex: :ex_abi, repo: "hexpm", optional: false]}, {:ex_doc, "~> 0.22", [hex: :ex_doc, repo: "hexpm", optional: false]}, {:exw3, "~> 0.6.1", [hex: :exw3, repo: "hexpm", optional: false]}, {:juice, "~> 0.0.3", [hex: :juice, repo: "hexpm", optional: false]}, {:proper_case, "~> 1.0", [hex: :proper_case, repo: "hexpm", optional: false]}, {:stored, "~> 0.0.7", [hex: :stored, repo: "hexpm", optional: false]}, {:table_rex, "~> 3.0", [hex: :table_rex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.4", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}, {:telemetry_metrics_prometheus, "~> 1.0", [hex: :telemetry_metrics_prometheus, repo: "hexpm", optional: false]}, {:telemetry_poller, "~> 0.4 or ~> 1.0", [hex: :telemetry_poller, repo: "hexpm", optional: false]}], "hexpm", "0ae5bbbb05712f3a31716a6391ed416b0214c2243e822469cdbfe84aef3ff41a"},
70 | "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
71 | "stored": {:hex, :stored, "0.0.8", "48f4fbd874a43586f542fb3b3ba0766befca6b24c04ab2464208b52e0ab6d623", [:mix], [], "hexpm", "8f62b6fe2c3413ed630921b19bdcb7d8db5db2b4596dd0842ca0078b37871fbe"},
72 | "stylish": {:hex, :stylish, "0.0.9", "caf5d4659995d5fe09d54ef87fd814212907810dd0a6ed2b93ab1130dbbf270c", [:mix], [{:phoenix_html, "~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.17.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "d99571994c2009335eefa1a1b7a7d9455453589dfc271a6e30c00202c17cf2a2"},
73 | "table_rex": {:hex, :table_rex, "3.1.1", "0c67164d1714b5e806d5067c1e96ff098ba7ae79413cc075973e17c38a587caa", [:mix], [], "hexpm", "678a23aba4d670419c23c17790f9dcd635a4a89022040df7d5d772cb21012490"},
74 | "telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"},
75 | "telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"},
76 | "telemetry_metrics_prometheus": {:hex, :telemetry_metrics_prometheus, "1.1.0", "1cc23e932c1ef9aa3b91db257ead31ea58d53229d407e059b29bb962c1505a13", [:mix], [{:plug_cowboy, "~> 2.1", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:telemetry_metrics_prometheus_core, "~> 1.0", [hex: :telemetry_metrics_prometheus_core, repo: "hexpm", optional: false]}], "hexpm", "d43b3659b3244da44fe0275b717701542365d4519b79d9ce895b9719c1ce4d26"},
77 | "telemetry_metrics_prometheus_core": {:hex, :telemetry_metrics_prometheus_core, "1.0.2", "c98b1c580de637bfeac00db41b9fb91fb4c3548ee3d512a8ed7299172312eaf3", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "48351a0d56f80e38c997b44232b1043e0a081670d16766eee920e6254175b730"},
78 | "telemetry_poller": {:hex, :telemetry_poller, "1.0.0", "db91bb424e07f2bb6e73926fcafbfcbcb295f0193e0a00e825e589a0a47e8453", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3a24eafd66c3f42da30fc3ca7dda1e9d546c12250a2d60d7b81d264fbec4f6e"},
79 | "toml": {:hex, :toml, "0.6.2", "38f445df384a17e5d382befe30e3489112a48d3ba4c459e543f748c2f25dd4d1", [:mix], [], "hexpm", "d013e45126d74c0c26a38d31f5e8e9b83ea19fc752470feb9a86071ca5a672fa"},
80 | "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
81 | }
82 |
--------------------------------------------------------------------------------