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

Commit

Permalink
Support Juno 0.9.2 responses (#400)
Browse files Browse the repository at this point in the history
* Change type TransactionReceipt.actual_fee to a map

* Changes in hex number resprentations

* Invoke transactions, skip required fields check
  • Loading branch information
pefontana authored Jan 12, 2024
1 parent 8f78403 commit 698bf20
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion lib/starknet_explorer/block/block_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ defmodule StarknetExplorer.BlockUtils do
|> Enum.map(fn
%{"execution_resources" => %{"steps" => steps}} ->
steps
|> StarknetExplorerWeb.Utils.hex_to_integer()

_ ->
nil
Expand Down
3 changes: 2 additions & 1 deletion lib/starknet_explorer/transaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ defmodule StarknetExplorer.Transaction do

defp validate_according_to_tx_type(changeset, _tx = %{"type" => "INVOKE"}) do
changeset
|> validate_required(@invoke_v0_tx_fields)
# Skip required fields check because of Juno0.9.2 breaking changes
# |> validate_required(@invoke_v0_tx_fields)
end

defp validate_according_to_tx_type(changeset, _tx = %{"type" => "DEPLOY", "max_fee" => _}) do
Expand Down
2 changes: 1 addition & 1 deletion lib/starknet_explorer/transaction_receipt.ex
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ defmodule StarknetExplorer.TransactionReceipt do
schema "transaction_receipts" do
belongs_to :transaction, Transaction, references: :hash
field :type, :string
field :actual_fee, :string
field :actual_fee, :map
field :finality_status, :string
field :execution_status, :string
field :block_hash, :string
Expand Down
8 changes: 4 additions & 4 deletions lib/starknet_explorer_web/live/transaction_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ defmodule StarknetExplorerWeb.TransactionLive do
<div class="block-label">Actual Fee</div>
<div class="col-span-3">
<span class="info-label cash-label">
<%= Utils.hex_wei_to_eth(@transaction_receipt.actual_fee) %> ETH
<%= Utils.hex_wei_to_eth(@transaction_receipt.actual_fee["amount"]) %> ETH
</span>
</div>
</div>
Expand Down Expand Up @@ -539,10 +539,10 @@ defmodule StarknetExplorerWeb.TransactionLive do
</div>
<div class="flex flex-col lg:flex-row items-center gap-5 px-5 md:p-0">
<div class="flex flex-col justify-center items-center gap-2">
<span class="blue-label py-1 px-2 rounded-lg">STEPS</span> <%= "#{Utils.hex_to_integer(@transaction_receipt.execution_resources["steps"])}" %>
<span class="blue-label py-1 px-2 rounded-lg">STEPS</span> <%= "#{@transaction_receipt.execution_resources["steps"]}" %>
</div>
<div class="flex flex-col justify-center items-center gap-2">
<span class="green-label py-1 px-2 rounded-lg">MEMORY HOLES</span> <%= "#{Utils.hex_to_integer(@transaction_receipt.execution_resources["memory_holes"])}" %>
<span class="green-label py-1 px-2 rounded-lg">MEMORY HOLES</span> <%= "#{@transaction_receipt.execution_resources["memory_holes"]}" %>
</div>
<%= for {builtin_name, resources} <- @transaction_receipt.execution_resources do %>
<%= if String.ends_with?(builtin_name, "_applications") and resources != "0x0" do %>
Expand All @@ -551,7 +551,7 @@ defmodule StarknetExplorerWeb.TransactionLive do
<span class={"#{Utils.builtin_color(temp_name)} py-1 px-2 rounded-lg"}>
<%= Utils.builtin_name(temp_name) %>
</span>
<%= Utils.hex_to_integer(resources) %>
<%= resources %>
</div>
<% end %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule StarknetExplorer.Repo.Migrations.TransactionReceipts do

add :transaction_hash, :string, primary_key: true
add :type, :string
add :actual_fee, :string
add :actual_fee, :map
add :finality_status, :string
add :execution_status, :string
add :block_hash, :string
Expand Down

0 comments on commit 698bf20

Please sign in to comment.