Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Add juno to docker compose (#72)
Browse files Browse the repository at this point in the history
* Add juno target to make and docker compose files

* Update makefile and docker compose file

* Update readme for Local development

* Simple fix for nil hash

* Update gitignore

* Newline

* Update git-ignore

* Remove newline

* Newline

* Update docker compose target

* Update README

* Update makefile

* Update readme + dockerfile

* Add nil check for transaction signatures

* Remove inspect
  • Loading branch information
fkrause98 authored Jul 31, 2023
1 parent acaddd7 commit 95ec188
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 15 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ npm-debug.log

# Ignore .envrc
.envrc

# Ignore postgres files
.volumes
.volumes
# Ignore juno files
juno_files
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```
Expand All @@ -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
```
Expand Down
15 changes: 14 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
version: '3.8'

services:
postgres:
container_name: starknet_explorer_dev_db
Expand Down Expand Up @@ -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
Expand Down
22 changes: 12 additions & 10 deletions lib/starknet_explorer_web/live/transaction_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -529,17 +529,19 @@ defmodule StarknetExplorerWeb.TransactionLive do
<div>Index</div>
<div class="col-span-7">Value</div>
</div>
<%= for {index, signature} <- Enum.with_index(@transaction["signature"]) do %>
<div class="w-full grid-8 custom-list-item">
<div>
<div class="list-h">Index</div>
<div class="break-all"><%= signature %></div>
</div>
<div>
<div class="list-h">Value</div>
<div class="break-all col-span-7"><%= index |> Utils.shorten_block_hash() %></div>
<%= unless is_nil(@transaction["signature"]) do %>
<%= for {index, signature} <- Enum.with_index(@transaction["signature"]) do %>
<div class="w-full grid-8 custom-list-item">
<div>
<div class="list-h">Index</div>
<div class="break-all"><%= signature %></div>
</div>
<div>
<div class="list-h">Value</div>
<div class="break-all col-span-7"><%= index |> Utils.shorten_block_hash() %></div>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions lib/starknet_explorer_web/live/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 95ec188

Please sign in to comment.