From 906a81138c838b912bd7dd811e2c1f61454bd85f Mon Sep 17 00:00:00 2001 From: Rodrigo Oliveri Date: Wed, 17 Jul 2024 16:07:36 -0300 Subject: [PATCH] Added Version to the NodeController for the node version rpc call --- lib/beacon_api/controllers/v1/node_controller.ex | 16 ++++++++++++++++ lib/beacon_api/router.ex | 1 + 2 files changed, 17 insertions(+) diff --git a/lib/beacon_api/controllers/v1/node_controller.ex b/lib/beacon_api/controllers/v1/node_controller.ex index 2fce6acbf..02cf59ff5 100644 --- a/lib/beacon_api/controllers/v1/node_controller.ex +++ b/lib/beacon_api/controllers/v1/node_controller.ex @@ -16,6 +16,9 @@ defmodule BeaconApi.V1.NodeController do def open_api_operation(:identity), do: ApiSpec.spec().paths["/eth/v1/node/identity"].get + def open_api_operation(:version), + do: ApiSpec.spec().paths["/eth/v1/node/version"].get + @spec health(Plug.Conn.t(), any) :: Plug.Conn.t() def health(conn, params) do # TODO: respond with syncing status if we're still syncing @@ -46,4 +49,17 @@ defmodule BeaconApi.V1.NodeController do } }) end + + @spec version(Plug.Conn.t(), any) :: Plug.Conn.t() + def version(conn, _params) do + version = Application.spec(:lambda_ethereum_consensus)[:vsn] + arch = :erlang.system_info(:system_architecture) + + conn + |> json(%{ + "data" => %{ + "version" => "Lambda/#{version}/#{arch}", + } + }) + end end diff --git a/lib/beacon_api/router.ex b/lib/beacon_api/router.ex index d0fec48c3..df36dda97 100644 --- a/lib/beacon_api/router.ex +++ b/lib/beacon_api/router.ex @@ -20,6 +20,7 @@ defmodule BeaconApi.Router do scope "/node" do get("/health", NodeController, :health) get("/identity", NodeController, :identity) + get("/version", NodeController, :version) end end