Skip to content

Commit

Permalink
fix(fee): compute fee even when no internal_operation_results
Browse files Browse the repository at this point in the history
  • Loading branch information
vhf committed May 27, 2024
1 parent 13747a8 commit 0301bc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/rpc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,9 @@ defmodule Tezex.Rpc do
Enum.map(preapplied_operations, fn content ->
if validation_passes(content["kind"]) == 3 do
internal_consumed_milligas =
Enum.reduce(content["metadata"]["internal_operation_results"], 0, fn obj, sum ->
sum +
case get_in(obj, ["result", "consumed_milligas"]) do
nil -> 0
n -> String.to_integer(n)
end
(get_in(content, ["metadata", "internal_operation_results"]) || [])
|> Enum.reduce(0, fn obj, sum ->
sum + String.to_integer(get_in(obj, ["result", "consumed_milligas"]) || "0")
end)

consumed_milligas =
Expand Down
2 changes: 2 additions & 0 deletions test/rpc_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defmodule Tezex.RpcTest do
@ghostnet_1_pkey "edsk33h91RysSBUiYyEWbeRwo41YeZrtMPTNsuZ9nzsYWwiV8CFyKi"
@ghostnet_2_address "tz1cMcDFLgFe2picQbo4DY1i6mZJiVhPCu5B"

@tag :tezos
test "get_counter_for_account" do
counter =
Rpc.get_counter_for_account(
Expand Down Expand Up @@ -467,6 +468,7 @@ defmodule Tezex.RpcTest do
end
end

@tag :tezos
test "raise" do
rpc = %Rpc{endpoint: @endpoint}

Expand Down

0 comments on commit 0301bc6

Please sign in to comment.