Merge pull request #5167 from MetaMask/fix-watcAsset-images

Fix images for watched tokens
feature/default_network_editable
Dan Finlay 6 years ago committed by GitHub
commit 5043451356
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      development/states/send-edit.json
  2. 1
      development/states/send-new-ui.json
  3. 1
      development/states/send.json
  4. 7
      ui/app/components/balance-component.js
  5. 3
      ui/app/components/confirm-page-container/confirm-page-container-content/confirm-page-container-content.component.js
  6. 4
      ui/app/components/confirm-page-container/confirm-page-container-content/confirm-page-container-summary/confirm-page-container-summary.component.js
  7. 5
      ui/app/components/confirm-page-container/confirm-page-container.component.js
  8. 3
      ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js
  9. 4
      ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.container.js
  10. 4
      ui/app/components/sender-to-recipient/sender-to-recipient.component.js
  11. 3
      ui/app/components/transaction-list-item/transaction-list-item.component.js
  12. 5
      ui/app/components/transaction-list/transaction-list.component.js
  13. 3
      ui/app/components/transaction-list/transaction-list.container.js
  14. 4
      ui/app/components/transaction-view-balance/transaction-view-balance.component.js
  15. 3
      ui/app/components/transaction-view-balance/transaction-view-balance.container.js
  16. 14
      ui/app/selectors.js

@ -22,6 +22,7 @@
"name": "Send Account 4" "name": "Send Account 4"
} }
}, },
"assetImages": {},
"unapprovedTxs": {}, "unapprovedTxs": {},
"currentCurrency": "USD", "currentCurrency": "USD",
"conversionRate": 1200.88200327, "conversionRate": 1200.88200327,

@ -61,6 +61,7 @@
"name": "Address Book Account 1" "name": "Address Book Account 1"
} }
], ],
"assetImages": {},
"tokens": [], "tokens": [],
"transactions": {}, "transactions": {},
"selectedAddressTxList": [], "selectedAddressTxList": [],

@ -21,6 +21,7 @@
"name": "Account 4" "name": "Account 4"
} }
}, },
"assetImages": {},
"unapprovedTxs": {}, "unapprovedTxs": {},
"currentCurrency": "USD", "currentCurrency": "USD",
"conversionRate": 16.88200327, "conversionRate": 16.88200327,

@ -5,6 +5,7 @@ const inherits = require('util').inherits
const TokenBalance = require('./token-balance') const TokenBalance = require('./token-balance')
const Identicon = require('./identicon') const Identicon = require('./identicon')
import CurrencyDisplay from './currency-display' import CurrencyDisplay from './currency-display'
const { getAssetImages, conversionRateSelector, getCurrentCurrency} = require('../selectors')
const { formatBalance, generateBalanceObject } = require('../util') const { formatBalance, generateBalanceObject } = require('../util')
@ -19,9 +20,9 @@ function mapStateToProps (state) {
return { return {
account, account,
network, network,
conversionRate: state.metamask.conversionRate, conversionRate: conversionRateSelector(state),
currentCurrency: state.metamask.currentCurrency, currentCurrency: getCurrentCurrency(state),
assetImages: state.metamask.assetImages, assetImages: getAssetImages(state),
} }
} }

@ -18,6 +18,7 @@ export default class ConfirmPageContainerContent extends Component {
hideSubtitle: PropTypes.bool, hideSubtitle: PropTypes.bool,
identiconAddress: PropTypes.string, identiconAddress: PropTypes.string,
nonce: PropTypes.string, nonce: PropTypes.string,
assetImage: PropTypes.string,
subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
summaryComponent: PropTypes.node, summaryComponent: PropTypes.node,
title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
@ -60,6 +61,7 @@ export default class ConfirmPageContainerContent extends Component {
hideSubtitle, hideSubtitle,
identiconAddress, identiconAddress,
nonce, nonce,
assetImage,
summaryComponent, summaryComponent,
detailsComponent, detailsComponent,
dataComponent, dataComponent,
@ -85,6 +87,7 @@ export default class ConfirmPageContainerContent extends Component {
hideSubtitle={hideSubtitle} hideSubtitle={hideSubtitle}
identiconAddress={identiconAddress} identiconAddress={identiconAddress}
nonce={nonce} nonce={nonce}
assetImage={assetImage}
/> />
) )
} }

@ -4,7 +4,7 @@ import classnames from 'classnames'
import Identicon from '../../../identicon' import Identicon from '../../../identicon'
const ConfirmPageContainerSummary = props => { const ConfirmPageContainerSummary = props => {
const { action, title, subtitle, hideSubtitle, className, identiconAddress, nonce } = props const { action, title, subtitle, hideSubtitle, className, identiconAddress, nonce, assetImage } = props
return ( return (
<div className={classnames('confirm-page-container-summary', className)}> <div className={classnames('confirm-page-container-summary', className)}>
@ -27,6 +27,7 @@ const ConfirmPageContainerSummary = props => {
className="confirm-page-container-summary__identicon" className="confirm-page-container-summary__identicon"
diameter={36} diameter={36}
address={identiconAddress} address={identiconAddress}
image={assetImage}
/> />
) )
} }
@ -51,6 +52,7 @@ ConfirmPageContainerSummary.propTypes = {
className: PropTypes.string, className: PropTypes.string,
identiconAddress: PropTypes.string, identiconAddress: PropTypes.string,
nonce: PropTypes.string, nonce: PropTypes.string,
assetImage: PropTypes.string,
} }
export default ConfirmPageContainerSummary export default ConfirmPageContainerSummary

@ -38,6 +38,7 @@ export default class ConfirmPageContainer extends Component {
detailsComponent: PropTypes.node, detailsComponent: PropTypes.node,
identiconAddress: PropTypes.string, identiconAddress: PropTypes.string,
nonce: PropTypes.string, nonce: PropTypes.string,
assetImage: PropTypes.string,
summaryComponent: PropTypes.node, summaryComponent: PropTypes.node,
warning: PropTypes.string, warning: PropTypes.string,
// Footer // Footer
@ -70,8 +71,10 @@ export default class ConfirmPageContainer extends Component {
onSubmit, onSubmit,
identiconAddress, identiconAddress,
nonce, nonce,
assetImage,
warning, warning,
} = this.props } = this.props
const renderAssetImage = contentComponent || (!contentComponent && !identiconAddress)
return ( return (
<div className="page-container"> <div className="page-container">
@ -84,6 +87,7 @@ export default class ConfirmPageContainer extends Component {
senderAddress={fromAddress} senderAddress={fromAddress}
recipientName={toName} recipientName={toName}
recipientAddress={toAddress} recipientAddress={toAddress}
assetImage={renderAssetImage ? assetImage : undefined}
/> />
</ConfirmPageContainerHeader> </ConfirmPageContainerHeader>
{ {
@ -101,6 +105,7 @@ export default class ConfirmPageContainer extends Component {
errorKey={errorKey} errorKey={errorKey}
identiconAddress={identiconAddress} identiconAddress={identiconAddress}
nonce={nonce} nonce={nonce}
assetImage={assetImage}
warning={warning} warning={warning}
/> />
) )

@ -38,6 +38,7 @@ export default class ConfirmTransactionBase extends Component {
isTxReprice: PropTypes.bool, isTxReprice: PropTypes.bool,
methodData: PropTypes.object, methodData: PropTypes.object,
nonce: PropTypes.string, nonce: PropTypes.string,
assetImage: PropTypes.string,
sendTransaction: PropTypes.func, sendTransaction: PropTypes.func,
showCustomizeGasModal: PropTypes.func, showCustomizeGasModal: PropTypes.func,
showTransactionConfirmedModal: PropTypes.func, showTransactionConfirmedModal: PropTypes.func,
@ -310,6 +311,7 @@ export default class ConfirmTransactionBase extends Component {
contentComponent, contentComponent,
onEdit, onEdit,
nonce, nonce,
assetImage,
warning, warning,
} = this.props } = this.props
const { submitting, submitError } = this.state const { submitting, submitError } = this.state
@ -334,6 +336,7 @@ export default class ConfirmTransactionBase extends Component {
dataComponent={this.renderData()} dataComponent={this.renderData()}
contentComponent={contentComponent} contentComponent={contentComponent}
nonce={nonce} nonce={nonce}
assetImage={assetImage}
identiconAddress={identiconAddress} identiconAddress={identiconAddress}
errorMessage={errorMessage || submitError} errorMessage={errorMessage || submitError}
errorKey={propsErrorKey || errorKey} errorKey={propsErrorKey || errorKey}

@ -52,8 +52,9 @@ const mapStateToProps = (state, props) => {
accounts, accounts,
selectedAddress, selectedAddress,
selectedAddressTxList, selectedAddressTxList,
assetImages,
} = metamask } = metamask
const assetImage = assetImages[txParamsToAddress]
const { balance } = accounts[selectedAddress] const { balance } = accounts[selectedAddress]
const { name: fromName } = identities[selectedAddress] const { name: fromName } = identities[selectedAddress]
const toAddress = propsToAddress || txParamsToAddress const toAddress = propsToAddress || txParamsToAddress
@ -88,6 +89,7 @@ const mapStateToProps = (state, props) => {
conversionRate, conversionRate,
transactionStatus, transactionStatus,
nonce, nonce,
assetImage,
} }
} }

@ -20,6 +20,7 @@ export default class SenderToRecipient extends PureComponent {
t: PropTypes.func, t: PropTypes.func,
variant: PropTypes.oneOf([DEFAULT_VARIANT, CARDS_VARIANT]), variant: PropTypes.oneOf([DEFAULT_VARIANT, CARDS_VARIANT]),
addressOnly: PropTypes.bool, addressOnly: PropTypes.bool,
assetImage: PropTypes.string,
} }
static defaultProps = { static defaultProps = {
@ -66,13 +67,14 @@ export default class SenderToRecipient extends PureComponent {
} }
renderRecipientIdenticon () { renderRecipientIdenticon () {
const { recipientAddress } = this.props const { recipientAddress, assetImage } = this.props
return !this.props.addressOnly && ( return !this.props.addressOnly && (
<div className="sender-to-recipient__sender-icon"> <div className="sender-to-recipient__sender-icon">
<Identicon <Identicon
address={recipientAddress} address={recipientAddress}
diameter={24} diameter={24}
image={assetImage}
/> />
</div> </div>
) )

@ -21,6 +21,7 @@ export default class TransactionListItem extends PureComponent {
setSelectedToken: PropTypes.func, setSelectedToken: PropTypes.func,
nonceAndDate: PropTypes.string, nonceAndDate: PropTypes.string,
token: PropTypes.object, token: PropTypes.object,
assetImages: PropTypes.object,
} }
handleClick = () => { handleClick = () => {
@ -100,6 +101,7 @@ export default class TransactionListItem extends PureComponent {
methodData, methodData,
showRetry, showRetry,
nonceAndDate, nonceAndDate,
assetImages,
} = this.props } = this.props
const { txParams = {} } = transaction const { txParams = {} } = transaction
@ -113,6 +115,7 @@ export default class TransactionListItem extends PureComponent {
className="transaction-list-item__identicon" className="transaction-list-item__identicon"
address={txParams.to} address={txParams.to}
diameter={34} diameter={34}
image={assetImages[txParams.to]}
/> />
<TransactionAction <TransactionAction
transaction={transaction} transaction={transaction}

@ -21,6 +21,7 @@ export default class TransactionList extends PureComponent {
transactionToRetry: PropTypes.object, transactionToRetry: PropTypes.object,
selectedToken: PropTypes.object, selectedToken: PropTypes.object,
updateNetworkNonce: PropTypes.func, updateNetworkNonce: PropTypes.func,
assetImages: PropTypes.object,
} }
componentDidMount () { componentDidMount () {
@ -45,7 +46,6 @@ export default class TransactionList extends PureComponent {
renderTransactions () { renderTransactions () {
const { t } = this.context const { t } = this.context
const { pendingTransactions = [], completedTransactions = [] } = this.props const { pendingTransactions = [], completedTransactions = [] } = this.props
return ( return (
<div className="transaction-list__transactions"> <div className="transaction-list__transactions">
{ {
@ -79,7 +79,7 @@ export default class TransactionList extends PureComponent {
} }
renderTransaction (transaction, index) { renderTransaction (transaction, index) {
const { selectedToken } = this.props const { selectedToken, assetImages } = this.props
return transaction.key === TRANSACTION_TYPE_SHAPESHIFT return transaction.key === TRANSACTION_TYPE_SHAPESHIFT
? ( ? (
@ -93,6 +93,7 @@ export default class TransactionList extends PureComponent {
key={transaction.id} key={transaction.id}
showRetry={this.shouldShowRetry(transaction)} showRetry={this.shouldShowRetry(transaction)}
token={selectedToken} token={selectedToken}
assetImages={assetImages}
/> />
) )
} }

@ -7,7 +7,7 @@ import {
submittedPendingTransactionsSelector, submittedPendingTransactionsSelector,
completedTransactionsSelector, completedTransactionsSelector,
} from '../../selectors/transactions' } from '../../selectors/transactions'
import { getSelectedAddress } from '../../selectors' import { getSelectedAddress, getAssetImages } from '../../selectors'
import { selectedTokenSelector } from '../../selectors/tokens' import { selectedTokenSelector } from '../../selectors/tokens'
import { getLatestSubmittedTxWithNonce } from '../../helpers/transactions.util' import { getLatestSubmittedTxWithNonce } from '../../helpers/transactions.util'
import { updateNetworkNonce } from '../../actions' import { updateNetworkNonce } from '../../actions'
@ -23,6 +23,7 @@ const mapStateToProps = state => {
transactionToRetry: getLatestSubmittedTxWithNonce(submittedPendingTransactions, networkNonce), transactionToRetry: getLatestSubmittedTxWithNonce(submittedPendingTransactions, networkNonce),
selectedToken: selectedTokenSelector(state), selectedToken: selectedTokenSelector(state),
selectedAddress: getSelectedAddress(state), selectedAddress: getSelectedAddress(state),
assetImages: getAssetImages(state),
} }
} }

@ -18,6 +18,7 @@ export default class TransactionViewBalance extends PureComponent {
history: PropTypes.object, history: PropTypes.object,
network: PropTypes.string, network: PropTypes.string,
balance: PropTypes.string, balance: PropTypes.string,
assetImage: PropTypes.string,
} }
renderBalance () { renderBalance () {
@ -75,7 +76,7 @@ export default class TransactionViewBalance extends PureComponent {
} }
render () { render () {
const { network, selectedToken } = this.props const { network, selectedToken, assetImage } = this.props
return ( return (
<div className="transaction-view-balance"> <div className="transaction-view-balance">
@ -84,6 +85,7 @@ export default class TransactionViewBalance extends PureComponent {
diameter={50} diameter={50}
address={selectedToken && selectedToken.address} address={selectedToken && selectedToken.address}
network={network} network={network}
image={assetImage}
/> />
{ this.renderBalance() } { this.renderBalance() }
</div> </div>

@ -2,7 +2,7 @@ import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom'
import { compose } from 'recompose' import { compose } from 'recompose'
import TransactionViewBalance from './transaction-view-balance.component' import TransactionViewBalance from './transaction-view-balance.component'
import { getSelectedToken, getSelectedAddress } from '../../selectors' import { getSelectedToken, getSelectedAddress, getSelectedTokenAssetImage } from '../../selectors'
import { showModal } from '../../actions' import { showModal } from '../../actions'
const mapStateToProps = state => { const mapStateToProps = state => {
@ -15,6 +15,7 @@ const mapStateToProps = state => {
selectedToken: getSelectedToken(state), selectedToken: getSelectedToken(state),
network, network,
balance, balance,
assetImage: getSelectedTokenAssetImage(state),
} }
} }

@ -14,6 +14,8 @@ const selectors = {
getSelectedAccount, getSelectedAccount,
getSelectedToken, getSelectedToken,
getSelectedTokenExchangeRate, getSelectedTokenExchangeRate,
getSelectedTokenAssetImage,
getAssetImages,
getTokenExchangeRate, getTokenExchangeRate,
conversionRateSelector, conversionRateSelector,
transactionsSelector, transactionsSelector,
@ -71,6 +73,18 @@ function getSelectedTokenExchangeRate (state) {
return contractExchangeRates[address] || 0 return contractExchangeRates[address] || 0
} }
function getSelectedTokenAssetImage (state) {
const assetImages = state.metamask.assetImages || {}
const selectedToken = getSelectedToken(state) || {}
const { address } = selectedToken
return assetImages[address]
}
function getAssetImages (state) {
const assetImages = state.metamask.assetImages || {}
return assetImages
}
function getTokenExchangeRate (state, address) { function getTokenExchangeRate (state, address) {
const contractExchangeRates = state.metamask.contractExchangeRates const contractExchangeRates = state.metamask.contractExchangeRates
return contractExchangeRates[address] || 0 return contractExchangeRates[address] || 0

Loading…
Cancel
Save