Merge branch 'master' into ab-various-token-id-fixes

pull/2755/head
Ayrat Badykov 5 years ago committed by GitHub
commit 303273b1d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 2
      apps/block_scout_web/lib/block_scout_web/csp_header.ex
  3. 21
      apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex
  4. 4
      apps/block_scout_web/priv/gettext/default.pot
  5. 10
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  6. 41
      apps/block_scout_web/test/block_scout_web/views/tokens/instance/overview_view_test.exs

@ -16,6 +16,7 @@
### Fixes
- [#2755](https://github.com/poanetwork/blockscout/pull/2755) - various token instance fetcher fixes
- [#2753](https://github.com/poanetwork/blockscout/pull/2753) - fix nft token instance images
- [#2750](https://github.com/poanetwork/blockscout/pull/2750) - fixed contract buttons color for NFT token instance on each theme
- [#2746](https://github.com/poanetwork/blockscout/pull/2746) - fixed wrong alignment in logs decoded view
- [#2745](https://github.com/poanetwork/blockscout/pull/2745) - optimize addresses page

@ -15,7 +15,7 @@ defmodule BlockScoutWeb.CSPHeader do
default-src 'self';\
script-src 'self' 'unsafe-inline' 'unsafe-eval';\
style-src 'self' 'unsafe-inline' 'unsafe-eval' https://fonts.googleapis.com;\
img-src 'self' 'unsafe-inline' 'unsafe-eval' data: https:;\
img-src 'self' * data:;\
font-src 'self' 'unsafe-inline' 'unsafe-eval' https://fonts.gstatic.com data:;\
"
})

@ -20,11 +20,22 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do
def image_src(nil), do: "/images/controller.svg"
def image_src(instance) do
cond do
instance.metadata && instance.metadata["image_url"] -> instance.metadata["image_url"]
instance.metadata && instance.metadata["image"] -> instance.metadata["image"]
true -> image_src(nil)
end
result =
cond do
instance.metadata && instance.metadata["image_url"] ->
instance.metadata["image_url"]
instance.metadata && instance.metadata["image"] ->
instance.metadata["image"]
instance.metadata && instance.metadata["properties"]["image"]["description"] ->
instance.metadata["properties"]["image"]["description"]
true ->
image_src(nil)
end
if String.trim(result) == "", do: image_src(nil), else: result
end
def total_supply_usd(token) do

@ -925,7 +925,7 @@ msgstr ""
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:15
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:4
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:60
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:71
#: lib/block_scout_web/views/tokens/overview_view.ex:35
#: lib/block_scout_web/views/transaction_view.ex:313
msgid "Token Transfers"
@ -1855,7 +1855,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/instance/metadata/index.html.eex:18
#: lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:10
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:61
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:72
msgid "Metadata"
msgstr ""

@ -925,7 +925,7 @@ msgstr ""
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:15
#: lib/block_scout_web/templates/transaction/_tabs.html.eex:4
#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:7
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:60
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:71
#: lib/block_scout_web/views/tokens/overview_view.ex:35
#: lib/block_scout_web/views/transaction_view.ex:313
msgid "Token Transfers"
@ -1820,7 +1820,7 @@ msgstr ""
msgid "Copy Token ID"
msgstr ""
#, elixir-format, fuzzy
#, elixir-format
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:69
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:67
msgid "Decimals"
@ -1855,16 +1855,16 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/instance/metadata/index.html.eex:18
#: lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex:10
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:61
#: lib/block_scout_web/views/tokens/instance/overview_view.ex:72
msgid "Metadata"
msgstr ""
#, elixir-format, fuzzy
#, elixir-format
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:58
msgid "Module"
msgstr ""
#, elixir-format, fuzzy
#, elixir-format
#: lib/block_scout_web/templates/chain/show.html.eex:56
msgid "Total transactions"
msgstr ""

@ -0,0 +1,41 @@
defmodule BlockScoutWeb.Tokens.Instance.OverviewViewTest do
use BlockScoutWeb.ConnCase, async: true
alias BlockScoutWeb.Tokens.Instance.OverviewView
describe "image_src/1" do
test "fetches image from ['properties']['image']['description'] path" do
json = """
{
"type": "object",
"title": "TestCore Metadata",
"properties": {
"name": {
"type": "string",
"description": "Identifies the asset to which this NFT represents"
},
"image": {
"type": "string",
"description": "https://img.paoditu.com/images/cut_trace_images/6b/5f/5b754f6b5f3b5_500_500.jpg"
},
"description": {
"type": "string",
"description": "Describes the asset to which this NFT represents"
}
}
}
"""
data = Jason.decode!(json)
assert OverviewView.image_src(%{metadata: data}) ==
"https://img.paoditu.com/images/cut_trace_images/6b/5f/5b754f6b5f3b5_500_500.jpg"
end
test "handles empty images" do
instance = %{metadata: %{"image" => ""}}
assert OverviewView.image_src(instance) != ""
end
end
end
Loading…
Cancel
Save