mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 17:33:23 +01:00
Buy button (#474)
* WIP: Buy button link * Add buy eth and the buy eth warning message * Add css * Move the opening of coinbase page to background and send to faucet if on test net * Create a Warning about storeing eth * Finish Buy button and Eth store warning screen * Add to CHANGELOG * fix frankies deletion and change chrome to extension
This commit is contained in:
parent
6658bea8d4
commit
fcd523abe4
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## Current Master
|
## Current Master
|
||||||
|
|
||||||
|
- Added a Warning screen about storing ETH
|
||||||
|
- Add buy Button!
|
||||||
- MetaMask now throws descriptive errors when apps try to use synchronous web3 methods.
|
- MetaMask now throws descriptive errors when apps try to use synchronous web3 methods.
|
||||||
|
|
||||||
## 2.6.2 2016-07-20
|
## 2.6.2 2016-07-20
|
||||||
|
@ -270,3 +270,13 @@ ConfigManager.prototype.getConfirmed = function () {
|
|||||||
return ('isConfirmed' in data) && data.isConfirmed
|
return ('isConfirmed' in data) && data.isConfirmed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigManager.prototype.setShouldntShowWarning = function (confirmed) {
|
||||||
|
var data = this.getData()
|
||||||
|
data.isEthConfirmed = confirmed
|
||||||
|
this.setData(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigManager.prototype.getShouldntShowWarning = function () {
|
||||||
|
var data = this.getData()
|
||||||
|
return ('isEthConfirmed' in data) && data.isEthConfirmed
|
||||||
|
}
|
||||||
|
@ -94,6 +94,7 @@ IdentityStore.prototype.getState = function () {
|
|||||||
isUnlocked: this._isUnlocked(),
|
isUnlocked: this._isUnlocked(),
|
||||||
seedWords: seedWords,
|
seedWords: seedWords,
|
||||||
isConfirmed: configManager.getConfirmed(),
|
isConfirmed: configManager.getConfirmed(),
|
||||||
|
isEthConfirmed: configManager.getShouldntShowWarning(),
|
||||||
unconfTxs: configManager.unconfirmedTxs(),
|
unconfTxs: configManager.unconfirmedTxs(),
|
||||||
transactions: configManager.getTxList(),
|
transactions: configManager.getTxList(),
|
||||||
unconfMsgs: messageManager.unconfirmedMsgs(),
|
unconfMsgs: messageManager.unconfirmedMsgs(),
|
||||||
@ -199,7 +200,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone
|
|||||||
time: time,
|
time: time,
|
||||||
status: 'unconfirmed',
|
status: 'unconfirmed',
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('addUnconfirmedTransaction:', txData)
|
console.log('addUnconfirmedTransaction:', txData)
|
||||||
|
|
||||||
// keep the onTxDoneCb around for after approval/denial (requires user interaction)
|
// keep the onTxDoneCb around for after approval/denial (requires user interaction)
|
||||||
|
@ -40,6 +40,7 @@ module.exports = class MetamaskController {
|
|||||||
setProviderType: this.setProviderType.bind(this),
|
setProviderType: this.setProviderType.bind(this),
|
||||||
useEtherscanProvider: this.useEtherscanProvider.bind(this),
|
useEtherscanProvider: this.useEtherscanProvider.bind(this),
|
||||||
agreeToDisclaimer: this.agreeToDisclaimer.bind(this),
|
agreeToDisclaimer: this.agreeToDisclaimer.bind(this),
|
||||||
|
agreeToEthWarning: this.agreeToEthWarning.bind(this),
|
||||||
// forward directly to idStore
|
// forward directly to idStore
|
||||||
createNewVault: idStore.createNewVault.bind(idStore),
|
createNewVault: idStore.createNewVault.bind(idStore),
|
||||||
recoverFromSeed: idStore.recoverFromSeed.bind(idStore),
|
recoverFromSeed: idStore.recoverFromSeed.bind(idStore),
|
||||||
@ -56,6 +57,8 @@ module.exports = class MetamaskController {
|
|||||||
saveAccountLabel: idStore.saveAccountLabel.bind(idStore),
|
saveAccountLabel: idStore.saveAccountLabel.bind(idStore),
|
||||||
tryPassword: idStore.tryPassword.bind(idStore),
|
tryPassword: idStore.tryPassword.bind(idStore),
|
||||||
recoverSeed: idStore.recoverSeed.bind(idStore),
|
recoverSeed: idStore.recoverSeed.bind(idStore),
|
||||||
|
// coinbase
|
||||||
|
buyEth: this.buyEth.bind(this),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +240,15 @@ module.exports = class MetamaskController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
agreeToEthWarning (cb) {
|
||||||
|
try {
|
||||||
|
this.configManager.setShouldntShowWarning(true)
|
||||||
|
cb()
|
||||||
|
} catch (e) {
|
||||||
|
cb(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// called from popup
|
// called from popup
|
||||||
setRpcTarget (rpcTarget) {
|
setRpcTarget (rpcTarget) {
|
||||||
this.configManager.setRpcTarget(rpcTarget)
|
this.configManager.setRpcTarget(rpcTarget)
|
||||||
@ -254,6 +266,22 @@ module.exports = class MetamaskController {
|
|||||||
this.configManager.useEtherscanProvider()
|
this.configManager.useEtherscanProvider()
|
||||||
extension.runtime.reload()
|
extension.runtime.reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buyEth (address, amount) {
|
||||||
|
if (!amount) amount = '5'
|
||||||
|
|
||||||
|
var network = this.idStore._currentState.network
|
||||||
|
var url = `https://buy.coinbase.com/?code=9ec56d01-7e81-5017-930c-513daa27bb6a&amount=${amount}&address=${address}&crypto_currency=ETH`
|
||||||
|
|
||||||
|
if (network === '2') {
|
||||||
|
url = 'https://testfaucet.metamask.io/'
|
||||||
|
}
|
||||||
|
|
||||||
|
extension.tabs.create({
|
||||||
|
url,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function noop () {}
|
function noop () {}
|
||||||
|
@ -28,6 +28,7 @@ function mapStateToProps (state) {
|
|||||||
network: state.metamask.network,
|
network: state.metamask.network,
|
||||||
unconfTxs: valuesFor(state.metamask.unconfTxs),
|
unconfTxs: valuesFor(state.metamask.unconfTxs),
|
||||||
unconfMsgs: valuesFor(state.metamask.unconfMsgs),
|
unconfMsgs: valuesFor(state.metamask.unconfMsgs),
|
||||||
|
isEthWarningConfirmed: state.metamask.isEthConfirmed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,6 +171,16 @@ AccountDetailScreen.prototype.render = function () {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
h('button', {
|
||||||
|
onClick: () => props.dispatch(actions.buyEth(selected)),
|
||||||
|
style: {
|
||||||
|
marginBottom: '20px',
|
||||||
|
marginRight: '8px',
|
||||||
|
position: 'absolute',
|
||||||
|
left: '219px',
|
||||||
|
},
|
||||||
|
}, 'BUY'),
|
||||||
|
|
||||||
h('button', {
|
h('button', {
|
||||||
onClick: () => props.dispatch(actions.showSendPage()),
|
onClick: () => props.dispatch(actions.showSendPage()),
|
||||||
style: {
|
style: {
|
||||||
@ -181,7 +192,7 @@ AccountDetailScreen.prototype.render = function () {
|
|||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
// subview (tx history, pk export confirm)
|
// subview (tx history, pk export confirm, buy eth warning)
|
||||||
h(ReactCSSTransitionGroup, {
|
h(ReactCSSTransitionGroup, {
|
||||||
className: 'css-transition-group',
|
className: 'css-transition-group',
|
||||||
transitionName: 'main',
|
transitionName: 'main',
|
||||||
@ -239,3 +250,4 @@ AccountDetailScreen.prototype.transactionList = function () {
|
|||||||
AccountDetailScreen.prototype.requestAccountExport = function () {
|
AccountDetailScreen.prototype.requestAccountExport = function () {
|
||||||
this.props.dispatch(actions.requestExportAccount())
|
this.props.dispatch(actions.requestExportAccount())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +66,10 @@ var actions = {
|
|||||||
showPrivateKey: showPrivateKey,
|
showPrivateKey: showPrivateKey,
|
||||||
SAVE_ACCOUNT_LABEL: 'SAVE_ACCOUNT_LABEL',
|
SAVE_ACCOUNT_LABEL: 'SAVE_ACCOUNT_LABEL',
|
||||||
saveAccountLabel: saveAccountLabel,
|
saveAccountLabel: saveAccountLabel,
|
||||||
|
AGREE_TO_ETH_WARNING: 'AGREE_TO_ETH_WARNING',
|
||||||
|
agreeToEthWarning: agreeToEthWarning,
|
||||||
|
SHOW_ETH_WARNING: 'SHOW_ETH_WARNING',
|
||||||
|
showEthWarning: showEthWarning,
|
||||||
// tx conf screen
|
// tx conf screen
|
||||||
COMPLETED_TX: 'COMPLETED_TX',
|
COMPLETED_TX: 'COMPLETED_TX',
|
||||||
TRANSACTION_ERROR: 'TRANSACTION_ERROR',
|
TRANSACTION_ERROR: 'TRANSACTION_ERROR',
|
||||||
@ -106,6 +110,9 @@ var actions = {
|
|||||||
HIDE_LOADING: 'HIDE_LOADING_INDICATION',
|
HIDE_LOADING: 'HIDE_LOADING_INDICATION',
|
||||||
showLoadingIndication: showLoadingIndication,
|
showLoadingIndication: showLoadingIndication,
|
||||||
hideLoadingIndication: hideLoadingIndication,
|
hideLoadingIndication: hideLoadingIndication,
|
||||||
|
// buy Eth with coinbase
|
||||||
|
BUY_ETH: 'BUY_ETH',
|
||||||
|
buyEth: buyEth,
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = actions
|
module.exports = actions
|
||||||
@ -559,3 +566,31 @@ function showSendPage () {
|
|||||||
type: actions.SHOW_SEND_PAGE,
|
type: actions.SHOW_SEND_PAGE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function agreeToEthWarning () {
|
||||||
|
return (dispatch) => {
|
||||||
|
_accountManager.agreeToEthWarning((err) => {
|
||||||
|
if (err) {
|
||||||
|
return dispatch(actions.showEthWarning(err.message))
|
||||||
|
}
|
||||||
|
dispatch({
|
||||||
|
type: actions.AGREE_TO_ETH_WARNING,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showEthWarning () {
|
||||||
|
return {
|
||||||
|
type: actions.SHOW_ETH_WARNING,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buyEth (address, amount) {
|
||||||
|
return (dispatch) => {
|
||||||
|
_accountManager.buyEth(address, amount)
|
||||||
|
dispatch({
|
||||||
|
type: actions.BUY_ETH,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -27,6 +27,7 @@ const MenuDroppo = require('menu-droppo')
|
|||||||
const DropMenuItem = require('./components/drop-menu-item')
|
const DropMenuItem = require('./components/drop-menu-item')
|
||||||
const NetworkIndicator = require('./components/network')
|
const NetworkIndicator = require('./components/network')
|
||||||
const Tooltip = require('./components/tooltip')
|
const Tooltip = require('./components/tooltip')
|
||||||
|
const EthStoreWarning = require('./eth-store-warning')
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps)(App)
|
module.exports = connect(mapStateToProps)(App)
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ function mapStateToProps (state) {
|
|||||||
return {
|
return {
|
||||||
// state from plugin
|
// state from plugin
|
||||||
isConfirmed: state.metamask.isConfirmed,
|
isConfirmed: state.metamask.isConfirmed,
|
||||||
|
isEthConfirmed: state.metamask.isEthConfirmed,
|
||||||
isInitialized: state.metamask.isInitialized,
|
isInitialized: state.metamask.isInitialized,
|
||||||
isUnlocked: state.metamask.isUnlocked,
|
isUnlocked: state.metamask.isUnlocked,
|
||||||
currentView: state.appState.currentView,
|
currentView: state.appState.currentView,
|
||||||
@ -324,6 +326,8 @@ App.prototype.renderPrimary = function () {
|
|||||||
|
|
||||||
// show current view
|
// show current view
|
||||||
switch (props.currentView.name) {
|
switch (props.currentView.name) {
|
||||||
|
case 'EthStoreWarning':
|
||||||
|
return h(EthStoreWarning, {key: 'ethWarning'})
|
||||||
|
|
||||||
case 'accounts':
|
case 'accounts':
|
||||||
return h(AccountsScreen, {key: 'accounts'})
|
return h(AccountsScreen, {key: 'accounts'})
|
||||||
|
@ -463,3 +463,9 @@ input.large-input {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* buy eth warning screen */
|
||||||
|
|
||||||
|
.eth-warning{
|
||||||
|
transition: opacity 400ms ease-in, transform 400ms ease-in;
|
||||||
|
}
|
||||||
|
89
ui/app/eth-store-warning.js
Normal file
89
ui/app/eth-store-warning.js
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
const connect = require('react-redux').connect
|
||||||
|
const Component = require('react').Component
|
||||||
|
const h = require('react-hyperscript')
|
||||||
|
const inherits = require('util').inherits
|
||||||
|
const actions = require('./actions')
|
||||||
|
|
||||||
|
module.exports = connect(mapStateToProps)(EthStoreWarning)
|
||||||
|
|
||||||
|
inherits(EthStoreWarning, Component)
|
||||||
|
function EthStoreWarning () {
|
||||||
|
Component.call(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapStateToProps (state) {
|
||||||
|
return {
|
||||||
|
selectedAccount: state.metamask.selectedAccount,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EthStoreWarning.prototype.render = function () {
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
h('.flex-column', {
|
||||||
|
key: 'ethWarning',
|
||||||
|
style: {
|
||||||
|
paddingTop: '25px',
|
||||||
|
marginRight: '30px',
|
||||||
|
marginLeft: '30px',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
}, [
|
||||||
|
h('.warning', {
|
||||||
|
style: {
|
||||||
|
margin: '10px 10px 10px 10px',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
`MetaMask is currently in beta -
|
||||||
|
exercise caution while handling
|
||||||
|
and storing your ether.
|
||||||
|
`),
|
||||||
|
|
||||||
|
h('i.fa.fa-exclamation-triangle.fa-4', {
|
||||||
|
style: {
|
||||||
|
fontSize: '152px',
|
||||||
|
color: '#AEAEAE',
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
h('.flex-row', {
|
||||||
|
style: {
|
||||||
|
marginTop: '25px',
|
||||||
|
marginBottom: '10px',
|
||||||
|
},
|
||||||
|
}, [
|
||||||
|
h('input', {
|
||||||
|
type: 'checkbox',
|
||||||
|
onChange: this.toggleShowWarning.bind(this, event),
|
||||||
|
}),
|
||||||
|
h('.warning', {
|
||||||
|
style: {
|
||||||
|
fontSize: '11px',
|
||||||
|
},
|
||||||
|
|
||||||
|
}, 'Dont show me this message again'),
|
||||||
|
]),
|
||||||
|
h('.flex-row', {
|
||||||
|
style: {
|
||||||
|
width: '100%',
|
||||||
|
justifyContent: 'space-around',
|
||||||
|
},
|
||||||
|
}, [
|
||||||
|
h('button', {
|
||||||
|
onClick: this.toAccounts.bind(this),
|
||||||
|
},
|
||||||
|
'Continue to MetaMask'),
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
EthStoreWarning.prototype.toggleShowWarning = function (event) {
|
||||||
|
this.props.dispatch(actions.agreeToEthWarning())
|
||||||
|
}
|
||||||
|
|
||||||
|
EthStoreWarning.prototype.toAccounts = function () {
|
||||||
|
this.props.dispatch(actions.showAccountDetail(this.props.account))
|
||||||
|
}
|
@ -28,10 +28,13 @@ function reduceApp (state, action) {
|
|||||||
name: 'createVaultComplete',
|
name: 'createVaultComplete',
|
||||||
seedWords,
|
seedWords,
|
||||||
}
|
}
|
||||||
|
var ethStoreWarning = {
|
||||||
|
name: 'EthStoreWarning',
|
||||||
|
}
|
||||||
|
|
||||||
var appState = extend({
|
var appState = extend({
|
||||||
menuOpen: false,
|
menuOpen: false,
|
||||||
currentView: seedWords ? seedConfView : defaultView,
|
currentView: seedWords ? seedConfView : !state.metamask.isEthConfirmed ? ethStoreWarning : defaultView,
|
||||||
accountDetail: {
|
accountDetail: {
|
||||||
subview: 'transactions',
|
subview: 'transactions',
|
||||||
},
|
},
|
||||||
@ -366,6 +369,17 @@ function reduceApp (state, action) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case actions.SHOW_ETH_WARNING:
|
||||||
|
return extend(appState, {
|
||||||
|
transForward: true,
|
||||||
|
currentView: {
|
||||||
|
name: 'accountDetail',
|
||||||
|
context: appState.currentView.context,
|
||||||
|
},
|
||||||
|
accountDetail: {
|
||||||
|
subview: 'buy-eth-warning',
|
||||||
|
},
|
||||||
|
})
|
||||||
default:
|
default:
|
||||||
return appState
|
return appState
|
||||||
}
|
}
|
||||||
@ -390,3 +404,5 @@ function indexForPending (state, txId) {
|
|||||||
})
|
})
|
||||||
return idx
|
return idx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,6 +31,11 @@ function reduceMetamask (state, action) {
|
|||||||
isConfirmed: true,
|
isConfirmed: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case actions.AGREE_TO_ETH_WARNING:
|
||||||
|
return extend(metamaskState, {
|
||||||
|
isEthConfirmed: true,
|
||||||
|
})
|
||||||
|
|
||||||
case actions.UNLOCK_METAMASK:
|
case actions.UNLOCK_METAMASK:
|
||||||
return extend(metamaskState, {
|
return extend(metamaskState, {
|
||||||
isUnlocked: true,
|
isUnlocked: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user