From 47b01580be6187c5283597fa1395e0249dfe2641 Mon Sep 17 00:00:00 2001
From: POA <33550681+poa@users.noreply.github.com>
Date: Fri, 31 Mar 2023 14:55:00 +0300
Subject: [PATCH] Add Aave tx actions to the old UI
---
.../templates/transaction/_actions.html.eex | 78 +++++++++++++++++++
.../transaction/_actions_aave.html.eex | 1 +
apps/block_scout_web/priv/gettext/default.pot | 4 +-
.../priv/gettext/en/LC_MESSAGES/default.po | 4 +-
4 files changed, 83 insertions(+), 4 deletions(-)
create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions_aave.html.eex
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions.html.eex
index a5ce8cfb15..9a820f5ad9 100644
--- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions.html.eex
+++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions.html.eex
@@ -1,3 +1,81 @@
+<%= if @action.protocol == :aave_v3 do %>
+ <%= if Enum.member?([:borrow, :supply, :withdraw, :repay, :flash_loan], @action.type) do %>
+
">
+
+ <% amount = formatted_action_amount(@action.data, "amount") %>
+ <% symbol = Map.get(@action.data, "symbol") %>
+ <% address = Map.get(@action.data, "address") %>
+
+
+
+ <% symbol = if symbol != "Ether", do: link(symbol, to: token_path(BlockScoutWeb.Endpoint, :show, address), "data-test": "token_link"), else: raw(symbol) %>
+
+ <%= if @action.type == :borrow do %>
+ <%= render BlockScoutWeb.TransactionView, "_actions_aave.html", action: "Borrow", amount: amount, symbol: symbol, tail: "From Aave Protocol V3" %>
+ <% end %>
+ <%= if @action.type == :supply do %>
+ <%= render BlockScoutWeb.TransactionView, "_actions_aave.html", action: "Supply", amount: amount, symbol: symbol, tail: "To Aave Protocol V3" %>
+ <% end %>
+ <%= if @action.type == :withdraw do %>
+ <%= render BlockScoutWeb.TransactionView, "_actions_aave.html", action: "Withdraw", amount: amount, symbol: symbol, tail: "From Aave Protocol V3" %>
+ <% end %>
+ <%= if @action.type == :repay do %>
+ <%= render BlockScoutWeb.TransactionView, "_actions_aave.html", action: "Repay", amount: amount, symbol: symbol, tail: "To Aave Protocol V3" %>
+ <% end %>
+ <%= if @action.type == :flash_loan do %>
+ <%= render BlockScoutWeb.TransactionView, "_actions_aave.html", action: "Flash Loan", amount: amount, symbol: symbol, tail: "From Aave Protocol V3" %>
+ <% end %>
+
+
+
+ <% end %>
+ <%= if Enum.member?([:enable_collateral, :disable_collateral], @action.type) do %>
+ ">
+
+ <% symbol = Map.get(@action.data, "symbol") %>
+ <% address = Map.get(@action.data, "address") %>
+
+
+
+ <% symbol = if symbol != "Ether", do: link(symbol, to: token_path(BlockScoutWeb.Endpoint, :show, address), "data-test": "token_link"), else: raw(symbol) %>
+
+ <%= if @action.type == :enable_collateral do %>
+ Enable
+ <% else %>
+ Disable
+ <% end %>
+
+ <%= symbol %> as Collateral on Aave Protocol V3
+
+
+
+ <% end %>
+ <%= if @action.type == :liquidation_call do %>
+ ">
+ <% debt_amount = formatted_action_amount(@action.data, "debt_amount") %>
+ <% debt_symbol = Map.get(@action.data, "debt_symbol") %>
+ <% debt_address = Map.get(@action.data, "debt_address") %>
+ <% debt_symbol = if debt_symbol != "Ether", do: link(debt_symbol, to: token_path(BlockScoutWeb.Endpoint, :show, debt_address), "data-test": "token_link"), else: raw(debt_symbol) %>
+
+
+
+ <%= render BlockScoutWeb.TransactionView, "_actions_aave.html", action: "Liquidator Repay", amount: debt_amount, symbol: debt_symbol, tail: "To Aave Protocol V3" %>
+
+
+
+ <% collateral_amount = formatted_action_amount(@action.data, "collateral_amount") %>
+ <% collateral_symbol = Map.get(@action.data, "collateral_symbol") %>
+ <% collateral_address = Map.get(@action.data, "collateral_address") %>
+ <% collateral_symbol = if collateral_symbol != "Ether", do: link(collateral_symbol, to: token_path(BlockScoutWeb.Endpoint, :show, collateral_address), "data-test": "token_link"), else: raw(collateral_symbol) %>
+
+
+
+ <%= render BlockScoutWeb.TransactionView, "_actions_aave.html", action: "Liquidation", amount: collateral_amount, symbol: collateral_symbol, tail: "On Aave Protocol V3" %>
+
+
+
+ <% end %>
+<% end %>
<%= if @action.protocol == :uniswap_v3 do %>
<%= if @action.type == :mint_nft do %>
">
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions_aave.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions_aave.html.eex
new file mode 100644
index 0000000000..7e1b70b886
--- /dev/null
+++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_actions_aave.html.eex
@@ -0,0 +1 @@
+<%= @action %> <%= @amount %> <%= @symbol %> <%= @tail %>
\ No newline at end of file
diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot
index fee9f73e6d..e829ea5aa7 100644
--- a/apps/block_scout_web/priv/gettext/default.pot
+++ b/apps/block_scout_web/priv/gettext/default.pot
@@ -3503,7 +3503,7 @@ msgstr ""
msgid "Your request contained an error, perhaps a mistyped tx/block/address hash. Try again, and check the developer tools console for more info."
msgstr ""
-#: lib/block_scout_web/templates/transaction/_actions.html.eex:23
+#: lib/block_scout_web/templates/transaction/_actions.html.eex:101
#, elixir-autogen, elixir-format
msgid "%{qty} of Token ID [%{link_to_id}]"
msgstr ""
@@ -3513,7 +3513,7 @@ msgstr ""
msgid "Highlighted events of the transaction."
msgstr ""
-#: lib/block_scout_web/templates/transaction/_actions.html.eex:14
+#: lib/block_scout_web/templates/transaction/_actions.html.eex:92
#, elixir-autogen, elixir-format
msgid "Mint of %{address} To %{to}"
msgstr ""
diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
index 1ddf98d65c..4c58cbc2d6 100644
--- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
+++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
@@ -3503,7 +3503,7 @@ msgstr ""
msgid "Your request contained an error, perhaps a mistyped tx/block/address hash. Try again, and check the developer tools console for more info."
msgstr ""
-#: lib/block_scout_web/templates/transaction/_actions.html.eex:23
+#: lib/block_scout_web/templates/transaction/_actions.html.eex:101
#, elixir-autogen, elixir-format
msgid "%{qty} of Token ID [%{link_to_id}]"
msgstr ""
@@ -3513,7 +3513,7 @@ msgstr ""
msgid "Highlighted events of the transaction."
msgstr ""
-#: lib/block_scout_web/templates/transaction/_actions.html.eex:14
+#: lib/block_scout_web/templates/transaction/_actions.html.eex:92
#, elixir-autogen, elixir-format
msgid "Mint of %{address} To %{to}"
msgstr ""