|
|
@ -55,10 +55,10 @@ function AddTokenScreen () { |
|
|
|
customSymbol: '', |
|
|
|
customSymbol: '', |
|
|
|
customDecimals: '', |
|
|
|
customDecimals: '', |
|
|
|
searchQuery: '', |
|
|
|
searchQuery: '', |
|
|
|
isCollapsed: true, |
|
|
|
|
|
|
|
selectedTokens: {}, |
|
|
|
selectedTokens: {}, |
|
|
|
errors: {}, |
|
|
|
errors: {}, |
|
|
|
autoFilled: false, |
|
|
|
autoFilled: false, |
|
|
|
|
|
|
|
displayedTab: 'SEARCH', |
|
|
|
} |
|
|
|
} |
|
|
|
this.tokenAddressDidChange = this.tokenAddressDidChange.bind(this) |
|
|
|
this.tokenAddressDidChange = this.tokenAddressDidChange.bind(this) |
|
|
|
this.tokenSymbolDidChange = this.tokenSymbolDidChange.bind(this) |
|
|
|
this.tokenSymbolDidChange = this.tokenSymbolDidChange.bind(this) |
|
|
@ -192,7 +192,7 @@ AddTokenScreen.prototype.attemptToAutoFillTokenParams = async function (address) |
|
|
|
AddTokenScreen.prototype.renderCustomForm = function () { |
|
|
|
AddTokenScreen.prototype.renderCustomForm = function () { |
|
|
|
const { autoFilled, customAddress, customSymbol, customDecimals, errors } = this.state |
|
|
|
const { autoFilled, customAddress, customSymbol, customDecimals, errors } = this.state |
|
|
|
|
|
|
|
|
|
|
|
return !this.state.isCollapsed && ( |
|
|
|
return ( |
|
|
|
h('div.add-token__add-custom-form', [ |
|
|
|
h('div.add-token__add-custom-form', [ |
|
|
|
h('div', { |
|
|
|
h('div', { |
|
|
|
className: classnames('add-token__add-custom-field', { |
|
|
|
className: classnames('add-token__add-custom-field', { |
|
|
@ -247,33 +247,36 @@ AddTokenScreen.prototype.renderTokenList = function () { |
|
|
|
}) |
|
|
|
}) |
|
|
|
const results = [...addressSearchResult, ...fuseSearchResult] |
|
|
|
const results = [...addressSearchResult, ...fuseSearchResult] |
|
|
|
|
|
|
|
|
|
|
|
return Array(6).fill(undefined) |
|
|
|
return h('div', [ |
|
|
|
.map((_, i) => { |
|
|
|
results.length > 0 && h('div.add-token__token-icons-title', t('popularTokens')), |
|
|
|
const { logo, symbol, name, address } = results[i] || {} |
|
|
|
h('div.add-token__token-icons-container', Array(6).fill(undefined) |
|
|
|
const tokenAlreadyAdded = this.checkExistingAddresses(address) |
|
|
|
.map((_, i) => { |
|
|
|
return Boolean(logo || symbol || name) && ( |
|
|
|
const { logo, symbol, name, address } = results[i] || {} |
|
|
|
h('div.add-token__token-wrapper', { |
|
|
|
const tokenAlreadyAdded = this.checkExistingAddresses(address) |
|
|
|
className: classnames({ |
|
|
|
return Boolean(logo || symbol || name) && ( |
|
|
|
'add-token__token-wrapper--selected': selectedTokens[address], |
|
|
|
h('div.add-token__token-wrapper', { |
|
|
|
'add-token__token-wrapper--disabled': tokenAlreadyAdded, |
|
|
|
className: classnames({ |
|
|
|
}), |
|
|
|
'add-token__token-wrapper--selected': selectedTokens[address], |
|
|
|
onClick: () => !tokenAlreadyAdded && this.toggleToken(address, results[i]), |
|
|
|
'add-token__token-wrapper--disabled': tokenAlreadyAdded, |
|
|
|
}, [ |
|
|
|
}), |
|
|
|
h('div.add-token__token-icon', { |
|
|
|
onClick: () => !tokenAlreadyAdded && this.toggleToken(address, results[i]), |
|
|
|
style: { |
|
|
|
}, [ |
|
|
|
backgroundImage: logo && `url(images/contract/${logo})`, |
|
|
|
h('div.add-token__token-icon', { |
|
|
|
}, |
|
|
|
style: { |
|
|
|
}), |
|
|
|
backgroundImage: logo && `url(images/contract/${logo})`, |
|
|
|
h('div.add-token__token-data', [ |
|
|
|
}, |
|
|
|
h('div.add-token__token-symbol', symbol), |
|
|
|
}), |
|
|
|
h('div.add-token__token-name', name), |
|
|
|
h('div.add-token__token-data', [ |
|
|
|
]), |
|
|
|
h('div.add-token__token-symbol', symbol), |
|
|
|
// tokenAlreadyAdded && (
|
|
|
|
h('div.add-token__token-name', name), |
|
|
|
// h('div.add-token__token-message', 'Already added')
|
|
|
|
]), |
|
|
|
// ),
|
|
|
|
// tokenAlreadyAdded && (
|
|
|
|
]) |
|
|
|
// h('div.add-token__token-message', 'Already added')
|
|
|
|
) |
|
|
|
// ),
|
|
|
|
}) |
|
|
|
]) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
})), |
|
|
|
|
|
|
|
]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
AddTokenScreen.prototype.renderConfirmation = function () { |
|
|
|
AddTokenScreen.prototype.renderConfirmation = function () { |
|
|
@ -332,46 +335,76 @@ AddTokenScreen.prototype.renderConfirmation = function () { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AddTokenScreen.prototype.displayTab = function (selectedTab) { |
|
|
|
|
|
|
|
this.setState({ displayedTab: selectedTab }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
AddTokenScreen.prototype.render = function () { |
|
|
|
AddTokenScreen.prototype.render = function () { |
|
|
|
const { isCollapsed, errors, isShowingConfirmation } = this.state |
|
|
|
const { |
|
|
|
|
|
|
|
errors, |
|
|
|
|
|
|
|
isShowingConfirmation, |
|
|
|
|
|
|
|
displayedTab, |
|
|
|
|
|
|
|
} = this.state |
|
|
|
const { goHome } = this.props |
|
|
|
const { goHome } = this.props |
|
|
|
|
|
|
|
|
|
|
|
return isShowingConfirmation |
|
|
|
return isShowingConfirmation |
|
|
|
? this.renderConfirmation() |
|
|
|
? this.renderConfirmation() |
|
|
|
: ( |
|
|
|
: ( |
|
|
|
h('div.add-token', [ |
|
|
|
h('div.add-token', [ |
|
|
|
h('div.add-token__wrapper', [ |
|
|
|
h('div.add-token__header', [ |
|
|
|
h('div.add-token__title-container', [ |
|
|
|
h('div.add-token__header__cancel', { |
|
|
|
h('div.add-token__title', t('addToken')), |
|
|
|
onClick: () => goHome(), |
|
|
|
h('div.add-token__description', t('tokenWarning1')), |
|
|
|
}, [ |
|
|
|
h('div.add-token__description', t('tokenSelection')), |
|
|
|
h('i.fa.fa-angle-left.fa-lg'), |
|
|
|
|
|
|
|
h('span', t('cancel')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
h('div.add-token__content-container', [ |
|
|
|
h('div.add-token__header__title', t('addTokens')), |
|
|
|
h('div.add-token__input-container', [ |
|
|
|
h('div.add-token__header__tabs', [ |
|
|
|
h('input.add-token__input', { |
|
|
|
|
|
|
|
type: 'text', |
|
|
|
h('div.add-token__header__tabs__tab', { |
|
|
|
placeholder: t('search'), |
|
|
|
className: classnames('add-token__header__tabs__tab', { |
|
|
|
onChange: e => this.setState({ searchQuery: e.target.value }), |
|
|
|
'add-token__header__tabs__selected': displayedTab === 'SEARCH', |
|
|
|
|
|
|
|
'add-token__header__tabs__unselected cursor-pointer': displayedTab !== 'SEARCH', |
|
|
|
}), |
|
|
|
}), |
|
|
|
h('div.add-token__search-input-error-message', errors.tokenSelector), |
|
|
|
onClick: () => this.displayTab('SEARCH'), |
|
|
|
]), |
|
|
|
}, t('search')), |
|
|
|
h( |
|
|
|
|
|
|
|
'div.add-token__token-icons-container', |
|
|
|
h('div.add-token__header__tabs__tab', { |
|
|
|
this.renderTokenList(), |
|
|
|
className: classnames('add-token__header__tabs__tab', { |
|
|
|
), |
|
|
|
'add-token__header__tabs__selected': displayedTab === 'CUSTOM_TOKEN', |
|
|
|
|
|
|
|
'add-token__header__tabs__unselected cursor-pointer': displayedTab !== 'CUSTOM_TOKEN', |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
onClick: () => this.displayTab('CUSTOM_TOKEN'), |
|
|
|
|
|
|
|
}, t('customToken')), |
|
|
|
|
|
|
|
|
|
|
|
]), |
|
|
|
]), |
|
|
|
h('div.add-token__footers', [ |
|
|
|
]), |
|
|
|
h('div.add-token__add-custom', { |
|
|
|
|
|
|
|
onClick: () => this.setState({ isCollapsed: !isCollapsed }), |
|
|
|
displayedTab === 'CUSTOM_TOKEN' |
|
|
|
}, [ |
|
|
|
? this.renderCustomForm() |
|
|
|
t('addCustomToken'), |
|
|
|
: h('div', [ |
|
|
|
h(`i.fa.fa-angle-${isCollapsed ? 'down' : 'up'}`), |
|
|
|
h('div.add-token__wrapper', [ |
|
|
|
|
|
|
|
h('div.add-token__content-container', [ |
|
|
|
|
|
|
|
h('div.add-token__info-box', [ |
|
|
|
|
|
|
|
h('div.add-token__info-box__close'), |
|
|
|
|
|
|
|
h('div.add-token__info-box__title', t('whatsThis')), |
|
|
|
|
|
|
|
h('div.add-token__info-box__copy', t('keepTrackTokens')), |
|
|
|
|
|
|
|
h('div.add-token__info-box__copy--blue', t('learnMore')), |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
h('div.add-token__input-container', [ |
|
|
|
|
|
|
|
h('input.add-token__input', { |
|
|
|
|
|
|
|
type: 'text', |
|
|
|
|
|
|
|
placeholder: t('searchTokens'), |
|
|
|
|
|
|
|
onChange: e => this.setState({ searchQuery: e.target.value }), |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
h('div.add-token__search-input-error-message', errors.tokenSelector), |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
this.renderTokenList(), |
|
|
|
]), |
|
|
|
]), |
|
|
|
this.renderCustomForm(), |
|
|
|
|
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
h('div.add-token__buttons', [ |
|
|
|
h('div.add-token__buttons', [ |
|
|
|
h('button.btn-cancel.add-token__button', { |
|
|
|
h('button.btn-cancel.add-token__button--cancel', { |
|
|
|
onClick: goHome, |
|
|
|
onClick: goHome, |
|
|
|
}, t('cancel')), |
|
|
|
}, t('cancel')), |
|
|
|
h('button.btn-clear.add-token__button', { |
|
|
|
h('button.btn-clear.add-token__button', { |
|
|
|