diff --git a/.gitignore b/.gitignore index d55ec4c6..5a00990f 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ npm-debug.log # Ignore .envrc .envrc - # Ignore postgres files -.volumes +.volumes +# Ignore juno files +juno_files diff --git a/Makefile b/Makefile index 2c052751..96cf34c5 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ run: setup: deps-get db db: - docker-compose up -d + docker-compose up -d postgres pgadmin mix ecto.create mix ecto.migrate @@ -23,3 +23,7 @@ seed: db cat ./priv/repo/seed.sql | docker exec -i $(db_container) psql -U postgres -d starknet_explorer_dev create-seed: db docker exec -i $(db_container) pg_dump --column-inserts --data-only -d starknet_explorer_dev -U postgres > ./priv/repo/seed.sql + +juno: + mkdir -p ./juno_files + docker-compose up juno diff --git a/README.md b/README.md index 551ec6f6..031cf647 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ ## Local development +### RPC Provider To run it locally, you'll need to set the RPC API url of the network. If you're using a provider like Infura, this will look something like this: ``` @@ -21,8 +22,17 @@ Set the following environment variable with the url mentioned above export RPC_API_HOST=your_rpc_hostname ``` -then do +### RPC with Juno +You can also use the docker provided juno with +``` +make juno +``` +You'll need a Mainnet Ethereum RPC provider for this to +work, set with the env variable `$ETH_NODE_URL`, mind you +it must be a websocket url. +### Up and running +With a working RPC set, start the explorer with ``` make setup run ``` diff --git a/docker-compose.yml b/docker-compose.yml index 4a85102f..34851e00 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,4 @@ version: '3.8' - services: postgres: container_name: starknet_explorer_dev_db @@ -32,6 +31,20 @@ services: default: aliases: - pgadmin + juno: + container_name: 'juno_mainnet' + image: nethermind/juno + ports: + - 6060:6060 + volumes: + - ./juno_files/:/var/lib/juno + command: > + --pending-poll-interval "60s" + --http-port 6060 + --db-path /var/lib/juno + --eth-node "${ETH_NODE_URL}" + --network mainnet + networks: default: driver: bridge diff --git a/lib/starknet_explorer_web/live/transaction_live.ex b/lib/starknet_explorer_web/live/transaction_live.ex index c962901d..2d62c88a 100644 --- a/lib/starknet_explorer_web/live/transaction_live.ex +++ b/lib/starknet_explorer_web/live/transaction_live.ex @@ -529,17 +529,19 @@ defmodule StarknetExplorerWeb.TransactionLive do
Index
Value
- <%= for {index, signature} <- Enum.with_index(@transaction["signature"]) do %> -
-
-
Index
-
<%= signature %>
-
-
-
Value
-
<%= index |> Utils.shorten_block_hash() %>
+ <%= unless is_nil(@transaction["signature"]) do %> + <%= for {index, signature} <- Enum.with_index(@transaction["signature"]) do %> +
+
+
Index
+
<%= signature %>
+
+
+
Value
+
<%= index |> Utils.shorten_block_hash() %>
+
-
+ <% end %> <% end %>
diff --git a/lib/starknet_explorer_web/live/utils.ex b/lib/starknet_explorer_web/live/utils.ex index 487a61bc..4f8c17a6 100644 --- a/lib/starknet_explorer_web/live/utils.ex +++ b/lib/starknet_explorer_web/live/utils.ex @@ -2,6 +2,8 @@ defmodule StarknetExplorerWeb.Utils do alias StarknetExplorer.Rpc alias StarknetExplorer.DateUtils + def shorten_block_hash(nil), do: "" + def shorten_block_hash(block_hash) do "#{String.slice(block_hash, 0, 6)}...#{String.slice(block_hash, -4, 4)}" end