add links to token instance

pull/2642/head
Ayrat Badykov 5 years ago
parent 24e455b8fd
commit 29c8f59a4f
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 2
      apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex
  2. 2
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/instance/transfer_controller.ex
  3. 2
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/transfer_controller.ex
  4. 28
      apps/block_scout_web/lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex
  5. 4
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_tile.html.eex
  6. 8
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_token_transfer.html.eex
  7. 7
      apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex
  8. 8
      apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex
  9. 10
      apps/block_scout_web/lib/block_scout_web/views/tokens/helpers.ex

@ -62,6 +62,7 @@ defmodule BlockScoutWeb.AddressTransactionController do
View.render_to_string( View.render_to_string(
TransactionView, TransactionView,
"_emission_reward_tile.html", "_emission_reward_tile.html",
conn: conn,
current_address: address, current_address: address,
emission_funds: emission_reward, emission_funds: emission_reward,
validator: validator_reward validator: validator_reward
@ -71,6 +72,7 @@ defmodule BlockScoutWeb.AddressTransactionController do
View.render_to_string( View.render_to_string(
TransactionView, TransactionView,
"_tile.html", "_tile.html",
conn: conn,
current_address: address, current_address: address,
transaction: transaction transaction: transaction
) )

@ -36,7 +36,7 @@ defmodule BlockScoutWeb.Tokens.Instance.TransferController do
"_token_transfer.html", "_token_transfer.html",
conn: conn, conn: conn,
token: token, token: token,
transfer: transfer token_transfer: transfer
) )
end) end)

@ -29,7 +29,7 @@ defmodule BlockScoutWeb.Tokens.TransferController do
"_token_transfer.html", "_token_transfer.html",
conn: conn, conn: conn,
token: token, token: token,
transfer: transfer token_transfer: transfer
) )
end) end)

@ -6,29 +6,35 @@
</div> </div>
<!-- Content --> <!-- Content -->
<div class="col-md-7 col-lg-8 d-flex flex-column pr-2 pr-sm-2 pr-md-0"> <div class="col-md-7 col-lg-8 d-flex flex-column pr-2 pr-sm-2 pr-md-0">
<%= render BlockScoutWeb.TransactionView, "_link.html", transaction_hash: @transfer.transaction_hash %> <%= render BlockScoutWeb.TransactionView, "_link.html", transaction_hash: @token_transfer.transaction_hash %>
<span class="text-nowrap"> <span class="text-nowrap">
<%= link to: address_token_transfers_path(@conn, :index, @transfer.from_address, @token.contract_address_hash), "data-test": "address_hash_link" do %> <%= link to: address_token_transfers_path(@conn, :index, @token_transfer.from_address, @token.contract_address_hash), "data-test": "address_hash_link" do %>
<%= render( <%= render(
BlockScoutWeb.AddressView, BlockScoutWeb.AddressView,
"_responsive_hash.html", "_responsive_hash.html",
address: @transfer.from_address, address: @token_transfer.from_address,
contract: BlockScoutWeb.AddressView.contract?(@transfer.from_address) contract: BlockScoutWeb.AddressView.contract?(@token_transfer.from_address)
) %> ) %>
<% end %> <% end %>
&rarr; &rarr;
<%= link to: address_token_transfers_path(@conn, :index, @transfer.to_address, @token.contract_address_hash), "data-test": "address_hash_link" do %> <%= link to: address_token_transfers_path(@conn, :index, @token_transfer.to_address, @token.contract_address_hash), "data-test": "address_hash_link" do %>
<%= render( <%= render(
BlockScoutWeb.AddressView, BlockScoutWeb.AddressView,
"_responsive_hash.html", "_responsive_hash.html",
address: @transfer.to_address, address: @token_transfer.to_address,
contract: BlockScoutWeb.AddressView.contract?(@transfer.to_address) contract: BlockScoutWeb.AddressView.contract?(@token_transfer.to_address)
) %> ) %>
<% end %> <% end %>
</span> </span>
<span class="d-flex flex-md-row flex-column mt-3 mt-md-0"> <span class="d-flex flex-md-row flex-column mt-3 mt-md-0">
<span class="tile-title"> <span class="tile-title">
<%= token_transfer_amount(@transfer) %> <%= @transfer.token.symbol %> <%= case token_transfer_amount(@token_transfer) do %>
<% {:ok, :erc721_instance} -> %>
<%= "TokenID ["%><%= link(@token_transfer.token_id, to: token_instance_path(@conn, :show, to_string(@token_transfer.token_id), @token_transfer.token.contract_address_hash)) %><%= "]" %>
<% {:ok, value} -> %>
<%= value %>
<% end %>
<%= @token_transfer.token.symbol %>
</span> </span>
</span> </span>
</div> </div>
@ -36,11 +42,11 @@
<div class="col-md-3 col-lg-2 d-flex flex-row flex-md-column flex-nowrap justify-content-center text-md-right mt-3 mt-md-0"> <div class="col-md-3 col-lg-2 d-flex flex-row flex-md-column flex-nowrap justify-content-center text-md-right mt-3 mt-md-0">
<span class="mr-2 mr-md-0 order-1"> <span class="mr-2 mr-md-0 order-1">
<%= link( <%= link(
gettext("Block #%{number}", number: @transfer.block_number), gettext("Block #%{number}", number: @token_transfer.block_number),
to: block_path(BlockScoutWeb.Endpoint, :show, @transfer.block_number) to: block_path(BlockScoutWeb.Endpoint, :show, @token_transfer.block_number)
) %> ) %>
</span> </span>
<span class="mr-2 mr-md-0 order-2" data-from-now="<%= @transfer.transaction.block.timestamp %>"></span> <span class="mr-2 mr-md-0 order-2" data-from-now="<%= @token_transfer.transaction.block.timestamp %>"></span>
</div> </div>
</div> </div>
</div> </div>

@ -38,11 +38,11 @@
<div class="d-flex flex-column mt-2"> <div class="d-flex flex-column mt-2">
<% [first_token_transfer | remaining_token_transfers] = @transaction.token_transfers %> <% [first_token_transfer | remaining_token_transfers] = @transaction.token_transfers %>
<%= render "_token_transfer.html", address: assigns[:current_address], token_transfer: first_token_transfer %> <%= render "_token_transfer.html", address: assigns[:current_address], token_transfer: first_token_transfer, conn: @conn %>
<div class="collapse token-transfer-toggle" id="transaction-<%= @transaction.hash %>"> <div class="collapse token-transfer-toggle" id="transaction-<%= @transaction.hash %>">
<%= for token_transfer <- remaining_token_transfers do %> <%= for token_transfer <- remaining_token_transfers do %>
<%= render "_token_transfer.html", address: assigns[:current_address], token_transfer: token_transfer %> <%= render "_token_transfer.html", address: assigns[:current_address], token_transfer: token_transfer, conn: @conn %>
<% end %> <% end %>
</div> </div>
</div> </div>

@ -20,6 +20,12 @@
</span> </span>
</span> </span>
<span class="col-xs-12 col-lg-4 ml-3 ml-sm-0 text-truncate"> <span class="col-xs-12 col-lg-4 ml-3 ml-sm-0 text-truncate">
<%= token_transfer_amount(@token_transfer) %> <%= link(token_symbol(@token_transfer.token), to: token_path(BlockScoutWeb.Endpoint, :show, @token_transfer.token.contract_address_hash)) %> <%= case token_transfer_amount(@token_transfer) do %>
<% {:ok, :erc721_instance} -> %>
<%= "TokenID ["%><%= link(@token_transfer.token_id, to: token_instance_path(@conn, :show, to_string(@token_transfer.token_id), @token_transfer.token.contract_address_hash)) %><%= "]" %>
<% {:ok, value} -> %>
<%= value %>
<% end %>
<%= link(token_symbol(@token_transfer.token), to: token_path(BlockScoutWeb.Endpoint, :show, @token_transfer.token.contract_address_hash)) %>
</span> </span>
</div> </div>

@ -193,7 +193,12 @@
<div class="text-right"> <div class="text-right">
<%= for transfer <- aggregate_token_transfers(transaction_with_transfers.token_transfers) do %> <%= for transfer <- aggregate_token_transfers(transaction_with_transfers.token_transfers) do %>
<h3 class="address-balance-text"> <h3 class="address-balance-text">
<%= token_transfer_amount(transfer) %> <%= case token_transfer_amount(@token_transfer) do %>
<% {:ok, :erc721_instance} -> %>
<%= "TokenID ["%><%= link(@token_transfer.token_id, to: token_instance_path(@conn, :show, to_string(@token_transfer.token_id), @token_transfer.token.contract_address_hash)) %><%= "]" %>
<% {:ok, value} -> %>
<%= value %>
<% end %>
<%= " "%> <%= " "%>
<%= link(token_symbol(transfer.token), to: token_path(BlockScoutWeb.Endpoint, :show, transfer.token.contract_address_hash)) %> <%= link(token_symbol(transfer.token), to: token_path(BlockScoutWeb.Endpoint, :show, transfer.token.contract_address_hash)) %>
</h3> </h3>

@ -13,7 +13,13 @@
</span> </span>
<span class="tile-title text-truncate"> <span class="tile-title text-truncate">
<%= token_transfer_amount(@token_transfer) %> <%= link(token_symbol(@token_transfer.token), to: token_path(@conn, :show, @token_transfer.token.contract_address_hash)) %> <%= case token_transfer_amount(@token_transfer) do%>
<% {:ok, :erc721_instance} -> %>
<%= "TokenID ["%><%= link(@token_transfer.token_id, to: token_instance_path(@conn, :show, to_string(@token_transfer.token_id), @token_transfer.token.contract_address_hash)) %><%= "]" %>
<% {:ok, value} -> %>
<%= value %>
<% end %>
<%= link(token_symbol(@token_transfer.token), to: token_path(BlockScoutWeb.Endpoint, :show, @token_transfer.token.contract_address_hash)) %>
</span> </span>
</div> </div>
</div> </div>

@ -21,19 +21,19 @@ defmodule BlockScoutWeb.Tokens.Helpers do
end end
defp do_token_transfer_amount(%Token{type: "ERC-20"}, nil, _token_id) do defp do_token_transfer_amount(%Token{type: "ERC-20"}, nil, _token_id) do
"--" {:ok, "--"}
end end
defp do_token_transfer_amount(%Token{type: "ERC-20", decimals: nil}, amount, _token_id) do defp do_token_transfer_amount(%Token{type: "ERC-20", decimals: nil}, amount, _token_id) do
CurrencyHelpers.format_according_to_decimals(amount, Decimal.new(0)) {:ok, CurrencyHelpers.format_according_to_decimals(amount, Decimal.new(0))}
end end
defp do_token_transfer_amount(%Token{type: "ERC-20", decimals: decimals}, amount, _token_id) do defp do_token_transfer_amount(%Token{type: "ERC-20", decimals: decimals}, amount, _token_id) do
CurrencyHelpers.format_according_to_decimals(amount, decimals) {:ok, CurrencyHelpers.format_according_to_decimals(amount, decimals)}
end end
defp do_token_transfer_amount(%Token{type: "ERC-721"}, _amount, token_id) do defp do_token_transfer_amount(%Token{type: "ERC-721"}, _amount, _token_id) do
"TokenID [#{token_id}]" {:ok, :erc721_instance}
end end
defp do_token_transfer_amount(_token, _amount, _token_id) do defp do_token_transfer_amount(_token, _amount, _token_id) do

Loading…
Cancel
Save