diff --git a/CHANGELOG.md b/CHANGELOG.md
index 32894ae0da..e345f9216d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,12 +1,15 @@
## Current
### Features
+- [#2555](https://github.com/poanetwork/blockscout/pull/2555) - find and show decoding candidates for logs
- [#2596](https://github.com/poanetwork/blockscout/pull/2596) - support AuRa's empty step reward type
- [#2561](https://github.com/poanetwork/blockscout/pull/2561) - Add token's type to the response of tokenlist method
- [#2499](https://github.com/poanetwork/blockscout/pull/2499) - import emission reward ranges
- [#2497](https://github.com/poanetwork/blockscout/pull/2497) - Add generic Ordered Cache behaviour and implementation
### Fixes
+- [#2640](https://github.com/poanetwork/blockscout/pull/2640) - SVG network icons
+- [#2635](https://github.com/poanetwork/blockscout/pull/2635) - optimize ERC721 inventory query
- [#2626](https://github.com/poanetwork/blockscout/pull/2626) - Fixing 2 Mobile UI Issues
- [#2623](https://github.com/poanetwork/blockscout/pull/2623) - fix a blinking test
- [#2616](https://github.com/poanetwork/blockscout/pull/2616) - deduplicate coin history records by delta
diff --git a/apps/block_scout_web/assets/css/_images-preload.scss b/apps/block_scout_web/assets/css/_images-preload.scss
index a084daa7a9..95f4633a56 100644
--- a/apps/block_scout_web/assets/css/_images-preload.scss
+++ b/apps/block_scout_web/assets/css/_images-preload.scss
@@ -1,16 +1,16 @@
body:after {
position:absolute; width:0; height:0; overflow:hidden; z-index:-1;
content:
- url(/images/network-selector-icons/callisto-mainnet.png)
- url(/images/network-selector-icons/ethereum-mainnet.png)
- url(/images/network-selector-icons/ethereum-classic.png)
- url(/images/network-selector-icons/goerli-testnet.png)
- url(/images/network-selector-icons/kovan-testnet.png)
- url(/images/network-selector-icons/poa-core.png)
- url(/images/network-selector-icons/poa-sokol.png)
- url(/images/network-selector-icons/rinkeby-testnet.png)
- url(/images/network-selector-icons/rsk-mainnet.png)
- url(/images/network-selector-icons/ropsten-testnet.png)
- url(/images/network-selector-icons/xdai-chain.png)
- url(/images/network-selector-icons/lukso-l14-testnet.png)
+ url(/images/network-selector-icons/callisto-mainnet.svg)
+ url(/images/network-selector-icons/ethereum-mainnet.svg)
+ url(/images/network-selector-icons/ethereum-classic.svg)
+ url(/images/network-selector-icons/goerli-testnet.svg)
+ url(/images/network-selector-icons/kovan-testnet.svg)
+ url(/images/network-selector-icons/poa-core.svg)
+ url(/images/network-selector-icons/poa-sokol.svg)
+ url(/images/network-selector-icons/rinkeby-testnet.svg)
+ url(/images/network-selector-icons/rsk-mainnet.svg)
+ url(/images/network-selector-icons/ropsten-testnet.svg)
+ url(/images/network-selector-icons/xdai-chain.svg)
+ url(/images/network-selector-icons/lukso-l14-testnet.svg)
};
\ No newline at end of file
diff --git a/apps/block_scout_web/assets/css/components/_network-selector.scss b/apps/block_scout_web/assets/css/components/_network-selector.scss
index e4a4991fa7..9df2d22164 100644
--- a/apps/block_scout_web/assets/css/components/_network-selector.scss
+++ b/apps/block_scout_web/assets/css/components/_network-selector.scss
@@ -245,40 +245,40 @@ $network-selector-item-icon-dimensions: 30px !default;
width: $network-selector-item-icon-dimensions;
&-callisto-mainnet {
- background-image: url(/images/network-selector-icons/callisto-mainnet.png)
+ background-image: url(/images/network-selector-icons/callisto-mainnet.svg)
}
&-ethereum-mainnet {
- background-image: url(/images/network-selector-icons/ethereum-mainnet.png)
+ background-image: url(/images/network-selector-icons/ethereum-mainnet.svg)
}
&-ethereum-classic {
- background-image: url(/images/network-selector-icons/ethereum-classic.png)
+ background-image: url(/images/network-selector-icons/ethereum-classic.svg)
}
&-goerli-testnet {
- background-image: url(/images/network-selector-icons/goerli-testnet.png)
+ background-image: url(/images/network-selector-icons/goerli-testnet.svg)
}
&-kovan-testnet {
- background-image: url(/images/network-selector-icons/kovan-testnet.png)
+ background-image: url(/images/network-selector-icons/kovan-testnet.svg)
}
&-poa-core {
- background-image: url(/images/network-selector-icons/poa-core.png)
+ background-image: url(/images/network-selector-icons/poa-core.svg)
}
&-poa-sokol {
- background-image: url(/images/network-selector-icons/poa-sokol.png)
+ background-image: url(/images/network-selector-icons/poa-sokol.svg)
}
&-rinkeby-testnet {
- background-image: url(/images/network-selector-icons/rinkeby-testnet.png)
+ background-image: url(/images/network-selector-icons/rinkeby-testnet.svg)
}
&-rsk-mainnet {
- background-image: url(/images/network-selector-icons/rsk-mainnet.png)
+ background-image: url(/images/network-selector-icons/rsk-mainnet.svg)
}
&-ropsten-testnet {
- background-image: url(/images/network-selector-icons/ropsten-testnet.png)
+ background-image: url(/images/network-selector-icons/ropsten-testnet.svg)
}
&-xdai-chain {
- background-image: url(/images/network-selector-icons/xdai-chain.png)
+ background-image: url(/images/network-selector-icons/xdai-chain.svg)
}
&-lukso-l14-testnet {
- background-image: url(/images/network-selector-icons/lukso-l14-testnet.png)
+ background-image: url(/images/network-selector-icons/lukso-l14-testnet.svg)
}
}
diff --git a/apps/block_scout_web/assets/package-lock.json b/apps/block_scout_web/assets/package-lock.json
index 2c78f45f55..d00f148391 100644
--- a/apps/block_scout_web/assets/package-lock.json
+++ b/apps/block_scout_web/assets/package-lock.json
@@ -4555,7 +4555,6 @@
"version": "2.2.4",
"resolved": false,
"integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
- "optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@@ -4773,8 +4772,7 @@
"safe-buffer": {
"version": "5.1.1",
"resolved": false,
- "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
- "optional": true
+ "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
},
"safer-buffer": {
"version": "2.1.2",
@@ -4877,8 +4875,7 @@
"yallist": {
"version": "3.0.2",
"resolved": false,
- "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=",
- "optional": true
+ "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k="
}
}
},
@@ -5989,7 +5986,7 @@
},
"callsites": {
"version": "2.0.0",
- "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz",
+ "resolved": "http://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz",
"integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=",
"dev": true
},
@@ -6191,7 +6188,7 @@
},
"jest-get-type": {
"version": "22.4.3",
- "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-22.4.3.tgz",
+ "resolved": "http://registry.npmjs.org/jest-get-type/-/jest-get-type-22.4.3.tgz",
"integrity": "sha512-/jsz0Y+V29w1chdXVygEKSz2nBoHoYqNShPe+QgxSNjAuP1i8+k4LbQNrfoliKej0P45sivkSCh7yiD6ubHS3w==",
"dev": true
},
@@ -6723,9 +6720,9 @@
}
},
"jquery": {
- "version": "3.3.1",
- "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
- "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg=="
+ "version": "3.4.0",
+ "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.0.tgz",
+ "integrity": "sha512-ggRCXln9zEqv6OqAGXFEcshF5dSBvCkzj6Gm2gzuR5fWawaX8t7cxKVkkygKODrDAzKdoYw3l/e3pm3vlT4IbQ=="
},
"js-base64": {
"version": "2.4.5",
diff --git a/apps/block_scout_web/assets/package.json b/apps/block_scout_web/assets/package.json
index 98fbc501d6..1169e22859 100644
--- a/apps/block_scout_web/assets/package.json
+++ b/apps/block_scout_web/assets/package.json
@@ -29,7 +29,7 @@
"highlight.js": "^9.13.1",
"highlightjs-solidity": "^1.0.6",
"humps": "^2.0.1",
- "jquery": "^3.3.1",
+ "jquery": "^3.4.0",
"lodash": "^4.17.13",
"moment": "^2.22.1",
"nanomorph": "^5.1.3",
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/aerum-mainnet.png b/apps/block_scout_web/assets/static/images/network-selector-icons/aerum-mainnet.png
deleted file mode 100644
index cdef9a2edb..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/aerum-mainnet.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/callisto-mainnet.png b/apps/block_scout_web/assets/static/images/network-selector-icons/callisto-mainnet.png
deleted file mode 100644
index 2e9f2b2730..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/callisto-mainnet.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/callisto-mainnet.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/callisto-mainnet.svg
new file mode 100644
index 0000000000..6a11260fa9
--- /dev/null
+++ b/apps/block_scout_web/assets/static/images/network-selector-icons/callisto-mainnet.svg
@@ -0,0 +1,5 @@
+
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/callisto.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/callisto.svg
deleted file mode 100644
index 7adabb6538..0000000000
--- a/apps/block_scout_web/assets/static/images/network-selector-icons/callisto.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/core.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/core.svg
deleted file mode 100644
index 63c66a6baa..0000000000
--- a/apps/block_scout_web/assets/static/images/network-selector-icons/core.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/dai.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/dai.svg
deleted file mode 100644
index c4f800733e..0000000000
--- a/apps/block_scout_web/assets/static/images/network-selector-icons/dai.svg
+++ /dev/null
@@ -1,33 +0,0 @@
-
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/ethereum-classic.png b/apps/block_scout_web/assets/static/images/network-selector-icons/ethereum-classic.png
deleted file mode 100755
index 5ca5d8fe7b..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/ethereum-classic.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/ethereum-classic.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/ethereum-classic.svg
new file mode 100644
index 0000000000..111605081a
--- /dev/null
+++ b/apps/block_scout_web/assets/static/images/network-selector-icons/ethereum-classic.svg
@@ -0,0 +1,4 @@
+
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/ethereum-mainnet.png b/apps/block_scout_web/assets/static/images/network-selector-icons/ethereum-mainnet.png
deleted file mode 100755
index 3752a92544..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/ethereum-mainnet.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/ethereum-mainnet.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/ethereum-mainnet.svg
new file mode 100644
index 0000000000..cb0276593b
--- /dev/null
+++ b/apps/block_scout_web/assets/static/images/network-selector-icons/ethereum-mainnet.svg
@@ -0,0 +1,9 @@
+
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/goerli-testnet.png b/apps/block_scout_web/assets/static/images/network-selector-icons/goerli-testnet.png
deleted file mode 100644
index 7a3ac4ae48..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/goerli-testnet.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/goerli-testnet.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/goerli-testnet.svg
new file mode 100644
index 0000000000..01b44f13a8
--- /dev/null
+++ b/apps/block_scout_web/assets/static/images/network-selector-icons/goerli-testnet.svg
@@ -0,0 +1,4 @@
+
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/kovan-testnet.png b/apps/block_scout_web/assets/static/images/network-selector-icons/kovan-testnet.png
deleted file mode 100755
index 4fabf2fd71..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/kovan-testnet.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/kovan-testnet.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/kovan-testnet.svg
new file mode 100644
index 0000000000..d04f204e62
--- /dev/null
+++ b/apps/block_scout_web/assets/static/images/network-selector-icons/kovan-testnet.svg
@@ -0,0 +1,4 @@
+
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/lukso-l14-testnet.png b/apps/block_scout_web/assets/static/images/network-selector-icons/lukso-l14-testnet.png
deleted file mode 100755
index 714c80f775..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/lukso-l14-testnet.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/lukso-l14-testnet.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/lukso-l14-testnet.svg
new file mode 100644
index 0000000000..bc849bbf9d
--- /dev/null
+++ b/apps/block_scout_web/assets/static/images/network-selector-icons/lukso-l14-testnet.svg
@@ -0,0 +1,6 @@
+
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/poa-core.png b/apps/block_scout_web/assets/static/images/network-selector-icons/poa-core.png
deleted file mode 100644
index 68bb5976f1..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/poa-core.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/poa-core.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/poa-core.svg
new file mode 100644
index 0000000000..f62c0ff8f6
--- /dev/null
+++ b/apps/block_scout_web/assets/static/images/network-selector-icons/poa-core.svg
@@ -0,0 +1,4 @@
+
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/poa-sokol.png b/apps/block_scout_web/assets/static/images/network-selector-icons/poa-sokol.png
deleted file mode 100644
index da38f9834b..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/poa-sokol.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/poa-sokol.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/poa-sokol.svg
new file mode 100644
index 0000000000..98a2fd0cfe
--- /dev/null
+++ b/apps/block_scout_web/assets/static/images/network-selector-icons/poa-sokol.svg
@@ -0,0 +1,4 @@
+
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/rinkeby-testnet.png b/apps/block_scout_web/assets/static/images/network-selector-icons/rinkeby-testnet.png
deleted file mode 100644
index 0e3993eb36..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/rinkeby-testnet.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/rinkeby-testnet.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/rinkeby-testnet.svg
new file mode 100644
index 0000000000..7a1c7de013
--- /dev/null
+++ b/apps/block_scout_web/assets/static/images/network-selector-icons/rinkeby-testnet.svg
@@ -0,0 +1,4 @@
+
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/rinkeby.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/rinkeby.svg
deleted file mode 100644
index 1991096926..0000000000
--- a/apps/block_scout_web/assets/static/images/network-selector-icons/rinkeby.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/ropsten-testnet.png b/apps/block_scout_web/assets/static/images/network-selector-icons/ropsten-testnet.png
deleted file mode 100644
index bc5afa1a2e..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/ropsten-testnet.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/ropsten-testnet.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/ropsten-testnet.svg
new file mode 100644
index 0000000000..96ccf5f9b4
--- /dev/null
+++ b/apps/block_scout_web/assets/static/images/network-selector-icons/ropsten-testnet.svg
@@ -0,0 +1,4 @@
+
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/ropsten.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/ropsten.svg
deleted file mode 100644
index 87c98f79d2..0000000000
--- a/apps/block_scout_web/assets/static/images/network-selector-icons/ropsten.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/rsk-mainnet.png b/apps/block_scout_web/assets/static/images/network-selector-icons/rsk-mainnet.png
deleted file mode 100755
index c7c0e067c8..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/rsk-mainnet.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/rsk-mainnet.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/rsk-mainnet.svg
new file mode 100644
index 0000000000..61965fb810
--- /dev/null
+++ b/apps/block_scout_web/assets/static/images/network-selector-icons/rsk-mainnet.svg
@@ -0,0 +1,4 @@
+
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/sokol.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/sokol.svg
deleted file mode 100644
index b2ced66189..0000000000
--- a/apps/block_scout_web/assets/static/images/network-selector-icons/sokol.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/xdai-chain.png b/apps/block_scout_web/assets/static/images/network-selector-icons/xdai-chain.png
deleted file mode 100644
index 5fb54a4175..0000000000
Binary files a/apps/block_scout_web/assets/static/images/network-selector-icons/xdai-chain.png and /dev/null differ
diff --git a/apps/block_scout_web/assets/static/images/network-selector-icons/xdai-chain.svg b/apps/block_scout_web/assets/static/images/network-selector-icons/xdai-chain.svg
new file mode 100644
index 0000000000..e6f660410a
--- /dev/null
+++ b/apps/block_scout_web/assets/static/images/network-selector-icons/xdai-chain.svg
@@ -0,0 +1,4 @@
+
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex
index e49adf8801..92a8ebc6cc 100644
--- a/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex
+++ b/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex
@@ -1,4 +1,19 @@
">
+ <% decoded_result = decode(@log, @log.transaction) %>
+ <%= case decoded_result do %>
+ <%= {:error, :contract_not_verified, _cadidates} -> %>
+
+ <%= gettext "To see accurate decoded input data, the contract must be verified." %>
+ <%= case @log.transaction do %>
+ <% %{to_address: %{hash: hash}} -> %>
+ <%= gettext "Verify the contract " %>
<%= gettext "here" %>
+ <% _ -> %>
+ <%= nil %>
+ <% end %>
+
+ <% _ -> %>
+ <%= nil %>
+ <% end %>
- <%= gettext "Transaction" %>
-
@@ -11,19 +26,7 @@
) %>
- <%= case decode(@log, @log.transaction) do %>
- <% {:error, :contract_not_verified} -> %>
- - <%= gettext "Decoded" %>
- -
-
- <%= gettext "To see decoded input data, the contract must be verified." %>
- <%= case @log.transaction do %>
- <% %{to_address: %{hash: hash}} -> %>
- <%= gettext "Verify the contract " %>
<%= gettext "here" %>
- <% _ -> %>
- <%= nil %>
- <% end %>
-
+ <%= case decoded_result do %>
<% {:error, :could_not_decode} -> %>
- <%= gettext "Decoded" %>
-
@@ -81,7 +84,61 @@
<% end %>
-
+
+ <% {:error, :contract_not_verified, results} -> %>
+ <%= for {:ok, method_id, text, mapping} <- results do %>
+ <%= gettext "Decoded" %>
+
+
+
+
" class="table thead-light table-bordered">
+
+ |
+ <%= gettext "Name" %> |
+ <%= gettext "Type" %> |
+ <%= gettext "Indexed?" %> |
+ <%= gettext "Data" %> |
+
+ <%= for {name, type, indexed?, value} <- mapping do %>
+
+
+ <%= case BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) do %>
+ <% :error -> %>
+ <%= nil %>
+ <% copy_text -> %>
+
+
+
+ <% end %>
+ |
+ <%= name %> |
+ <%= type %> |
+ <%= indexed? %> |
+
+ <%= BlockScoutWeb.ABIEncodedValueView.value_html(type, value) %>
+ |
+
+ <% end %>
+
+
+ <% end %>
<% _ -> %>
<%= nil %>
<% end %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex
index c63502669b..49a18bf84d 100644
--- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex
+++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex
@@ -1,4 +1,20 @@
+ <% decoded_result = decode(@log, @transaction) %>
+ <%= case decoded_result do %>
+ <%= {:error, :contract_not_verified, _cadidates} -> %>
+
+ <%= gettext "To see accurate decoded input data, the contract must be verified." %>
+ <%= case @transaction do %>
+ <% %{to_address: %{hash: hash}} -> %>
+ <%= gettext "Verify the contract " %>
<%= gettext "here" %>
+ <% _ -> %>
+ <%= nil %>
+ <% end %>
+
+ <% _ -> %>
+ <%= nil %>
+ <% end %>
+
- <%= gettext "Address" %>
-
@@ -11,19 +27,7 @@
) %>
- <%= case decode(@log, @transaction) do %>
- <% {:error, :contract_not_verified} -> %>
- - <%= gettext "Decoded" %>
- -
-
- <%= gettext "To see decoded input data, the contract must be verified." %>
- <%= case @transaction do %>
- <% %{to_address: %{hash: hash}} -> %>
- <%= gettext "Verify the contract " %>
<%= gettext "here" %>
- <% _ -> %>
- <%= nil %>
- <% end %>
-
+ <%= case decoded_result do %>
<% {:error, :could_not_decode} -> %>
- <%= gettext "Decoded" %>
-
@@ -83,7 +87,61 @@
<% end %>
-
+
+ <% {:error, :contract_not_verified, results} -> %>
+ <%= for {:ok, method_id, text, mapping} <- results do %>
+ <%= gettext "Decoded" %>
+
+
+
+
" class="table thead-light table-bordered">
+
+ |
+ <%= gettext "Name" %> |
+ <%= gettext "Type" %> |
+ <%= gettext "Indexed?" %> |
+ <%= gettext "Data" %> |
+
+ <%= for {name, type, indexed?, value} <- mapping do %>
+
+
+ <%= case BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) do %>
+ <% :error -> %>
+ <%= nil %>
+ <% copy_text -> %>
+
+
+
+ <% end %>
+ |
+ <%= name %> |
+ <%= type %> |
+ <%= indexed? %> |
+
+ <%= BlockScoutWeb.ABIEncodedValueView.value_html(type, value) %>
+ |
+
+ <% end %>
+
+
+ <% end %>
<% _ -> %>
<%= nil %>
<% end %>
diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot
index 886a88e4c0..607d83da8a 100644
--- a/apps/block_scout_web/priv/gettext/default.pot
+++ b/apps/block_scout_web/priv/gettext/default.pot
@@ -98,7 +98,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:16
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:3
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:19
#: lib/block_scout_web/views/address_view.ex:99
msgid "Address"
msgstr ""
@@ -558,11 +558,13 @@ msgid "Must be set to:"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:50
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:53
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:106
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:52
#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:59
#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:19
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:52
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:56
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:109
msgid "Name"
msgstr ""
@@ -851,7 +853,7 @@ msgid "Total transactions"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:3
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:18
#: lib/block_scout_web/views/transaction_view.ex:262
msgid "Transaction"
msgstr ""
@@ -1128,12 +1130,12 @@ msgid "Static Call"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:16
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:28
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:34
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:16
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:28
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:36
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:31
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:37
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:90
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:32
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:40
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:93
msgid "Decoded"
msgstr ""
@@ -1142,12 +1144,6 @@ msgstr ""
msgid "Method Id"
msgstr ""
-#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:19
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:19
-msgid "To see decoded input data, the contract must be verified."
-msgstr ""
-
#, elixir-format
#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:2
#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:16
@@ -1155,16 +1151,16 @@ msgid "Transaction Inputs"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:22
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:9
#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:22
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:9
msgid "Verify the contract "
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:22
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:9
#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:22
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:9
msgid "here"
msgstr ""
@@ -1318,7 +1314,9 @@ msgid "To have guaranteed accuracy, use the link above to verify the contract's
msgstr ""
#, elixir-format
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:6
#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:8
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:6
msgid "To see accurate decoded input data, the contract must be verified."
msgstr ""
@@ -1777,9 +1775,11 @@ msgid "Constructor Arguments"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:63
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:66
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:119
#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:31
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:65
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:69
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:122
msgid "Copy Value"
msgstr ""
@@ -1789,29 +1789,35 @@ msgid "Create2"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:53
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:118
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:56
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:109
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:175
#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:55
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:121
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:59
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:112
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:179
msgid "Data"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:31
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:31
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:34
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:35
msgid "Failed to decode log data."
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:52
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:54
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:55
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:108
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:58
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:111
msgid "Indexed?"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:47
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:49
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:50
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:103
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:53
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:106
msgid "Log Data"
msgstr ""
@@ -1823,14 +1829,16 @@ msgid "Reward"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:88
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:91
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:145
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:149
msgid "Topics"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:51
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:54
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:107
#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:20
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:53
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:57
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:110
msgid "Type"
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 8fd1e1ff2e..a4ae226813 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
@@ -98,7 +98,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:16
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:3
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:19
#: lib/block_scout_web/views/address_view.ex:99
msgid "Address"
msgstr ""
@@ -558,11 +558,13 @@ msgid "Must be set to:"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:50
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:53
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:106
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:52
#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:59
#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:19
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:52
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:56
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:109
msgid "Name"
msgstr ""
@@ -851,7 +853,7 @@ msgid "Total transactions"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:3
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:18
#: lib/block_scout_web/views/transaction_view.ex:262
msgid "Transaction"
msgstr ""
@@ -1128,12 +1130,12 @@ msgid "Static Call"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:16
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:28
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:34
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:16
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:28
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:36
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:31
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:37
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:90
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:32
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:40
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:93
msgid "Decoded"
msgstr ""
@@ -1142,12 +1144,6 @@ msgstr ""
msgid "Method Id"
msgstr ""
-#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:19
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:19
-msgid "To see decoded input data, the contract must be verified."
-msgstr ""
-
#, elixir-format
#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:2
#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:16
@@ -1155,16 +1151,16 @@ msgid "Transaction Inputs"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:22
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:9
#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:22
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:9
msgid "Verify the contract "
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:22
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:9
#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:22
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:9
msgid "here"
msgstr ""
@@ -1319,7 +1315,9 @@ msgid "To have guaranteed accuracy, use the link above to verify the contract's
msgstr ""
#, elixir-format
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:6
#: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:8
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:6
msgid "To see accurate decoded input data, the contract must be verified."
msgstr ""
@@ -1778,9 +1776,11 @@ msgid "Constructor Arguments"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:63
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:66
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:119
#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:31
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:65
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:69
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:122
msgid "Copy Value"
msgstr ""
@@ -1790,29 +1790,35 @@ msgid "Create2"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:53
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:118
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:56
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:109
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:175
#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:55
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:121
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:59
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:112
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:179
msgid "Data"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:31
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:31
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:34
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:35
msgid "Failed to decode log data."
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:52
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:54
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:55
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:108
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:58
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:111
msgid "Indexed?"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:47
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:49
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:50
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:103
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:53
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:106
msgid "Log Data"
msgstr ""
@@ -1824,14 +1830,16 @@ msgid "Reward"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:88
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:91
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:145
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:149
msgid "Topics"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_logs/_logs.html.eex:51
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:54
+#: lib/block_scout_web/templates/address_logs/_logs.html.eex:107
#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:20
-#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:53
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:57
+#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:110
msgid "Type"
msgstr ""
diff --git a/apps/explorer/lib/explorer/chain/log.ex b/apps/explorer/lib/explorer/chain/log.ex
index b6c5c00a2d..7916b56fb3 100644
--- a/apps/explorer/lib/explorer/chain/log.ex
+++ b/apps/explorer/lib/explorer/chain/log.ex
@@ -6,7 +6,8 @@ defmodule Explorer.Chain.Log do
require Logger
alias ABI.{Event, FunctionSelector}
- alias Explorer.Chain.{Address, Data, Hash, Transaction}
+ alias Explorer.Chain.{Address, ContractMethod, Data, Hash, Transaction}
+ alias Explorer.Repo
@required_attrs ~w(address_hash data index transaction_hash)a
@optional_attrs ~w(first_topic second_topic third_topic fourth_topic type)a
@@ -114,7 +115,50 @@ defmodule Explorer.Chain.Log do
do: {:ok, identifier, text, mapping}
end
- def decode(_log, _transaction), do: {:error, :contract_not_verified}
+ def decode(log, transaction) do
+ case log.first_topic do
+ "0x" <> hex_part ->
+ case Integer.parse(hex_part, 16) do
+ {number, ""} ->
+ <> = :binary.encode_unsigned(number)
+ find_candidates(method_id, log, transaction)
+
+ _ ->
+ {:error, :could_not_decode}
+ end
+
+ _ ->
+ {:error, :could_not_decode}
+ end
+ end
+
+ defp find_candidates(method_id, log, transaction) do
+ candidates_query =
+ from(
+ contract_method in ContractMethod,
+ where: contract_method.identifier == ^method_id,
+ limit: 3
+ )
+
+ candidates =
+ candidates_query
+ |> Repo.all()
+ |> Enum.flat_map(fn contract_method ->
+ case find_and_decode([contract_method.abi], log, transaction) do
+ {:ok, selector, mapping} ->
+ identifier = Base.encode16(selector.method_id, case: :lower)
+ text = function_call(selector.function, mapping)
+
+ [{:ok, identifier, text, mapping}]
+
+ _ ->
+ []
+ end
+ end)
+ |> Enum.take(1)
+
+ {:error, :contract_not_verified, candidates}
+ end
defp find_and_decode(abi, log, transaction) do
with {%FunctionSelector{} = selector, mapping} <-
diff --git a/apps/explorer/lib/explorer/chain/token_transfer.ex b/apps/explorer/lib/explorer/chain/token_transfer.ex
index 2aa291cb6f..619de87db2 100644
--- a/apps/explorer/lib/explorer/chain/token_transfer.ex
+++ b/apps/explorer/lib/explorer/chain/token_transfer.ex
@@ -27,7 +27,7 @@ defmodule Explorer.Chain.TokenTransfer do
import Ecto.Changeset
import Ecto.Query, only: [from: 2, limit: 2, where: 3]
- alias Explorer.Chain.{Address, Hash, Token, TokenTransfer, Transaction}
+ alias Explorer.Chain.{Address, Hash, TokenTransfer, Transaction}
alias Explorer.{PagingOptions, Repo}
@default_paging_options %PagingOptions{page_size: 50}
@@ -238,12 +238,8 @@ defmodule Explorer.Chain.TokenTransfer do
def address_to_unique_tokens(contract_address_hash) do
from(
tt in TokenTransfer,
- join: t in Token,
- on: tt.token_contract_address_hash == t.contract_address_hash,
- join: ts in Transaction,
- on: tt.transaction_hash == ts.hash,
- where: t.contract_address_hash == ^contract_address_hash and t.type == "ERC-721",
- order_by: [desc: ts.block_number],
+ where: tt.token_contract_address_hash == ^contract_address_hash,
+ order_by: [desc: tt.block_number],
distinct: tt.token_id,
preload: [:to_address],
select: tt
diff --git a/apps/explorer/priv/repo/migrations/20190827120224_add_index_on_token_transfer_token_id.exs b/apps/explorer/priv/repo/migrations/20190827120224_add_index_on_token_transfer_token_id.exs
new file mode 100644
index 0000000000..b92f216fd4
--- /dev/null
+++ b/apps/explorer/priv/repo/migrations/20190827120224_add_index_on_token_transfer_token_id.exs
@@ -0,0 +1,7 @@
+defmodule Explorer.Repo.Migrations.AddIndexOnTokenTransferTokenId do
+ use Ecto.Migration
+
+ def change do
+ create_if_not_exists(index(:token_transfers, [:token_id]))
+ end
+end
diff --git a/apps/explorer/test/explorer/chain/log_test.exs b/apps/explorer/test/explorer/chain/log_test.exs
index 28be44a1af..e4ce0695bc 100644
--- a/apps/explorer/test/explorer/chain/log_test.exs
+++ b/apps/explorer/test/explorer/chain/log_test.exs
@@ -2,7 +2,8 @@ defmodule Explorer.Chain.LogTest do
use Explorer.DataCase
alias Ecto.Changeset
- alias Explorer.Chain.Log
+ alias Explorer.Chain.{Log, SmartContract}
+ alias Explorer.Repo
doctest Log
@@ -47,7 +48,7 @@ defmodule Explorer.Chain.LogTest do
log = insert(:log, transaction: transaction)
- assert Log.decode(log, transaction) == {:error, :contract_not_verified}
+ assert Log.decode(log, transaction) == {:error, :could_not_decode}
end
test "that a contract call transaction that has a verified contract returns the decoded input data" do
@@ -100,5 +101,59 @@ defmodule Explorer.Chain.LogTest do
{"_belly", "bool", true, true}
]}
end
+
+ test "finds decoding candidates" do
+ params =
+ params_for(:smart_contract, %{
+ abi: [
+ %{
+ "anonymous" => false,
+ "inputs" => [
+ %{"indexed" => true, "name" => "_from_human", "type" => "string"},
+ %{"indexed" => false, "name" => "_number", "type" => "uint256"},
+ %{"indexed" => true, "name" => "_belly", "type" => "bool"}
+ ],
+ "name" => "WantsPets",
+ "type" => "event"
+ }
+ ]
+ })
+
+ # changeset has a callback to insert contract methods
+ %SmartContract{}
+ |> SmartContract.changeset(params)
+ |> Repo.insert!()
+
+ topic1 = "0x" <> Base.encode16(:keccakf1600.hash(:sha3_256, "WantsPets(string,uint256,bool)"), case: :lower)
+ topic2 = "0x" <> Base.encode16(:keccakf1600.hash(:sha3_256, "bob"), case: :lower)
+ topic3 = "0x0000000000000000000000000000000000000000000000000000000000000001"
+ data = "0x0000000000000000000000000000000000000000000000000000000000000000"
+
+ transaction = insert(:transaction)
+
+ log =
+ insert(:log,
+ transaction: transaction,
+ first_topic: topic1,
+ second_topic: topic2,
+ third_topic: topic3,
+ fourth_topic: nil,
+ data: data
+ )
+
+ assert Log.decode(log, transaction) ==
+ {:error, :contract_not_verified,
+ [
+ {:ok, "eb9b3c4c", "WantsPets(string indexed _from_human, uint256 _number, bool indexed _belly)",
+ [
+ {"_from_human", "string", true,
+ {:dynamic,
+ <<56, 228, 122, 123, 113, 157, 206, 99, 102, 42, 234, 244, 52, 64, 50, 111, 85, 27, 138, 126,
+ 225, 152, 206, 227, 92, 181, 213, 23, 242, 210, 150, 162>>}},
+ {"_number", "uint256", false, 0},
+ {"_belly", "bool", true, true}
+ ]}
+ ]}
+ end
end
end
diff --git a/apps/explorer/test/explorer/chain/token_transfer_test.exs b/apps/explorer/test/explorer/chain/token_transfer_test.exs
index 5d9608e66b..b388fafcbe 100644
--- a/apps/explorer/test/explorer/chain/token_transfer_test.exs
+++ b/apps/explorer/test/explorer/chain/token_transfer_test.exs
@@ -188,31 +188,6 @@ defmodule Explorer.Chain.TokenTransferTest do
assert Enum.map(results, & &1.token_id) == [last_owner.token_id]
assert Enum.map(results, & &1.to_address_hash) == [last_owner.to_address_hash]
end
-
- test "won't return tokens that aren't uniques" do
- token_contract_address = insert(:contract_address)
- token = insert(:token, contract_address: token_contract_address, type: "ERC-20")
-
- transaction =
- :transaction
- |> insert()
- |> with_block(insert(:block, number: 1))
-
- insert(
- :token_transfer,
- to_address: build(:address),
- transaction: transaction,
- token_contract_address: token_contract_address,
- token: token
- )
-
- results =
- token_contract_address.hash
- |> TokenTransfer.address_to_unique_tokens()
- |> Repo.all()
-
- assert results == []
- end
end
describe "where_any_address_fields_match/3" do