fix: Hotfix for Indexer.Fetcher.Optimism.WithdrawalEvent and EthereumJSONRPC.Receipt (#10130)

* fix: Hotfix for Indexer.Fetcher.Optimism.WithdrawalEvent

* Small refactoring

* Small refactoring

* Consider nil in game_index

* Add empty handler for Optimism Fjord tx receipt fields

---------

Co-authored-by: POA <33550681+poa@users.noreply.github.com>
pull/10146/head
varasev 6 months ago committed by GitHub
parent 5c4cb10f4c
commit dc44b18030
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex
  2. 14
      apps/indexer/lib/indexer/fetcher/optimism/withdrawal_event.ex

@ -369,7 +369,8 @@ defmodule EthereumJSONRPC.Receipt do
defp entry_to_elixir({key, quantity})
when key in ~w(blockNumber cumulativeGasUsed gasUsed transactionIndex blobGasUsed
blobGasPrice l1Fee l1GasPrice l1GasUsed effectiveGasPrice gasUsedForL1) do
blobGasPrice l1Fee l1GasPrice l1GasUsed effectiveGasPrice gasUsedForL1
l1BlobBaseFeeScalar l1BlobBaseFee l1BaseFeeScalar) do
result =
if is_nil(quantity) do
nil

@ -207,7 +207,8 @@ defmodule Indexer.Fetcher.Optimism.WithdrawalEvent do
Map.put(acc, block_number, timestamp)
end)
Enum.map(events, fn event ->
events
|> Enum.map(fn event ->
tx_hash = event["transactionHash"]
{l1_event_type, game_index} =
@ -233,6 +234,17 @@ defmodule Indexer.Fetcher.Optimism.WithdrawalEvent do
game_index: game_index
}
end)
|> Enum.reduce(%{}, fn e, acc ->
key = {e.withdrawal_hash, e.l1_event_type}
prev_game_index = Map.get(acc, key, %{game_index: 0}).game_index
if prev_game_index < e.game_index or is_nil(prev_game_index) do
Map.put(acc, key, e)
else
acc
end
end)
|> Map.values()
end
def get_last_l1_item do

Loading…
Cancel
Save