typo watchAsset imageUrl to image

feature/default_network_editable
Esteban MIno 6 years ago
parent 56bed3f1bc
commit b59a1e91b8
  1. 12
      app/scripts/controllers/preferences.js
  2. 14
      test/unit/app/controllers/preferences-controller-test.js
  3. 4
      ui/app/actions.js
  4. 4
      ui/app/components/balance-component.js
  5. 6
      ui/app/components/identicon.js
  6. 4
      ui/app/components/modals/hide-token-confirmation-modal.js
  7. 4
      ui/app/components/pages/confirm-add-suggested-token/confirm-add-suggested-token.component.js
  8. 2
      ui/app/components/pages/confirm-add-suggested-token/confirm-add-suggested-token.container.js
  9. 4
      ui/app/components/token-cell.js
  10. 2
      ui/app/components/token-list.js

@ -67,9 +67,9 @@ class PreferencesController {
addSuggestedERC20Asset (tokenOpts) { addSuggestedERC20Asset (tokenOpts) {
this._validateERC20AssetParams(tokenOpts) this._validateERC20AssetParams(tokenOpts)
const suggested = this.getSuggestedTokens() const suggested = this.getSuggestedTokens()
const { rawAddress, symbol, decimals, imageUrl } = tokenOpts const { rawAddress, symbol, decimals, image } = tokenOpts
const address = normalizeAddress(rawAddress) const address = normalizeAddress(rawAddress)
const newEntry = { address, symbol, decimals, imageUrl } const newEntry = { address, symbol, decimals, image }
suggested[address] = newEntry suggested[address] = newEntry
this.store.updateState({ suggestedTokens: suggested }) this.store.updateState({ suggestedTokens: suggested })
} }
@ -291,7 +291,7 @@ class PreferencesController {
* @returns {Promise<array>} Promises the new array of AddedToken objects. * @returns {Promise<array>} Promises the new array of AddedToken objects.
* *
*/ */
async addToken (rawAddress, symbol, decimals, imageUrl) { async addToken (rawAddress, symbol, decimals, image) {
const address = normalizeAddress(rawAddress) const address = normalizeAddress(rawAddress)
const newEntry = { address, symbol, decimals } const newEntry = { address, symbol, decimals }
const tokens = this.store.getState().tokens const tokens = this.store.getState().tokens
@ -306,7 +306,7 @@ class PreferencesController {
} else { } else {
tokens.push(newEntry) tokens.push(newEntry)
} }
assetImages[address] = imageUrl assetImages[address] = image
this._updateAccountTokens(tokens, assetImages) this._updateAccountTokens(tokens, assetImages)
return Promise.resolve(tokens) return Promise.resolve(tokens)
} }
@ -509,14 +509,14 @@ class PreferencesController {
* *
*/ */
async _handleWatchAssetERC20 (options) { async _handleWatchAssetERC20 (options) {
const { address, symbol, decimals, imageUrl } = options const { address, symbol, decimals, image } = options
const rawAddress = address const rawAddress = address
try { try {
this._validateERC20AssetParams({ rawAddress, symbol, decimals }) this._validateERC20AssetParams({ rawAddress, symbol, decimals })
} catch (err) { } catch (err) {
return err return err
} }
const tokenOpts = { rawAddress, decimals, symbol, imageUrl } const tokenOpts = { rawAddress, decimals, symbol, image }
this.addSuggestedERC20Asset(tokenOpts) this.addSuggestedERC20Asset(tokenOpts)
return this.showWatchAssetUi().then(() => { return this.showWatchAssetUi().then(() => {
const tokenAddresses = this.getTokens().filter(token => token.address === normalizeAddress(rawAddress)) const tokenAddresses = this.getTokens().filter(token => token.address === normalizeAddress(rawAddress))

@ -409,8 +409,8 @@ describe('preferences controller', function () {
const address = '0xabcdef1234567' const address = '0xabcdef1234567'
const symbol = 'ABBR' const symbol = 'ABBR'
const decimals = 5 const decimals = 5
const imageUrl = 'someimageurl' const image = 'someimage'
req.params.options = { address, symbol, decimals, imageUrl } req.params.options = { address, symbol, decimals, image }
sandbox.stub(preferencesController, '_validateERC20AssetParams').returns(true) sandbox.stub(preferencesController, '_validateERC20AssetParams').returns(true)
preferencesController.showWatchAssetUi = async () => {} preferencesController.showWatchAssetUi = async () => {}
@ -422,19 +422,19 @@ describe('preferences controller', function () {
assert.equal(suggested[address].address, address, 'set address correctly') assert.equal(suggested[address].address, address, 'set address correctly')
assert.equal(suggested[address].symbol, symbol, 'set symbol correctly') assert.equal(suggested[address].symbol, symbol, 'set symbol correctly')
assert.equal(suggested[address].decimals, decimals, 'set decimals correctly') assert.equal(suggested[address].decimals, decimals, 'set decimals correctly')
assert.equal(suggested[address].imageUrl, imageUrl, 'set imageUrl correctly') assert.equal(suggested[address].image, image, 'set image correctly')
}) })
it('should add token correctly if user confirms', async function () { it('should add token correctly if user confirms', async function () {
const address = '0xabcdef1234567' const address = '0xabcdef1234567'
const symbol = 'ABBR' const symbol = 'ABBR'
const decimals = 5 const decimals = 5
const imageUrl = 'someimageurl' const image = 'someimage'
req.params.options = { address, symbol, decimals, imageUrl } req.params.options = { address, symbol, decimals, image }
sandbox.stub(preferencesController, '_validateERC20AssetParams').returns(true) sandbox.stub(preferencesController, '_validateERC20AssetParams').returns(true)
preferencesController.showWatchAssetUi = async () => { preferencesController.showWatchAssetUi = async () => {
await preferencesController.addToken(address, symbol, decimals, imageUrl) await preferencesController.addToken(address, symbol, decimals, image)
} }
await preferencesController._handleWatchAssetERC20(req.params.options) await preferencesController._handleWatchAssetERC20(req.params.options)
@ -446,7 +446,7 @@ describe('preferences controller', function () {
assert.equal(added.decimals, decimals, 'set decimals correctly') assert.equal(added.decimals, decimals, 'set decimals correctly')
const assetImages = preferencesController.getAssetImages() const assetImages = preferencesController.getAssetImages()
assert.ok(assetImages[address], `set imageurl correctly`) assert.ok(assetImages[address], `set image correctly`)
}) })
}) })
}) })

@ -1599,11 +1599,11 @@ function showAddSuggestedTokenPage (transitionForward = true) {
} }
} }
function addToken (address, symbol, decimals, imageUrl) { function addToken (address, symbol, decimals, image) {
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
background.addToken(address, symbol, decimals, imageUrl, (err, tokens) => { background.addToken(address, symbol, decimals, image, (err, tokens) => {
dispatch(actions.hideLoadingIndication()) dispatch(actions.hideLoadingIndication())
if (err) { if (err) {
dispatch(actions.displayWarning(err.message)) dispatch(actions.displayWarning(err.message))

@ -35,7 +35,7 @@ BalanceComponent.prototype.render = function () {
const props = this.props const props = this.props
const { token, network, assetImages } = props const { token, network, assetImages } = props
const address = token && token.address const address = token && token.address
const imageUrl = assetImages && address ? assetImages[token.address] : undefined const image = assetImages && address ? assetImages[token.address] : undefined
return h('div.balance-container', {}, [ return h('div.balance-container', {}, [
@ -48,7 +48,7 @@ BalanceComponent.prototype.render = function () {
diameter: 50, diameter: 50,
address, address,
network, network,
imageUrl, image,
}), }),
token ? this.renderTokenBalance() : this.renderBalance(), token ? this.renderTokenBalance() : this.renderBalance(),

@ -26,17 +26,17 @@ function mapStateToProps (state) {
IdenticonComponent.prototype.render = function () { IdenticonComponent.prototype.render = function () {
var props = this.props var props = this.props
const { className = '', address, imageUrl } = props const { className = '', address, image } = props
var diameter = props.diameter || this.defaultDiameter var diameter = props.diameter || this.defaultDiameter
const style = { const style = {
height: diameter, height: diameter,
width: diameter, width: diameter,
borderRadius: diameter / 2, borderRadius: diameter / 2,
} }
if (imageUrl) { if (image) {
return h('img', { return h('img', {
className: `${className} identicon`, className: `${className} identicon`,
src: imageUrl, src: image,
style: { style: {
...style, ...style,
}, },

@ -43,7 +43,7 @@ module.exports = connect(mapStateToProps, mapDispatchToProps)(HideTokenConfirmat
HideTokenConfirmationModal.prototype.render = function () { HideTokenConfirmationModal.prototype.render = function () {
const { token, network, hideToken, hideModal, assetImages } = this.props const { token, network, hideToken, hideModal, assetImages } = this.props
const { symbol, address } = token const { symbol, address } = token
const imageUrl = assetImages[address] const image = assetImages[address]
return h('div.hide-token-confirmation', {}, [ return h('div.hide-token-confirmation', {}, [
h('div.hide-token-confirmation__container', { h('div.hide-token-confirmation__container', {
@ -57,7 +57,7 @@ HideTokenConfirmationModal.prototype.render = function () {
diameter: 45, diameter: 45,
address, address,
network, network,
imageUrl, image,
}), }),
h('div.hide-token-confirmation__symbol', {}, symbol), h('div.hide-token-confirmation__symbol', {}, symbol),

@ -61,7 +61,7 @@ export default class ConfirmAddSuggestedToken extends Component {
{ {
Object.entries(pendingTokens) Object.entries(pendingTokens)
.map(([ address, token ]) => { .map(([ address, token ]) => {
const { name, symbol, imageUrl } = token const { name, symbol, image } = token
return ( return (
<div <div
@ -73,7 +73,7 @@ export default class ConfirmAddSuggestedToken extends Component {
className="confirm-add-token__token-icon" className="confirm-add-token__token-icon"
diameter={48} diameter={48}
address={address} address={address}
imageUrl={imageUrl} image={image}
/> />
<div className="confirm-add-token__name"> <div className="confirm-add-token__name">
{ this.getTokenName(name, symbol) } { this.getTokenName(name, symbol) }

@ -18,7 +18,7 @@ const mapStateToProps = ({ metamask }) => {
const mapDispatchToProps = dispatch => { const mapDispatchToProps = dispatch => {
return { return {
addToken: ({address, symbol, decimals, imageUrl}) => dispatch(addToken(address, symbol, decimals, imageUrl)), addToken: ({address, symbol, decimals, image}) => dispatch(addToken(address, symbol, decimals, image)),
removeSuggestedTokens: () => dispatch(removeSuggestedTokens()), removeSuggestedTokens: () => dispatch(removeSuggestedTokens()),
} }
} }

@ -56,7 +56,7 @@ TokenCell.prototype.render = function () {
sidebarOpen, sidebarOpen,
currentCurrency, currentCurrency,
// userAddress, // userAddress,
imageUrl, image,
} = props } = props
let currentTokenToFiatRate let currentTokenToFiatRate
let currentTokenInFiat let currentTokenInFiat
@ -97,7 +97,7 @@ TokenCell.prototype.render = function () {
diameter: 50, diameter: 50,
address, address,
network, network,
imageUrl, image,
}), }),
h('div.token-list-item__balance-ellipsis', null, [ h('div.token-list-item__balance-ellipsis', null, [

@ -75,7 +75,7 @@ TokenList.prototype.render = function () {
} }
return h('div', tokens.map((tokenData) => { return h('div', tokens.map((tokenData) => {
tokenData.imageUrl = assetImages[tokenData.address] tokenData.image = assetImages[tokenData.address]
return h(TokenCell, tokenData) return h(TokenCell, tokenData)
})) }))

Loading…
Cancel
Save