Skip to content

Commit

Permalink
zip movements with transfers refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
bchamagne committed Jan 5, 2024
1 parent 67dd7be commit ce57774
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
23 changes: 10 additions & 13 deletions lib/archethic_web/explorer/live/transaction_details_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -301,25 +301,22 @@ defmodule ArchethicWeb.Explorer.TransactionDetailsLive do
# movements are inserted in this order: 1: uco 2: token 3: mint
uco_transfers_count = length(uco_transfers)
token_transfers_count = length(token_transfers)
movements_count = length(movements)

uco_movements =
Enum.slice(movements, 0, uco_transfers_count)
{uco_movements, rest} = Enum.split(movements, uco_transfers_count)
{token_movements, mint_movements} = Enum.split(rest, token_transfers_count)

List.flatten([
uco_movements
|> Enum.zip_with(uco_transfers, fn movement, %UCOTransfer{to: address} ->
{movement, address}
end)

token_movements =
Enum.slice(movements, uco_transfers_count, token_transfers_count)
end),
token_movements
|> Enum.zip_with(token_transfers, fn movement, %TokenTransfer{to: address} ->
{movement, address}
end)

mint_movements =
Enum.slice(movements, uco_transfers_count + token_transfers_count, movements_count)
end),
mint_movements
|> Enum.map(&{&1, nil})

List.flatten([uco_movements, token_movements, mint_movements])
])
end

defp filter_inputs(
Expand Down
19 changes: 11 additions & 8 deletions lib/archethic_web/explorer/live/transaction_details_live.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,13 @@
<li class="columns">
<div class="column is-narrow">
<span class="ae-label">To</span>
<%= link(WebUtils.short_address(movement.to),

<%= link(WebUtils.short_address(transfer_address),
to:
Routes.live_path(
@socket,
ArchethicWeb.Explorer.TransactionDetailsLive,
Base.encode16(movement.to)
Base.encode16(transfer_address)
)
) %>
</div>
Expand All @@ -207,12 +208,13 @@
<span class="tag is-success mono">MINTED</span>
<% else %>
<span class="ae-label">Resolved</span>
<%= link(WebUtils.short_address(transfer_address),

<%= link(WebUtils.short_address(movement.to),
to:
Routes.live_path(
@socket,
ArchethicWeb.Explorer.TransactionDetailsLive,
Base.encode16(transfer_address)
Base.encode16(movement.to)
)
) %>
<% end %>
Expand All @@ -231,12 +233,13 @@
<li class="columns">
<div class="column is-narrow">
<span class="ae-label">To</span>
<%= link(WebUtils.short_address(movement.to),

<%= link(WebUtils.short_address(transfer_address),
to:
Routes.live_path(
@socket,
ArchethicWeb.Explorer.TransactionDetailsLive,
Base.encode16(movement.to)
Base.encode16(transfer_address)
)
) %>
</div>
Expand All @@ -246,12 +249,12 @@
<span class="tag is-success mono">MINTED</span>
<% else %>
<span class="ae-label">Resolved</span>
<%= link(WebUtils.short_address(transfer_address),
<%= link(WebUtils.short_address(movement.to),
to:
Routes.live_path(
@socket,
ArchethicWeb.Explorer.TransactionDetailsLive,
Base.encode16(transfer_address)
Base.encode16(movement.to)
)
) %>
<% end %>
Expand Down

0 comments on commit ce57774

Please sign in to comment.