Skip to content

Commit

Permalink
Finance: fix loading some icons on test networks (aragon#1052)
Browse files Browse the repository at this point in the history
  • Loading branch information
sohkai authored Nov 26, 2019
1 parent 2f610d5 commit 819e6f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/finance/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dependencies": {
"@aragon/api": "^2.0.0-beta.6",
"@aragon/api-react": "^2.0.0-beta.6",
"@aragon/templates-tokens": "^1.2.0",
"@aragon/templates-tokens": "^1.3.0",
"@aragon/ui": "^1.0.0",
"@babel/polyfill": "^7.0.0",
"bn.js": "^4.11.8",
Expand Down
8 changes: 7 additions & 1 deletion apps/finance/app/src/lib/icon-utils.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import { tokenIconUrl as _tokenIconUrl } from '@aragon/ui'
import { getTestTokenAddresses } from '../testnet'
import { ETHER_TOKEN_FAKE_ADDRESS } from './token-utils'
import { ETHER_TOKEN_VERIFIED_BY_SYMBOL } from './verified-tokens'

// Small shim on top of @aragon/ui's tokenIconUrl, to handle our testnet tokens
export const tokenIconUrl = (tokenAddress, tokenSymbol, networkType) => {
if (networkType === 'main') {
if (tokenAddress === ETHER_TOKEN_FAKE_ADDRESS || networkType === 'main') {
return _tokenIconUrl(tokenAddress)
}

// On other networks, only pretend known test tokens are legit
const testTokens = new Set(getTestTokenAddresses(networkType))
if (testTokens.has(tokenAddress.toLowerCase())) {
// For the memez
if (tokenSymbol === 'BCC') {
return 'https://chasing-coins.com/coin/logo/BCC'
}

const mainnetEquivalent = ETHER_TOKEN_VERIFIED_BY_SYMBOL.get(tokenSymbol)
return mainnetEquivalent ? _tokenIconUrl(mainnetEquivalent) : ''
}
Expand Down

0 comments on commit 819e6f3

Please sign in to comment.