This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes brave/brave-browser#4773 - adds BAT token by default to accounts
- Loading branch information
Showing
12 changed files
with
184 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const inherits = require('util').inherits | ||
const Component = require('react').Component | ||
const h = require('react-hyperscript') | ||
|
||
inherits(Menu, Component) | ||
function Menu () { Component.call(this) } | ||
|
||
Menu.prototype.render = function () { | ||
const { className = '', children, isShowing } = this.props | ||
return isShowing | ||
? h('div', { className: `menu ${className}` }, children) | ||
: h('noscript') | ||
} | ||
|
||
inherits(Item, Component) | ||
function Item () { Component.call(this) } | ||
|
||
Item.prototype.render = function () { | ||
const { | ||
icon, | ||
children, | ||
text, | ||
className = '', | ||
onClick, | ||
isShowing | ||
} = this.props | ||
|
||
if (isShowing === false) { | ||
return h('noscript') | ||
} | ||
|
||
const itemClassName = `menu__item ${className} ${onClick ? 'menu__item--clickable' : ''}` | ||
const iconComponent = icon ? h('div.menu__item__icon', [icon]) : null | ||
const textComponent = text ? h('div.menu__item__text', text) : null | ||
|
||
return children | ||
? h('div', { className: itemClassName, onClick }, children) | ||
: h('div.menu__item', { className: itemClassName, onClick }, [ iconComponent, textComponent ] | ||
.filter(d => Boolean(d)) | ||
) | ||
} | ||
|
||
module.exports = { Menu, Item } |
69 changes: 69 additions & 0 deletions
69
ui/app/components/app/dropdowns/components/brave/token-menu-dropdown.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const Component = require('react').Component | ||
const PropTypes = require('prop-types') | ||
const h = require('react-hyperscript') | ||
const inherits = require('util').inherits | ||
const connect = require('react-redux').connect | ||
const actions = require('../../../../../store/actions') | ||
const genAccountLink = require('etherscan-link').createAccountLink | ||
const { CloseArea } = require('../menu') | ||
const { Menu, Item } = require('../brave/menu') | ||
TokenMenuDropdown.contextTypes = { | ||
t: PropTypes.func, | ||
} | ||
|
||
module.exports = connect(mapStateToProps, mapDispatchToProps)(TokenMenuDropdown) | ||
|
||
function mapStateToProps (state) { | ||
return { | ||
network: state.metamask.network, | ||
} | ||
} | ||
|
||
function mapDispatchToProps (dispatch) { | ||
return { | ||
showHideTokenConfirmationModal: (token) => { | ||
dispatch(actions.showModal({ name: 'HIDE_TOKEN_CONFIRMATION', token })) | ||
}, | ||
} | ||
} | ||
|
||
|
||
inherits(TokenMenuDropdown, Component) | ||
function TokenMenuDropdown () { | ||
Component.call(this) | ||
|
||
this.onClose = this.onClose.bind(this) | ||
} | ||
|
||
TokenMenuDropdown.prototype.onClose = function (e) { | ||
e.stopPropagation() | ||
this.props.onClose() | ||
} | ||
|
||
TokenMenuDropdown.prototype.render = function () { | ||
const { showHideTokenConfirmationModal } = this.props | ||
|
||
return h(Menu, { className: 'token-menu-dropdown', isShowing: true }, [ | ||
h(CloseArea, { | ||
onClick: this.onClose, | ||
}), | ||
h(Item, { | ||
onClick: (e) => { | ||
e.stopPropagation() | ||
showHideTokenConfirmationModal(this.props.token) | ||
this.props.onClose() | ||
}, | ||
isShowing: (this.props.token.symbol !== 'BAT'), | ||
text: this.context.t('hideToken'), | ||
}), | ||
h(Item, { | ||
onClick: (e) => { | ||
e.stopPropagation() | ||
const url = genAccountLink(this.props.token.address, this.props.network) | ||
global.platform.openWindow({ url }) | ||
this.props.onClose() | ||
}, | ||
text: this.context.t('viewOnEtherscan'), | ||
}), | ||
]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default { | ||
'0x0D8775F648430679A709E98d2b0Cb6250d2887EF': { | ||
'name': 'Basic Attention Token', | ||
'logo': 'BAT_icon.svg', | ||
'erc20': true, | ||
'symbol': 'BAT', | ||
'decimals': 18, | ||
'address' :'0x0D8775F648430679A709E98d2b0Cb6250d2887EF' | ||
} | ||
} |