Merge branch 'master' into ab-use-coin-gecko

pull/2610/head
Ayrat Badykov 5 years ago committed by GitHub
commit d429c2d8f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CHANGELOG.md
  2. 230
      apps/block_scout_web/assets/package-lock.json
  3. 2
      apps/block_scout_web/assets/package.json
  4. 5
      apps/block_scout_web/lib/block_scout_web/etherscan.ex
  5. 3
      apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex
  6. 35
      apps/block_scout_web/test/block_scout_web/controllers/api/rpc/address_controller_test.exs
  7. 12
      apps/explorer/lib/explorer/etherscan.ex
  8. 97
      apps/explorer/test/explorer/etherscan_test.exs
  9. 4
      apps/indexer/lib/indexer/block/fetcher.ex

@ -8,6 +8,7 @@
### Fixes ### Fixes
- [#2610](https://github.com/poanetwork/blockscout/pull/2610) - use CoinGecko instead of CoinMarketcap for exchange rates - [#2610](https://github.com/poanetwork/blockscout/pull/2610) - use CoinGecko instead of CoinMarketcap for exchange rates
- [#2613](https://github.com/poanetwork/blockscout/pull/2613) - fix getminedblocks rpc endpoint
- [#2592](https://github.com/poanetwork/blockscout/pull/2592) - process new metadata format for whisper - [#2592](https://github.com/poanetwork/blockscout/pull/2592) - process new metadata format for whisper
- [#2572](https://github.com/poanetwork/blockscout/pull/2572) - Ease non-critical css - [#2572](https://github.com/poanetwork/blockscout/pull/2572) - Ease non-critical css
- [#2570](https://github.com/poanetwork/blockscout/pull/2570) - Network icons preload - [#2570](https://github.com/poanetwork/blockscout/pull/2570) - Network icons preload
@ -18,6 +19,8 @@
- [#2538](https://github.com/poanetwork/blockscout/pull/2538) - fetch the last not empty coin balance records - [#2538](https://github.com/poanetwork/blockscout/pull/2538) - fetch the last not empty coin balance records
### Chore ### Chore
- [#2611](https://github.com/poanetwork/blockscout/pull/2611) - fix js dependency vulnerabilities
- [#2617](https://github.com/poanetwork/blockscout/pull/2617) - skip cache update if there are no blocks inserted
- [#2594](https://github.com/poanetwork/blockscout/pull/2594) - do not start genesis data fetching periodically - [#2594](https://github.com/poanetwork/blockscout/pull/2594) - do not start genesis data fetching periodically
- [#2590](https://github.com/poanetwork/blockscout/pull/2590) - restore backward compatablity with old releases - [#2590](https://github.com/poanetwork/blockscout/pull/2590) - restore backward compatablity with old releases
- [#2574](https://github.com/poanetwork/blockscout/pull/2574) - limit request body in json rpc error - [#2574](https://github.com/poanetwork/blockscout/pull/2574) - limit request body in json rpc error

@ -2678,8 +2678,7 @@
"esprima": { "esprima": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
"dev": true
}, },
"is-svg": { "is-svg": {
"version": "3.0.0", "version": "3.0.0",
@ -2690,16 +2689,6 @@
"html-comment-regex": "^1.1.0" "html-comment-regex": "^1.1.0"
} }
}, },
"js-yaml": {
"version": "3.13.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
},
"mdn-data": { "mdn-data": {
"version": "1.1.4", "version": "1.1.4",
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-1.1.4.tgz", "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-1.1.4.tgz",
@ -3638,8 +3627,7 @@
"esprima": { "esprima": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw=="
"dev": true
}, },
"globals": { "globals": {
"version": "11.7.0", "version": "11.7.0",
@ -3647,16 +3635,6 @@
"integrity": "sha512-K8BNSPySfeShBQXsahYB/AbbWruVOTyVpgoIDnl8odPpeSfP2J5QO2oLFFdl2j7GfDCtZj2bMKar2T49itTPCg==", "integrity": "sha512-K8BNSPySfeShBQXsahYB/AbbWruVOTyVpgoIDnl8odPpeSfP2J5QO2oLFFdl2j7GfDCtZj2bMKar2T49itTPCg==",
"dev": true "dev": true
}, },
"js-yaml": {
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz",
"integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
},
"strip-ansi": { "strip-ansi": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
@ -3812,12 +3790,6 @@
"acorn-jsx": "^3.0.0" "acorn-jsx": "^3.0.0"
} }
}, },
"esprima": {
"version": "2.7.3",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz",
"integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=",
"dev": true
},
"esquery": { "esquery": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz",
@ -3980,9 +3952,9 @@
} }
}, },
"extend": { "extend": {
"version": "3.0.1", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
"dev": true "dev": true
}, },
"extend-shallow": { "extend-shallow": {
@ -4293,6 +4265,16 @@
"readable-stream": "^2.0.0" "readable-stream": "^2.0.0"
} }
}, },
"fs-minipass": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz",
"integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==",
"dev": true,
"optional": true,
"requires": {
"minipass": "^2.2.1"
}
},
"fs-write-stream-atomic": { "fs-write-stream-atomic": {
"version": "1.0.10", "version": "1.0.10",
"resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz",
@ -4375,9 +4357,7 @@
"chownr": { "chownr": {
"version": "1.0.1", "version": "1.0.1",
"resolved": false, "resolved": false,
"integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE=", "integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE="
"dev": true,
"optional": true
}, },
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
@ -4442,8 +4422,6 @@
"version": "1.2.5", "version": "1.2.5",
"resolved": false, "resolved": false,
"integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==",
"dev": true,
"optional": true,
"requires": { "requires": {
"minipass": "^2.2.1" "minipass": "^2.2.1"
} }
@ -4577,7 +4555,6 @@
"version": "2.2.4", "version": "2.2.4",
"resolved": false, "resolved": false,
"integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
"dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
@ -4588,8 +4565,6 @@
"version": "1.1.0", "version": "1.1.0",
"resolved": false, "resolved": false,
"integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==", "integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==",
"dev": true,
"optional": true,
"requires": { "requires": {
"minipass": "^2.2.1" "minipass": "^2.2.1"
} }
@ -4799,7 +4774,6 @@
"version": "5.1.1", "version": "5.1.1",
"resolved": false, "resolved": false,
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
"dev": true,
"optional": true "optional": true
}, },
"safer-buffer": { "safer-buffer": {
@ -4876,22 +4850,6 @@
"dev": true, "dev": true,
"optional": true "optional": true
}, },
"tar": {
"version": "4.4.1",
"resolved": false,
"integrity": "sha512-O+v1r9yN4tOsvl90p5HAP4AEqbYhx4036AGMm075fH9F8Qwi3oJ+v4u50FkT/KkvywNGtwkk0zRI+8eYm1X/xg==",
"dev": true,
"optional": true,
"requires": {
"chownr": "^1.0.1",
"fs-minipass": "^1.2.5",
"minipass": "^2.2.4",
"minizlib": "^1.1.0",
"mkdirp": "^0.5.0",
"safe-buffer": "^5.1.1",
"yallist": "^3.0.2"
}
},
"util-deprecate": { "util-deprecate": {
"version": "1.0.2", "version": "1.0.2",
"resolved": false, "resolved": false,
@ -4920,15 +4878,14 @@
"version": "3.0.2", "version": "3.0.2",
"resolved": false, "resolved": false,
"integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=",
"dev": true,
"optional": true "optional": true
} }
} }
}, },
"fstream": { "fstream": {
"version": "1.0.11", "version": "1.0.12",
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz",
"integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==",
"dev": true, "dev": true,
"requires": { "requires": {
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",
@ -5158,15 +5115,23 @@
"dev": true "dev": true
}, },
"handlebars": { "handlebars": {
"version": "4.0.12", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.12.tgz", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz",
"integrity": "sha512-RhmTekP+FZL+XNhwS1Wf+bTTZpdLougwt5pcgA1tuz6Jcx0fpH/7z0qd71RKnZHBCxIRBHfBOnio4gViPemNzA==", "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==",
"dev": true, "dev": true,
"requires": { "requires": {
"async": "^2.5.0", "neo-async": "^2.6.0",
"optimist": "^0.6.1", "optimist": "^0.6.1",
"source-map": "^0.6.1", "source-map": "^0.6.1",
"uglify-js": "^3.1.4" "uglify-js": "^3.1.4"
},
"dependencies": {
"neo-async": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz",
"integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==",
"dev": true
}
} }
}, },
"har-schema": { "har-schema": {
@ -6024,7 +5989,7 @@
}, },
"callsites": { "callsites": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "http://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz",
"integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=", "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=",
"dev": true "dev": true
}, },
@ -6226,7 +6191,7 @@
}, },
"jest-get-type": { "jest-get-type": {
"version": "22.4.3", "version": "22.4.3",
"resolved": "http://registry.npmjs.org/jest-get-type/-/jest-get-type-22.4.3.tgz", "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-22.4.3.tgz",
"integrity": "sha512-/jsz0Y+V29w1chdXVygEKSz2nBoHoYqNShPe+QgxSNjAuP1i8+k4LbQNrfoliKej0P45sivkSCh7yiD6ubHS3w==", "integrity": "sha512-/jsz0Y+V29w1chdXVygEKSz2nBoHoYqNShPe+QgxSNjAuP1i8+k4LbQNrfoliKej0P45sivkSCh7yiD6ubHS3w==",
"dev": true "dev": true
}, },
@ -6774,13 +6739,21 @@
"integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls="
}, },
"js-yaml": { "js-yaml": {
"version": "3.7.0", "version": "3.13.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.7.0.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
"integrity": "sha1-XJZ93YN6m/3KXy3oQlOr6KHAO4A=", "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"dev": true, "dev": true,
"requires": { "requires": {
"argparse": "^1.0.7", "argparse": "^1.0.7",
"esprima": "^2.6.0" "esprima": "^4.0.0"
},
"dependencies": {
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"dev": true
}
} }
}, },
"jsbn": { "jsbn": {
@ -6988,9 +6961,9 @@
} }
}, },
"lodash": { "lodash": {
"version": "4.17.11", "version": "4.17.13",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.13.tgz",
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" "integrity": "sha512-vm3/XWXfWtRua0FkUyEHBZy8kCPjErNBT9fJx8Zvs+U6zjqPbTUOpkaoum3O5uiA8sm+yNMHXfYkTUHFoMxFNA=="
}, },
"lodash.assign": { "lodash.assign": {
"version": "4.2.0", "version": "4.2.0",
@ -7017,9 +6990,9 @@
"dev": true "dev": true
}, },
"lodash.mergewith": { "lodash.mergewith": {
"version": "4.6.1", "version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz", "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz",
"integrity": "sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ==", "integrity": "sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==",
"dev": true "dev": true
}, },
"lodash.sortby": { "lodash.sortby": {
@ -7422,6 +7395,36 @@
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true "dev": true
}, },
"minipass": {
"version": "2.3.5",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz",
"integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==",
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
},
"dependencies": {
"yallist": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz",
"integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==",
"dev": true,
"optional": true
}
}
},
"minizlib": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz",
"integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==",
"dev": true,
"optional": true,
"requires": {
"minipass": "^2.2.1"
}
},
"mississippi": { "mississippi": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/mississippi/-/mississippi-2.0.0.tgz", "resolved": "https://registry.npmjs.org/mississippi/-/mississippi-2.0.0.tgz",
@ -7608,6 +7611,31 @@
"resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
"integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=",
"dev": true "dev": true
},
"tar": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz",
"integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==",
"dev": true,
"requires": {
"block-stream": "*",
"fstream": "^1.0.12",
"inherits": "2"
},
"dependencies": {
"fstream": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz",
"integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
"inherits": "~2.0.0",
"mkdirp": ">=0.5 0",
"rimraf": "2"
}
}
}
} }
} }
}, },
@ -8026,18 +8054,7 @@
"esprima": { "esprima": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
"dev": true
},
"js-yaml": {
"version": "3.13.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
}, },
"parse-json": { "parse-json": {
"version": "4.0.0", "version": "4.0.0",
@ -10720,14 +10737,35 @@
"dev": true "dev": true
}, },
"tar": { "tar": {
"version": "2.2.1", "version": "4.4.10",
"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.10.tgz",
"integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", "integrity": "sha512-g2SVs5QIxvo6OLp0GudTqEf05maawKUxXru104iaayWA09551tFCTI8f1Asb4lPfkBr91k07iL4c11XO3/b0tA==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"block-stream": "*", "chownr": "^1.1.1",
"fstream": "^1.0.2", "fs-minipass": "^1.2.5",
"inherits": "2" "minipass": "^2.3.5",
"minizlib": "^1.2.1",
"mkdirp": "^0.5.0",
"safe-buffer": "^5.1.2",
"yallist": "^3.0.3"
},
"dependencies": {
"chownr": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.2.tgz",
"integrity": "sha512-GkfeAQh+QNy3wquu9oIZr6SS5x7wGdSgNQvD10X3r+AZr1Oys22HW8kAmDMvNg2+Dm0TeGaEuO8gFwdBXxwO8A==",
"dev": true,
"optional": true
},
"yallist": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz",
"integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==",
"dev": true,
"optional": true
}
} }
}, },
"terser": { "terser": {

@ -30,7 +30,7 @@
"highlightjs-solidity": "^1.0.6", "highlightjs-solidity": "^1.0.6",
"humps": "^2.0.1", "humps": "^2.0.1",
"jquery": "^3.3.1", "jquery": "^3.3.1",
"lodash": "^4.17.11", "lodash": "^4.17.13",
"moment": "^2.22.1", "moment": "^2.22.1",
"nanomorph": "^5.1.3", "nanomorph": "^5.1.3",
"numeral": "^2.0.6", "numeral": "^2.0.6",

@ -713,11 +713,6 @@ defmodule BlockScoutWeb.Etherscan do
type: "timestamp", type: "timestamp",
definition: "When the block was collated.", definition: "When the block was collated.",
example: ~s("1480072029") example: ~s("1480072029")
},
blockReward: %{
type: "block reward",
definition: "The reward given to the miner of a block.",
example: ~s("5003251945421042780")
} }
} }
} }

@ -157,8 +157,7 @@ defmodule BlockScoutWeb.API.RPC.AddressView do
defp prepare_block(block) do defp prepare_block(block) do
%{ %{
"blockNumber" => to_string(block.number), "blockNumber" => to_string(block.number),
"timeStamp" => to_string(block.timestamp), "timeStamp" => to_string(block.timestamp)
"blockReward" => to_string(block.reward.value)
} }
end end

@ -2266,7 +2266,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
end end
test "returns all the required fields", %{conn: conn} do test "returns all the required fields", %{conn: conn} do
%{block_range: range} = emission_reward = insert(:emission_reward) %{block_range: range} = insert(:emission_reward)
block = insert(:block, number: Enum.random(Range.new(range.from, range.to))) block = insert(:block, number: Enum.random(Range.new(range.from, range.to)))
@ -2274,17 +2274,10 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
|> insert(gas_price: 1) |> insert(gas_price: 1)
|> with_block(block, gas_used: 1) |> with_block(block, gas_used: 1)
expected_reward =
emission_reward.reward
|> Wei.to(:wei)
|> Decimal.add(Decimal.new(1))
|> Wei.from(:wei)
expected_result = [ expected_result = [
%{ %{
"blockNumber" => to_string(block.number), "blockNumber" => to_string(block.number),
"timeStamp" => to_string(block.timestamp), "timeStamp" => to_string(block.timestamp)
"blockReward" => to_string(expected_reward.value)
} }
] ]
@ -2306,7 +2299,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
end end
test "with a block with one transaction", %{conn: conn} do test "with a block with one transaction", %{conn: conn} do
%{block_range: range} = emission_reward = insert(:emission_reward) %{block_range: range} = insert(:emission_reward)
block = insert(:block, number: Enum.random(Range.new(range.from, range.to))) block = insert(:block, number: Enum.random(Range.new(range.from, range.to)))
@ -2314,12 +2307,6 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
|> insert(gas_price: 1) |> insert(gas_price: 1)
|> with_block(block, gas_used: 1) |> with_block(block, gas_used: 1)
expected_reward =
emission_reward.reward
|> Wei.to(:wei)
|> Decimal.add(Decimal.new(1))
|> Wei.from(:wei)
params = %{ params = %{
"module" => "account", "module" => "account",
"action" => "getminedblocks", "action" => "getminedblocks",
@ -2329,8 +2316,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
expected_result = [ expected_result = [
%{ %{
"blockNumber" => to_string(block.number), "blockNumber" => to_string(block.number),
"timeStamp" => to_string(block.timestamp), "timeStamp" => to_string(block.timestamp)
"blockReward" => to_string(expected_reward.value)
} }
] ]
@ -2346,7 +2332,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
end end
test "with pagination options", %{conn: conn} do test "with pagination options", %{conn: conn} do
%{block_range: range} = emission_reward = insert(:emission_reward) %{block_range: range} = insert(:emission_reward)
block_numbers = Range.new(range.from, range.to) block_numbers = Range.new(range.from, range.to)
@ -2361,12 +2347,6 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
|> insert(gas_price: 2) |> insert(gas_price: 2)
|> with_block(block2, gas_used: 2) |> with_block(block2, gas_used: 2)
expected_reward =
emission_reward.reward
|> Wei.to(:wei)
|> Decimal.add(Decimal.new(4))
|> Wei.from(:wei)
params = %{ params = %{
"module" => "account", "module" => "account",
"action" => "getminedblocks", "action" => "getminedblocks",
@ -2380,8 +2360,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
expected_result = [ expected_result = [
%{ %{
"blockNumber" => to_string(block2.number), "blockNumber" => to_string(block2.number),
"timeStamp" => to_string(block2.timestamp), "timeStamp" => to_string(block2.timestamp)
"blockReward" => to_string(expected_reward.value)
} }
] ]
@ -2683,7 +2662,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
}) })
end end
defp resolve_schema(result \\ %{}) do defp resolve_schema(result) do
%{ %{
"type" => "object", "type" => "object",
"properties" => %{ "properties" => %{

@ -8,8 +8,7 @@ defmodule Explorer.Etherscan do
alias Explorer.Etherscan.Logs alias Explorer.Etherscan.Logs
alias Explorer.{Chain, Repo} alias Explorer.{Chain, Repo}
alias Explorer.Chain.Address.TokenBalance alias Explorer.Chain.Address.TokenBalance
alias Explorer.Chain.{Block, Hash, InternalTransaction, Transaction, Wei} alias Explorer.Chain.{Block, Hash, InternalTransaction, Transaction}
alias Explorer.Chain.Block.EmissionReward
@default_options %{ @default_options %{
order_by_direction: :asc, order_by_direction: :asc,
@ -187,22 +186,15 @@ defmodule Explorer.Etherscan do
query = query =
from( from(
b in Block, b in Block,
left_join: t in assoc(b, :transactions),
inner_join: r in EmissionReward,
on: fragment("? <@ ?", b.number, r.block_range),
where: b.miner_hash == ^address_hash, where: b.miner_hash == ^address_hash,
order_by: [desc: b.number], order_by: [desc: b.number],
group_by: b.number, group_by: b.number,
group_by: b.timestamp, group_by: b.timestamp,
group_by: r.reward,
limit: ^merged_options.page_size, limit: ^merged_options.page_size,
offset: ^offset(merged_options), offset: ^offset(merged_options),
select: %{ select: %{
number: b.number, number: b.number,
timestamp: b.timestamp, timestamp: b.timestamp
reward: %Wei{
value: fragment("coalesce(sum(? * ?), 0) + ?", t.gas_used, t.gas_price, r.reward)
}
} }
) )

@ -4,7 +4,7 @@ defmodule Explorer.EtherscanTest do
import Explorer.Factory import Explorer.Factory
alias Explorer.{Etherscan, Chain} alias Explorer.{Etherscan, Chain}
alias Explorer.Chain.{Transaction, Wei} alias Explorer.Chain.Transaction
describe "list_transactions/2" do describe "list_transactions/2" do
test "with empty db" do test "with empty db" do
@ -1170,7 +1170,7 @@ defmodule Explorer.EtherscanTest do
describe "list_blocks/1" do describe "list_blocks/1" do
test "it returns all required fields" do test "it returns all required fields" do
%{block_range: range} = emission_reward = insert(:emission_reward) %{block_range: range} = insert(:emission_reward)
block = insert(:block, number: Enum.random(Range.new(range.from, range.to))) block = insert(:block, number: Enum.random(Range.new(range.from, range.to)))
@ -1181,17 +1181,10 @@ defmodule Explorer.EtherscanTest do
|> insert(gas_price: 1) |> insert(gas_price: 1)
|> with_block(block, gas_used: 1) |> with_block(block, gas_used: 1)
expected_reward =
emission_reward.reward
|> Wei.to(:wei)
|> Decimal.add(Decimal.new(1))
|> Wei.from(:wei)
expected = [ expected = [
%{ %{
number: block.number, number: block.number,
timestamp: block.timestamp, timestamp: block.timestamp
reward: expected_reward
} }
] ]
@ -1199,32 +1192,14 @@ defmodule Explorer.EtherscanTest do
end end
test "with block containing multiple transactions" do test "with block containing multiple transactions" do
%{block_range: range} = emission_reward = insert(:emission_reward) %{block_range: range} = insert(:emission_reward)
block = insert(:block, number: Enum.random(Range.new(range.from, range.to))) block = insert(:block, number: Enum.random(Range.new(range.from, range.to)))
# irrelevant transaction
insert(:transaction)
:transaction
|> insert(gas_price: 1)
|> with_block(block, gas_used: 1)
:transaction
|> insert(gas_price: 1)
|> with_block(block, gas_used: 2)
expected_reward =
emission_reward.reward
|> Wei.to(:wei)
|> Decimal.add(Decimal.new(3))
|> Wei.from(:wei)
expected = [ expected = [
%{ %{
number: block.number, number: block.number,
timestamp: block.timestamp, timestamp: block.timestamp
reward: expected_reward
} }
] ]
@ -1232,7 +1207,7 @@ defmodule Explorer.EtherscanTest do
end end
test "with block without transactions" do test "with block without transactions" do
%{block_range: range} = emission_reward = insert(:emission_reward) %{block_range: range} = insert(:emission_reward)
block = insert(:block, number: Enum.random(Range.new(range.from, range.to))) block = insert(:block, number: Enum.random(Range.new(range.from, range.to)))
@ -1242,8 +1217,7 @@ defmodule Explorer.EtherscanTest do
expected = [ expected = [
%{ %{
number: block.number, number: block.number,
timestamp: block.timestamp, timestamp: block.timestamp
reward: emission_reward.reward
} }
] ]
@ -1251,7 +1225,7 @@ defmodule Explorer.EtherscanTest do
end end
test "with multiple blocks" do test "with multiple blocks" do
%{block_range: range} = emission_reward = insert(:emission_reward) %{block_range: range} = insert(:emission_reward)
block_numbers = Range.new(range.from, range.to) block_numbers = Range.new(range.from, range.to)
@ -1262,47 +1236,14 @@ defmodule Explorer.EtherscanTest do
block1 = insert(:block, number: block_number1, miner: address) block1 = insert(:block, number: block_number1, miner: address)
block2 = insert(:block, number: block_number2, miner: address) block2 = insert(:block, number: block_number2, miner: address)
# irrelevant transaction
insert(:transaction)
:transaction
|> insert(gas_price: 2)
|> with_block(block1, gas_used: 2)
:transaction
|> insert(gas_price: 2)
|> with_block(block1, gas_used: 2)
:transaction
|> insert(gas_price: 3)
|> with_block(block2, gas_used: 3)
:transaction
|> insert(gas_price: 3)
|> with_block(block2, gas_used: 3)
expected_reward_block1 =
emission_reward.reward
|> Wei.to(:wei)
|> Decimal.add(Decimal.new(8))
|> Wei.from(:wei)
expected_reward_block2 =
emission_reward.reward
|> Wei.to(:wei)
|> Decimal.add(Decimal.new(18))
|> Wei.from(:wei)
expected = [ expected = [
%{ %{
number: block2.number, number: block2.number,
timestamp: block2.timestamp, timestamp: block2.timestamp
reward: expected_reward_block2
}, },
%{ %{
number: block1.number, number: block1.number,
timestamp: block1.timestamp, timestamp: block1.timestamp
reward: expected_reward_block1
} }
] ]
@ -1310,7 +1251,7 @@ defmodule Explorer.EtherscanTest do
end end
test "with pagination options" do test "with pagination options" do
%{block_range: range} = emission_reward = insert(:emission_reward) %{block_range: range} = insert(:emission_reward)
block_numbers = Range.new(range.from, range.to) block_numbers = Range.new(range.from, range.to)
@ -1321,29 +1262,17 @@ defmodule Explorer.EtherscanTest do
block1 = insert(:block, number: block_number1, miner: address) block1 = insert(:block, number: block_number1, miner: address)
block2 = insert(:block, number: block_number2, miner: address) block2 = insert(:block, number: block_number2, miner: address)
:transaction
|> insert(gas_price: 2)
|> with_block(block1, gas_used: 2)
expected_reward =
emission_reward.reward
|> Wei.to(:wei)
|> Decimal.add(Decimal.new(4))
|> Wei.from(:wei)
expected1 = [ expected1 = [
%{ %{
number: block2.number, number: block2.number,
timestamp: block2.timestamp, timestamp: block2.timestamp
reward: emission_reward.reward
} }
] ]
expected2 = [ expected2 = [
%{ %{
number: block1.number, number: block1.number,
timestamp: block1.timestamp, timestamp: block1.timestamp
reward: expected_reward
} }
] ]

@ -183,7 +183,7 @@ defmodule Indexer.Block.Fetcher do
end end
end end
defp update_block_cache(blocks) do defp update_block_cache(blocks) when is_list(blocks) do
max_block = Enum.max_by(blocks, fn block -> block.number end) max_block = Enum.max_by(blocks, fn block -> block.number end)
min_block = Enum.min_by(blocks, fn block -> block.number end) min_block = Enum.min_by(blocks, fn block -> block.number end)
@ -192,6 +192,8 @@ defmodule Indexer.Block.Fetcher do
BlocksCache.update(blocks) BlocksCache.update(blocks)
end end
defp update_block_cache(_), do: :ok
defp update_transactions_cache(transactions) do defp update_transactions_cache(transactions) do
Transactions.update(transactions) Transactions.update(transactions)
end end

Loading…
Cancel
Save