{"action":"created","comment":{"url":"https://api.github.com/repos/poanetwork/blockscout/pulls/comments/301177268","pull_request_review_id":258973739,"id":301177268,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMwMTE3NzI2OA==","diff_hunk":"@@ -0,0 +1,117 @@\n+import $ from 'jquery'\n+import { createStore, connectElements } from '../lib/redux_helpers.js'\n+import Web3 from 'web3'\n+\n+export const initialState = {\n+  web3: null,\n+  user: null\n+}\n+\n+export function reducer (state = initialState, action) {\n+  switch (action.type) {\n+    case 'WEB3_DETECTED': {\n+      return Object.assign({}, state, { web3: action.web3 })\n+    }\n+    case 'UPDATE_USER': {\n+      console.log(action.user)\n+      return Object.assign({}, state, { user: action.user })\n+    }\n+    default:\n+      return state\n+  }\n+}\n+\n+const elements = {\n+  '[data-selector=\"login-button\"]': {\n+    load ($el) {\n+      $el.on('click', redirectToMetamask)\n+    },\n+    render ($el, state, oldState) {\n+      if (oldState.web3 === state.web3) return\n+      $el.unbind('click')\n+      $el.on('click', state.web3 ? loginByMetamask : redirectToMetamask)\n+    }\n+  },\n+  '[data-async-load]': {\n+    load ($el) {\n+      return {\n+        accountPath: $el.data('async-listing')\n+      }\n+    }\n+  },\n+  '[data-selector=\"stakes-top\"]': {\n+    render ($el, state, oldState) {\n+      if (state.user === oldState.user) return\n+      $.getJSON(state.accountPath, {type: 'JSON', template: 'top'})","path":"apps/block_scout_web/assets/js/pages/stakes.js","position":45,"original_position":45,"commit_id":"a755ed063148c46b966abca33e6aa7750a45a2b5","original_commit_id":"a755ed063148c46b966abca33e6aa7750a45a2b5","user":{"login":"goodsoft","id":2828228,"node_id":"MDQ6VXNlcjI4MjgyMjg=","avatar_url":"https://avatars2.githubusercontent.com/u/2828228?v=4","gravatar_id":"","url":"https://api.github.com/users/goodsoft","html_url":"https://github.com/goodsoft","followers_url":"https://api.github.com/users/goodsoft/followers","following_url":"https://api.github.com/users/goodsoft/following{/other_user}","gists_url":"https://api.github.com/users/goodsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/goodsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goodsoft/subscriptions","organizations_url":"https://api.github.com/users/goodsoft/orgs","repos_url":"https://api.github.com/users/goodsoft/repos","events_url":"https://api.github.com/users/goodsoft/events{/privacy}","received_events_url":"https://api.github.com/users/goodsoft/received_events","type":"User","site_admin":false},"body":"Asynchronous network requests in a function named `render` set off an alarm in my head. :rotating_light: :rotating_light: :rotating_light: \r\nI'm not familiar with how Redux works, but that seems kinda wrong to me.\r\n\r\nAlso, I don't understand the purpose and mechanics of `accountPath` field in `state`.\r\nIt is not even defined in `initialState`.","created_at":"2019-07-08T16:05:18Z","updated_at":"2019-07-08T16:06:39Z","html_url":"https://github.com/poanetwork/blockscout/pull/2220#discussion_r301177268","pull_request_url":"https://api.github.com/repos/poanetwork/blockscout/pulls/2220","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/poanetwork/blockscout/pulls/comments/301177268"},"html":{"href":"https://github.com/poanetwork/blockscout/pull/2220#discussion_r301177268"},"pull_request":{"href":"https://api.github.com/repos/poanetwork/blockscout/pulls/2220"}}},"pull_request":{"url":"https://api.github.com/repos/poanetwork/blockscout/pulls/2220","id":290823630,"node_id":"MDExOlB1bGxSZXF1ZXN0MjkwODIzNjMw","html_url":"https://github.com/poanetwork/blockscout/pull/2220","diff_url":"https://github.com/poanetwork/blockscout/pull/2220.diff","patch_url":"https://github.com/poanetwork/blockscout/pull/2220.patch","issue_url":"https://api.github.com/repos/poanetwork/blockscout/issues/2220","number":2220,"state":"open","locked":false,"title":"Add async login and logout by MetaMask","user":{"login":"saneery","id":11743366,"node_id":"MDQ6VXNlcjExNzQzMzY2","avatar_url":"https://avatars1.githubusercontent.com/u/11743366?v=4","gravatar_id":"","url":"https://api.github.com/users/saneery","html_url":"https://github.com/saneery","followers_url":"https://api.github.com/users/saneery/followers","following_url":"https://api.github.com/users/saneery/following{/other_user}","gists_url":"https://api.github.com/users/saneery/gists{/gist_id}","starred_url":"https://api.github.com/users/saneery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saneery/subscriptions","organizations_url":"https://api.github.com/users/saneery/orgs","repos_url":"https://api.github.com/users/saneery/repos","events_url":"https://api.github.com/users/saneery/events{/privacy}","received_events_url":"https://api.github.com/users/saneery/received_events","type":"User","site_admin":false},"body":"#1709\r\n**Merge after [PR#2215](https://github.com/poanetwork/blockscout/pull/2215)**\r\n\r\nAdd async login and logout by MetaMask\r\n\r\n## Changelog\r\n\r\n* Add web3.js in dependencies\r\n* Login by MetaMask\r\n* Async update top navbar with a user data on change account or logout","created_at":"2019-06-22T13:28:01Z","updated_at":"2019-07-08T16:06:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e36ea26763d4afe715efd8a3cfbd059ed891029f","assignee":null,"assignees":[],"requested_reviewers":[{"login":"Heimdell","id":1784505,"node_id":"MDQ6VXNlcjE3ODQ1MDU=","avatar_url":"https://avatars3.githubusercontent.com/u/1784505?v=4","gravatar_id":"","url":"https://api.github.com/users/Heimdell","html_url":"https://github.com/Heimdell","followers_url":"https://api.github.com/users/Heimdell/followers","following_url":"https://api.github.com/users/Heimdell/following{/other_user}","gists_url":"https://api.github.com/users/Heimdell/gists{/gist_id}","starred_url":"https://api.github.com/users/Heimdell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Heimdell/subscriptions","organizations_url":"https://api.github.com/users/Heimdell/orgs","repos_url":"https://api.github.com/users/Heimdell/repos","events_url":"https://api.github.com/users/Heimdell/events{/privacy}","received_events_url":"https://api.github.com/users/Heimdell/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":1416880636,"node_id":"MDU6TGFiZWwxNDE2ODgwNjM2","url":"https://api.github.com/repos/poanetwork/blockscout/labels/chain:%20POSDAO%20:chains:","name":"chain: POSDAO :chains:","color":"dd77ac","default":false},{"id":1320319080,"node_id":"MDU6TGFiZWwxMzIwMzE5MDgw","url":"https://api.github.com/repos/poanetwork/blockscout/labels/do%20not%20merge","name":"do not merge","color":"ee0701","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/poanetwork/blockscout/pulls/2220/commits","review_comments_url":"https://api.github.com/repos/poanetwork/blockscout/pulls/2220/comments","review_comment_url":"https://api.github.com/repos/poanetwork/blockscout/pulls/comments{/number}","comments_url":"https://api.github.com/repos/poanetwork/blockscout/issues/2220/comments","statuses_url":"https://api.github.com/repos/poanetwork/blockscout/statuses/a755ed063148c46b966abca33e6aa7750a45a2b5","head":{"label":"poanetwork:login-metamask","ref":"login-metamask","sha":"a755ed063148c46b966abca33e6aa7750a45a2b5","user":{"login":"poanetwork","id":28943015,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTQzMDE1","avatar_url":"https://avatars2.githubusercontent.com/u/28943015?v=4","gravatar_id":"","url":"https://api.github.com/users/poanetwork","html_url":"https://github.com/poanetwork","followers_url":"https://api.github.com/users/poanetwork/followers","following_url":"https://api.github.com/users/poanetwork/following{/other_user}","gists_url":"https://api.github.com/users/poanetwork/gists{/gist_id}","starred_url":"https://api.github.com/users/poanetwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poanetwork/subscriptions","organizations_url":"https://api.github.com/users/poanetwork/orgs","repos_url":"https://api.github.com/users/poanetwork/repos","events_url":"https://api.github.com/users/poanetwork/events{/privacy}","received_events_url":"https://api.github.com/users/poanetwork/received_events","type":"Organization","site_admin":false},"repo":{"id":117294980,"node_id":"MDEwOlJlcG9zaXRvcnkxMTcyOTQ5ODA=","name":"blockscout","full_name":"poanetwork/blockscout","private":false,"owner":{"login":"poanetwork","id":28943015,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTQzMDE1","avatar_url":"https://avatars2.githubusercontent.com/u/28943015?v=4","gravatar_id":"","url":"https://api.github.com/users/poanetwork","html_url":"https://github.com/poanetwork","followers_url":"https://api.github.com/users/poanetwork/followers","following_url":"https://api.github.com/users/poanetwork/following{/other_user}","gists_url":"https://api.github.com/users/poanetwork/gists{/gist_id}","starred_url":"https://api.github.com/users/poanetwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poanetwork/subscriptions","organizations_url":"https://api.github.com/users/poanetwork/orgs","repos_url":"https://api.github.com/users/poanetwork/repos","events_url":"https://api.github.com/users/poanetwork/events{/privacy}","received_events_url":"https://api.github.com/users/poanetwork/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/poanetwork/blockscout","description":"Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains. ","fork":false,"url":"https://api.github.com/repos/poanetwork/blockscout","forks_url":"https://api.github.com/repos/poanetwork/blockscout/forks","keys_url":"https://api.github.com/repos/poanetwork/blockscout/keys{/key_id}","collaborators_url":"https://api.github.com/repos/poanetwork/blockscout/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/poanetwork/blockscout/teams","hooks_url":"https://api.github.com/repos/poanetwork/blockscout/hooks","issue_events_url":"https://api.github.com/repos/poanetwork/blockscout/issues/events{/number}","events_url":"https://api.github.com/repos/poanetwork/blockscout/events","assignees_url":"https://api.github.com/repos/poanetwork/blockscout/assignees{/user}","branches_url":"https://api.github.com/repos/poanetwork/blockscout/branches{/branch}","tags_url":"https://api.github.com/repos/poanetwork/blockscout/tags","blobs_url":"https://api.github.com/repos/poanetwork/blockscout/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/poanetwork/blockscout/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/poanetwork/blockscout/git/refs{/sha}","trees_url":"https://api.github.com/repos/poanetwork/blockscout/git/trees{/sha}","statuses_url":"https://api.github.com/repos/poanetwork/blockscout/statuses/{sha}","languages_url":"https://api.github.com/repos/poanetwork/blockscout/languages","stargazers_url":"https://api.github.com/repos/poanetwork/blockscout/stargazers","contributors_url":"https://api.github.com/repos/poanetwork/blockscout/contributors","subscribers_url":"https://api.github.com/repos/poanetwork/blockscout/subscribers","subscription_url":"https://api.github.com/repos/poanetwork/blockscout/subscription","commits_url":"https://api.github.com/repos/poanetwork/blockscout/commits{/sha}","git_commits_url":"https://api.github.com/repos/poanetwork/blockscout/git/commits{/sha}","comments_url":"https://api.github.com/repos/poanetwork/blockscout/comments{/number}","issue_comment_url":"https://api.github.com/repos/poanetwork/blockscout/issues/comments{/number}","contents_url":"https://api.github.com/repos/poanetwork/blockscout/contents/{+path}","compare_url":"https://api.github.com/repos/poanetwork/blockscout/compare/{base}...{head}","merges_url":"https://api.github.com/repos/poanetwork/blockscout/merges","archive_url":"https://api.github.com/repos/poanetwork/blockscout/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/poanetwork/blockscout/downloads","issues_url":"https://api.github.com/repos/poanetwork/blockscout/issues{/number}","pulls_url":"https://api.github.com/repos/poanetwork/blockscout/pulls{/number}","milestones_url":"https://api.github.com/repos/poanetwork/blockscout/milestones{/number}","notifications_url":"https://api.github.com/repos/poanetwork/blockscout/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/poanetwork/blockscout/labels{/name}","releases_url":"https://api.github.com/repos/poanetwork/blockscout/releases{/id}","deployments_url":"https://api.github.com/repos/poanetwork/blockscout/deployments","created_at":"2018-01-12T22:45:24Z","updated_at":"2019-07-08T08:14:32Z","pushed_at":"2019-07-08T15:01:19Z","git_url":"git://github.com/poanetwork/blockscout.git","ssh_url":"git@github.com:poanetwork/blockscout.git","clone_url":"https://github.com/poanetwork/blockscout.git","svn_url":"https://github.com/poanetwork/blockscout","homepage":"https://blockscout.com","size":26976,"stargazers_count":583,"watchers_count":583,"language":"Elixir","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":208,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":179,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":208,"open_issues":179,"watchers":583,"default_branch":"master"}},"base":{"label":"poanetwork:staking","ref":"staking","sha":"d206b3ece91b3ca6c329e640b83fe8e39573210a","user":{"login":"poanetwork","id":28943015,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTQzMDE1","avatar_url":"https://avatars2.githubusercontent.com/u/28943015?v=4","gravatar_id":"","url":"https://api.github.com/users/poanetwork","html_url":"https://github.com/poanetwork","followers_url":"https://api.github.com/users/poanetwork/followers","following_url":"https://api.github.com/users/poanetwork/following{/other_user}","gists_url":"https://api.github.com/users/poanetwork/gists{/gist_id}","starred_url":"https://api.github.com/users/poanetwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poanetwork/subscriptions","organizations_url":"https://api.github.com/users/poanetwork/orgs","repos_url":"https://api.github.com/users/poanetwork/repos","events_url":"https://api.github.com/users/poanetwork/events{/privacy}","received_events_url":"https://api.github.com/users/poanetwork/received_events","type":"Organization","site_admin":false},"repo":{"id":117294980,"node_id":"MDEwOlJlcG9zaXRvcnkxMTcyOTQ5ODA=","name":"blockscout","full_name":"poanetwork/blockscout","private":false,"owner":{"login":"poanetwork","id":28943015,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTQzMDE1","avatar_url":"https://avatars2.githubusercontent.com/u/28943015?v=4","gravatar_id":"","url":"https://api.github.com/users/poanetwork","html_url":"https://github.com/poanetwork","followers_url":"https://api.github.com/users/poanetwork/followers","following_url":"https://api.github.com/users/poanetwork/following{/other_user}","gists_url":"https://api.github.com/users/poanetwork/gists{/gist_id}","starred_url":"https://api.github.com/users/poanetwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poanetwork/subscriptions","organizations_url":"https://api.github.com/users/poanetwork/orgs","repos_url":"https://api.github.com/users/poanetwork/repos","events_url":"https://api.github.com/users/poanetwork/events{/privacy}","received_events_url":"https://api.github.com/users/poanetwork/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/poanetwork/blockscout","description":"Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains. ","fork":false,"url":"https://api.github.com/repos/poanetwork/blockscout","forks_url":"https://api.github.com/repos/poanetwork/blockscout/forks","keys_url":"https://api.github.com/repos/poanetwork/blockscout/keys{/key_id}","collaborators_url":"https://api.github.com/repos/poanetwork/blockscout/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/poanetwork/blockscout/teams","hooks_url":"https://api.github.com/repos/poanetwork/blockscout/hooks","issue_events_url":"https://api.github.com/repos/poanetwork/blockscout/issues/events{/number}","events_url":"https://api.github.com/repos/poanetwork/blockscout/events","assignees_url":"https://api.github.com/repos/poanetwork/blockscout/assignees{/user}","branches_url":"https://api.github.com/repos/poanetwork/blockscout/branches{/branch}","tags_url":"https://api.github.com/repos/poanetwork/blockscout/tags","blobs_url":"https://api.github.com/repos/poanetwork/blockscout/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/poanetwork/blockscout/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/poanetwork/blockscout/git/refs{/sha}","trees_url":"https://api.github.com/repos/poanetwork/blockscout/git/trees{/sha}","statuses_url":"https://api.github.com/repos/poanetwork/blockscout/statuses/{sha}","languages_url":"https://api.github.com/repos/poanetwork/blockscout/languages","stargazers_url":"https://api.github.com/repos/poanetwork/blockscout/stargazers","contributors_url":"https://api.github.com/repos/poanetwork/blockscout/contributors","subscribers_url":"https://api.github.com/repos/poanetwork/blockscout/subscribers","subscription_url":"https://api.github.com/repos/poanetwork/blockscout/subscription","commits_url":"https://api.github.com/repos/poanetwork/blockscout/commits{/sha}","git_commits_url":"https://api.github.com/repos/poanetwork/blockscout/git/commits{/sha}","comments_url":"https://api.github.com/repos/poanetwork/blockscout/comments{/number}","issue_comment_url":"https://api.github.com/repos/poanetwork/blockscout/issues/comments{/number}","contents_url":"https://api.github.com/repos/poanetwork/blockscout/contents/{+path}","compare_url":"https://api.github.com/repos/poanetwork/blockscout/compare/{base}...{head}","merges_url":"https://api.github.com/repos/poanetwork/blockscout/merges","archive_url":"https://api.github.com/repos/poanetwork/blockscout/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/poanetwork/blockscout/downloads","issues_url":"https://api.github.com/repos/poanetwork/blockscout/issues{/number}","pulls_url":"https://api.github.com/repos/poanetwork/blockscout/pulls{/number}","milestones_url":"https://api.github.com/repos/poanetwork/blockscout/milestones{/number}","notifications_url":"https://api.github.com/repos/poanetwork/blockscout/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/poanetwork/blockscout/labels{/name}","releases_url":"https://api.github.com/repos/poanetwork/blockscout/releases{/id}","deployments_url":"https://api.github.com/repos/poanetwork/blockscout/deployments","created_at":"2018-01-12T22:45:24Z","updated_at":"2019-07-08T08:14:32Z","pushed_at":"2019-07-08T15:01:19Z","git_url":"git://github.com/poanetwork/blockscout.git","ssh_url":"git@github.com:poanetwork/blockscout.git","clone_url":"https://github.com/poanetwork/blockscout.git","svn_url":"https://github.com/poanetwork/blockscout","homepage":"https://blockscout.com","size":26976,"stargazers_count":583,"watchers_count":583,"language":"Elixir","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":208,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":179,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":208,"open_issues":179,"watchers":583,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/poanetwork/blockscout/pulls/2220"},"html":{"href":"https://github.com/poanetwork/blockscout/pull/2220"},"issue":{"href":"https://api.github.com/repos/poanetwork/blockscout/issues/2220"},"comments":{"href":"https://api.github.com/repos/poanetwork/blockscout/issues/2220/comments"},"review_comments":{"href":"https://api.github.com/repos/poanetwork/blockscout/pulls/2220/comments"},"review_comment":{"href":"https://api.github.com/repos/poanetwork/blockscout/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/poanetwork/blockscout/pulls/2220/commits"},"statuses":{"href":"https://api.github.com/repos/poanetwork/blockscout/statuses/a755ed063148c46b966abca33e6aa7750a45a2b5"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"goodsoft"}}