Skip to content

Commit

Permalink
fix(fee): take internal operations into account
Browse files Browse the repository at this point in the history
  • Loading branch information
vhf committed May 27, 2024
1 parent fb9eb1d commit a005f23
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/rpc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,21 @@ defmodule Tezex.Rpc do
contents =
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
end)

consumed_milligas =
case content["metadata"]["operation_result"]["consumed_milligas"] do
nil -> 0
v -> String.to_integer(v)
end
internal_consumed_milligas +
case content["metadata"]["operation_result"]["consumed_milligas"] do
nil -> 0
v -> String.to_integer(v)
end

gas_limit_new = ceil(consumed_milligas / 1000)

Expand Down

0 comments on commit a005f23

Please sign in to comment.