{"action":"created","comment":{"url":"https://api.github.com/repos/gnosis/dex-react/pulls/comments/356507960","pull_request_review_id":330408164,"id":356507960,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDM1NjUwNzk2MA==","diff_hunk":"@@ -15,29 +11,51 @@ function _getImageUrl(tokenAddress?: string): string | undefined {\n export class TokenListApiImpl implements TokenList {\n   public networkIds: number[]\n   private _tokensByNetwork: { [networkId: number]: TokenDetails[] }\n+  private _exchangeApi: ExchangeApi\n \n-  public constructor(networkIds: number[]) {\n+  public constructor(networkIds: number[], exchangeApi: ExchangeApi) {\n     this.networkIds = networkIds\n+    this._exchangeApi = exchangeApi\n \n     // Init the tokens by network\n     this._tokensByNetwork = {}\n     networkIds.forEach(networkId => {\n-      // Get list of tokens\n-      const tokens = getTokensByNetwork(networkId).map(token => {\n-        // Add image to the tokens\n-        return {\n-          ...token,\n-          image: _getImageUrl(token.addressMainnet),\n-        }\n-      })\n-\n-      this._tokensByNetwork[networkId] = tokens\n+      // initial value\n+      this._tokensByNetwork[networkId] = getTokensByNetwork(networkId)\n+      // update async\n+      this.fetchTokenIdsFromExchange(networkId)\n     })\n   }\n \n   public getTokens(networkId: number): TokenDetails[] {\n     return this._tokensByNetwork[networkId] || []\n   }\n+\n+  public async fetchTokenIdsFromExchange(networkId: number): Promise<void> {\n+    // on every call fetch initial list again as tokens previously discarded might have been added to exchange\n+    const tokens = getTokensByNetwork(networkId)","path":"src/api/tokenList/TokenListApiImpl.ts","position":48,"original_position":50,"commit_id":"f0685ba093babd7e8c9dc161fedc01cec09cb0ca","original_commit_id":"0b70552771ce076a5decd99b77587719e88b2730","user":{"login":"anxolin","id":2352112,"node_id":"MDQ6VXNlcjIzNTIxMTI=","avatar_url":"https://avatars2.githubusercontent.com/u/2352112?v=4","gravatar_id":"","url":"https://api.github.com/users/anxolin","html_url":"https://github.com/anxolin","followers_url":"https://api.github.com/users/anxolin/followers","following_url":"https://api.github.com/users/anxolin/following{/other_user}","gists_url":"https://api.github.com/users/anxolin/gists{/gist_id}","starred_url":"https://api.github.com/users/anxolin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anxolin/subscriptions","organizations_url":"https://api.github.com/users/anxolin/orgs","repos_url":"https://api.github.com/users/anxolin/repos","events_url":"https://api.github.com/users/anxolin/events{/privacy}","received_events_url":"https://api.github.com/users/anxolin/received_events","type":"User","site_admin":false},"body":"I opened a discussion to define responsibilities of the layers. Maybe it would help us agree on the best way to organize them.\r\n\r\nI don't think we should have a declarative `updateTokenIdsForNetwork `. In my opinion we should just get the list of tokens from the api providing the id, the API should know for how long we cache the list and abstract this away to the UI (hooks or components). However, if we end up using a repository layer, I would have the cache logic there.\r\n\r\nI have the same opinion for the other question you have. How to deal with \"unknown\" ids. I think we should have a getter in an api/repository that caches:\r\n* forever if the id is known\r\n* 10-30min for example, if the token is unknown. It's fine for me having a delay of some minutes (or make the user REFRESH to get a brand new token :P ) \r\n\r\nPotencially the cache can be even persisted in the browser for future versions if we see a BOOST with that ;) \r\n","created_at":"2019-12-11T10:11:52Z","updated_at":"2019-12-11T10:27:34Z","html_url":"https://github.com/gnosis/dex-react/pull/297#discussion_r356507960","pull_request_url":"https://api.github.com/repos/gnosis/dex-react/pulls/297","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/gnosis/dex-react/pulls/comments/356507960"},"html":{"href":"https://github.com/gnosis/dex-react/pull/297#discussion_r356507960"},"pull_request":{"href":"https://api.github.com/repos/gnosis/dex-react/pulls/297"}},"in_reply_to_id":355940811},"pull_request":{"url":"https://api.github.com/repos/gnosis/dex-react/pulls/297","id":351124345,"node_id":"MDExOlB1bGxSZXF1ZXN0MzUxMTI0MzQ1","html_url":"https://github.com/gnosis/dex-react/pull/297","diff_url":"https://github.com/gnosis/dex-react/pull/297.diff","patch_url":"https://github.com/gnosis/dex-react/pull/297.patch","issue_url":"https://api.github.com/repos/gnosis/dex-react/issues/297","number":297,"state":"open","locked":false,"title":"208/display orders on page","user":{"login":"alfetopito","id":43217,"node_id":"MDQ6VXNlcjQzMjE3","avatar_url":"https://avatars1.githubusercontent.com/u/43217?v=4","gravatar_id":"","url":"https://api.github.com/users/alfetopito","html_url":"https://github.com/alfetopito","followers_url":"https://api.github.com/users/alfetopito/followers","following_url":"https://api.github.com/users/alfetopito/following{/other_user}","gists_url":"https://api.github.com/users/alfetopito/gists{/gist_id}","starred_url":"https://api.github.com/users/alfetopito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alfetopito/subscriptions","organizations_url":"https://api.github.com/users/alfetopito/orgs","repos_url":"https://api.github.com/users/alfetopito/repos","events_url":"https://api.github.com/users/alfetopito/events{/privacy}","received_events_url":"https://api.github.com/users/alfetopito/received_events","type":"User","site_admin":false},"body":"Part of #208 \r\n\r\n---\r\n\r\nThis is a bigger than usual PR:\r\n\r\n- Adding id to AutionElement when decoding encoded order from contract\r\n- Made parameter optional on ExchangeApiMock for testing\r\n- Moved url helper to tokenList\r\n- New method on TokenListApiImpl to update list of tokens according to …\r\n- Adjusting fake order data ids and amounts\r\n- New Util function to convert from batchId to Date\r\n- New constants for thresholds on no limit/no expiration for orders\r\n- Replacing static orders with data from useOrders hook\r\n- Added bignumber.js for calculating prices (decimal big number division)\r\n- Rendering OrderRow with the real order data ","created_at":"2019-12-09T23:24:19Z","updated_at":"2019-12-11T10:27:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c0827e1479c14aef3a50f8826c59a394310b8546","assignee":{"login":"alfetopito","id":43217,"node_id":"MDQ6VXNlcjQzMjE3","avatar_url":"https://avatars1.githubusercontent.com/u/43217?v=4","gravatar_id":"","url":"https://api.github.com/users/alfetopito","html_url":"https://github.com/alfetopito","followers_url":"https://api.github.com/users/alfetopito/followers","following_url":"https://api.github.com/users/alfetopito/following{/other_user}","gists_url":"https://api.github.com/users/alfetopito/gists{/gist_id}","starred_url":"https://api.github.com/users/alfetopito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alfetopito/subscriptions","organizations_url":"https://api.github.com/users/alfetopito/orgs","repos_url":"https://api.github.com/users/alfetopito/repos","events_url":"https://api.github.com/users/alfetopito/events{/privacy}","received_events_url":"https://api.github.com/users/alfetopito/received_events","type":"User","site_admin":false},"assignees":[{"login":"alfetopito","id":43217,"node_id":"MDQ6VXNlcjQzMjE3","avatar_url":"https://avatars1.githubusercontent.com/u/43217?v=4","gravatar_id":"","url":"https://api.github.com/users/alfetopito","html_url":"https://github.com/alfetopito","followers_url":"https://api.github.com/users/alfetopito/followers","following_url":"https://api.github.com/users/alfetopito/following{/other_user}","gists_url":"https://api.github.com/users/alfetopito/gists{/gist_id}","starred_url":"https://api.github.com/users/alfetopito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alfetopito/subscriptions","organizations_url":"https://api.github.com/users/alfetopito/orgs","repos_url":"https://api.github.com/users/alfetopito/repos","events_url":"https://api.github.com/users/alfetopito/events{/privacy}","received_events_url":"https://api.github.com/users/alfetopito/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/gnosis/dex-react/milestones/7","html_url":"https://github.com/gnosis/dex-react/milestone/7","labels_url":"https://api.github.com/repos/gnosis/dex-react/milestones/7/labels","id":4885473,"node_id":"MDk6TWlsZXN0b25lNDg4NTQ3Mw==","number":7,"title":"Sprint 6","description":"","creator":{"login":"anxolin","id":2352112,"node_id":"MDQ6VXNlcjIzNTIxMTI=","avatar_url":"https://avatars2.githubusercontent.com/u/2352112?v=4","gravatar_id":"","url":"https://api.github.com/users/anxolin","html_url":"https://github.com/anxolin","followers_url":"https://api.github.com/users/anxolin/followers","following_url":"https://api.github.com/users/anxolin/following{/other_user}","gists_url":"https://api.github.com/users/anxolin/gists{/gist_id}","starred_url":"https://api.github.com/users/anxolin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anxolin/subscriptions","organizations_url":"https://api.github.com/users/anxolin/orgs","repos_url":"https://api.github.com/users/anxolin/repos","events_url":"https://api.github.com/users/anxolin/events{/privacy}","received_events_url":"https://api.github.com/users/anxolin/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":15,"state":"open","created_at":"2019-11-27T18:03:40Z","updated_at":"2019-12-11T03:25:17Z","due_on":"2019-12-11T08:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/gnosis/dex-react/pulls/297/commits","review_comments_url":"https://api.github.com/repos/gnosis/dex-react/pulls/297/comments","review_comment_url":"https://api.github.com/repos/gnosis/dex-react/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gnosis/dex-react/issues/297/comments","statuses_url":"https://api.github.com/repos/gnosis/dex-react/statuses/f0685ba093babd7e8c9dc161fedc01cec09cb0ca","head":{"label":"gnosis:208/display-orders-on-page","ref":"208/display-orders-on-page","sha":"f0685ba093babd7e8c9dc161fedc01cec09cb0ca","user":{"login":"gnosis","id":24954468,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0OTU0NDY4","avatar_url":"https://avatars1.githubusercontent.com/u/24954468?v=4","gravatar_id":"","url":"https://api.github.com/users/gnosis","html_url":"https://github.com/gnosis","followers_url":"https://api.github.com/users/gnosis/followers","following_url":"https://api.github.com/users/gnosis/following{/other_user}","gists_url":"https://api.github.com/users/gnosis/gists{/gist_id}","starred_url":"https://api.github.com/users/gnosis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnosis/subscriptions","organizations_url":"https://api.github.com/users/gnosis/orgs","repos_url":"https://api.github.com/users/gnosis/repos","events_url":"https://api.github.com/users/gnosis/events{/privacy}","received_events_url":"https://api.github.com/users/gnosis/received_events","type":"Organization","site_admin":false},"repo":{"id":200027889,"node_id":"MDEwOlJlcG9zaXRvcnkyMDAwMjc4ODk=","name":"dex-react","full_name":"gnosis/dex-react","private":false,"owner":{"login":"gnosis","id":24954468,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0OTU0NDY4","avatar_url":"https://avatars1.githubusercontent.com/u/24954468?v=4","gravatar_id":"","url":"https://api.github.com/users/gnosis","html_url":"https://github.com/gnosis","followers_url":"https://api.github.com/users/gnosis/followers","following_url":"https://api.github.com/users/gnosis/following{/other_user}","gists_url":"https://api.github.com/users/gnosis/gists{/gist_id}","starred_url":"https://api.github.com/users/gnosis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnosis/subscriptions","organizations_url":"https://api.github.com/users/gnosis/orgs","repos_url":"https://api.github.com/users/gnosis/repos","events_url":"https://api.github.com/users/gnosis/events{/privacy}","received_events_url":"https://api.github.com/users/gnosis/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/gnosis/dex-react","description":null,"fork":false,"url":"https://api.github.com/repos/gnosis/dex-react","forks_url":"https://api.github.com/repos/gnosis/dex-react/forks","keys_url":"https://api.github.com/repos/gnosis/dex-react/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gnosis/dex-react/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gnosis/dex-react/teams","hooks_url":"https://api.github.com/repos/gnosis/dex-react/hooks","issue_events_url":"https://api.github.com/repos/gnosis/dex-react/issues/events{/number}","events_url":"https://api.github.com/repos/gnosis/dex-react/events","assignees_url":"https://api.github.com/repos/gnosis/dex-react/assignees{/user}","branches_url":"https://api.github.com/repos/gnosis/dex-react/branches{/branch}","tags_url":"https://api.github.com/repos/gnosis/dex-react/tags","blobs_url":"https://api.github.com/repos/gnosis/dex-react/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gnosis/dex-react/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gnosis/dex-react/git/refs{/sha}","trees_url":"https://api.github.com/repos/gnosis/dex-react/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gnosis/dex-react/statuses/{sha}","languages_url":"https://api.github.com/repos/gnosis/dex-react/languages","stargazers_url":"https://api.github.com/repos/gnosis/dex-react/stargazers","contributors_url":"https://api.github.com/repos/gnosis/dex-react/contributors","subscribers_url":"https://api.github.com/repos/gnosis/dex-react/subscribers","subscription_url":"https://api.github.com/repos/gnosis/dex-react/subscription","commits_url":"https://api.github.com/repos/gnosis/dex-react/commits{/sha}","git_commits_url":"https://api.github.com/repos/gnosis/dex-react/git/commits{/sha}","comments_url":"https://api.github.com/repos/gnosis/dex-react/comments{/number}","issue_comment_url":"https://api.github.com/repos/gnosis/dex-react/issues/comments{/number}","contents_url":"https://api.github.com/repos/gnosis/dex-react/contents/{+path}","compare_url":"https://api.github.com/repos/gnosis/dex-react/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gnosis/dex-react/merges","archive_url":"https://api.github.com/repos/gnosis/dex-react/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gnosis/dex-react/downloads","issues_url":"https://api.github.com/repos/gnosis/dex-react/issues{/number}","pulls_url":"https://api.github.com/repos/gnosis/dex-react/pulls{/number}","milestones_url":"https://api.github.com/repos/gnosis/dex-react/milestones{/number}","notifications_url":"https://api.github.com/repos/gnosis/dex-react/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gnosis/dex-react/labels{/name}","releases_url":"https://api.github.com/repos/gnosis/dex-react/releases{/id}","deployments_url":"https://api.github.com/repos/gnosis/dex-react/deployments","created_at":"2019-08-01T10:14:22Z","updated_at":"2019-12-10T08:35:34Z","pushed_at":"2019-12-11T03:23:26Z","git_url":"git://github.com/gnosis/dex-react.git","ssh_url":"git@github.com:gnosis/dex-react.git","clone_url":"https://github.com/gnosis/dex-react.git","svn_url":"https://github.com/gnosis/dex-react","homepage":null,"size":1418,"stargazers_count":4,"watchers_count":4,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":54,"license":null,"forks":0,"open_issues":54,"watchers":4,"default_branch":"develop"}},"base":{"label":"gnosis:develop","ref":"develop","sha":"c93b90247ed3e5984c429b67b39eb70a50080658","user":{"login":"gnosis","id":24954468,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0OTU0NDY4","avatar_url":"https://avatars1.githubusercontent.com/u/24954468?v=4","gravatar_id":"","url":"https://api.github.com/users/gnosis","html_url":"https://github.com/gnosis","followers_url":"https://api.github.com/users/gnosis/followers","following_url":"https://api.github.com/users/gnosis/following{/other_user}","gists_url":"https://api.github.com/users/gnosis/gists{/gist_id}","starred_url":"https://api.github.com/users/gnosis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnosis/subscriptions","organizations_url":"https://api.github.com/users/gnosis/orgs","repos_url":"https://api.github.com/users/gnosis/repos","events_url":"https://api.github.com/users/gnosis/events{/privacy}","received_events_url":"https://api.github.com/users/gnosis/received_events","type":"Organization","site_admin":false},"repo":{"id":200027889,"node_id":"MDEwOlJlcG9zaXRvcnkyMDAwMjc4ODk=","name":"dex-react","full_name":"gnosis/dex-react","private":false,"owner":{"login":"gnosis","id":24954468,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0OTU0NDY4","avatar_url":"https://avatars1.githubusercontent.com/u/24954468?v=4","gravatar_id":"","url":"https://api.github.com/users/gnosis","html_url":"https://github.com/gnosis","followers_url":"https://api.github.com/users/gnosis/followers","following_url":"https://api.github.com/users/gnosis/following{/other_user}","gists_url":"https://api.github.com/users/gnosis/gists{/gist_id}","starred_url":"https://api.github.com/users/gnosis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnosis/subscriptions","organizations_url":"https://api.github.com/users/gnosis/orgs","repos_url":"https://api.github.com/users/gnosis/repos","events_url":"https://api.github.com/users/gnosis/events{/privacy}","received_events_url":"https://api.github.com/users/gnosis/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/gnosis/dex-react","description":null,"fork":false,"url":"https://api.github.com/repos/gnosis/dex-react","forks_url":"https://api.github.com/repos/gnosis/dex-react/forks","keys_url":"https://api.github.com/repos/gnosis/dex-react/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gnosis/dex-react/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gnosis/dex-react/teams","hooks_url":"https://api.github.com/repos/gnosis/dex-react/hooks","issue_events_url":"https://api.github.com/repos/gnosis/dex-react/issues/events{/number}","events_url":"https://api.github.com/repos/gnosis/dex-react/events","assignees_url":"https://api.github.com/repos/gnosis/dex-react/assignees{/user}","branches_url":"https://api.github.com/repos/gnosis/dex-react/branches{/branch}","tags_url":"https://api.github.com/repos/gnosis/dex-react/tags","blobs_url":"https://api.github.com/repos/gnosis/dex-react/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gnosis/dex-react/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gnosis/dex-react/git/refs{/sha}","trees_url":"https://api.github.com/repos/gnosis/dex-react/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gnosis/dex-react/statuses/{sha}","languages_url":"https://api.github.com/repos/gnosis/dex-react/languages","stargazers_url":"https://api.github.com/repos/gnosis/dex-react/stargazers","contributors_url":"https://api.github.com/repos/gnosis/dex-react/contributors","subscribers_url":"https://api.github.com/repos/gnosis/dex-react/subscribers","subscription_url":"https://api.github.com/repos/gnosis/dex-react/subscription","commits_url":"https://api.github.com/repos/gnosis/dex-react/commits{/sha}","git_commits_url":"https://api.github.com/repos/gnosis/dex-react/git/commits{/sha}","comments_url":"https://api.github.com/repos/gnosis/dex-react/comments{/number}","issue_comment_url":"https://api.github.com/repos/gnosis/dex-react/issues/comments{/number}","contents_url":"https://api.github.com/repos/gnosis/dex-react/contents/{+path}","compare_url":"https://api.github.com/repos/gnosis/dex-react/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gnosis/dex-react/merges","archive_url":"https://api.github.com/repos/gnosis/dex-react/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gnosis/dex-react/downloads","issues_url":"https://api.github.com/repos/gnosis/dex-react/issues{/number}","pulls_url":"https://api.github.com/repos/gnosis/dex-react/pulls{/number}","milestones_url":"https://api.github.com/repos/gnosis/dex-react/milestones{/number}","notifications_url":"https://api.github.com/repos/gnosis/dex-react/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gnosis/dex-react/labels{/name}","releases_url":"https://api.github.com/repos/gnosis/dex-react/releases{/id}","deployments_url":"https://api.github.com/repos/gnosis/dex-react/deployments","created_at":"2019-08-01T10:14:22Z","updated_at":"2019-12-10T08:35:34Z","pushed_at":"2019-12-11T03:23:26Z","git_url":"git://github.com/gnosis/dex-react.git","ssh_url":"git@github.com:gnosis/dex-react.git","clone_url":"https://github.com/gnosis/dex-react.git","svn_url":"https://github.com/gnosis/dex-react","homepage":null,"size":1418,"stargazers_count":4,"watchers_count":4,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":54,"license":null,"forks":0,"open_issues":54,"watchers":4,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/gnosis/dex-react/pulls/297"},"html":{"href":"https://github.com/gnosis/dex-react/pull/297"},"issue":{"href":"https://api.github.com/repos/gnosis/dex-react/issues/297"},"comments":{"href":"https://api.github.com/repos/gnosis/dex-react/issues/297/comments"},"review_comments":{"href":"https://api.github.com/repos/gnosis/dex-react/pulls/297/comments"},"review_comment":{"href":"https://api.github.com/repos/gnosis/dex-react/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gnosis/dex-react/pulls/297/commits"},"statuses":{"href":"https://api.github.com/repos/gnosis/dex-react/statuses/f0685ba093babd7e8c9dc161fedc01cec09cb0ca"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"anxolin"}}