aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-10-13 01:29:03 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-10-18 09:10:09 +0800
commitac43872c1a1468057974648c8ae90bf1edd708d7 (patch)
treedcd98d338d99b97dc91ac7240326e9b4a6a50841 /ui
parent7caa9142235cc0eca20d638a066d666d8cfaabee (diff)
downloadtangerine-wallet-browser-ac43872c1a1468057974648c8ae90bf1edd708d7.tar
tangerine-wallet-browser-ac43872c1a1468057974648c8ae90bf1edd708d7.tar.gz
tangerine-wallet-browser-ac43872c1a1468057974648c8ae90bf1edd708d7.tar.bz2
tangerine-wallet-browser-ac43872c1a1468057974648c8ae90bf1edd708d7.tar.lz
tangerine-wallet-browser-ac43872c1a1468057974648c8ae90bf1edd708d7.tar.xz
tangerine-wallet-browser-ac43872c1a1468057974648c8ae90bf1edd708d7.tar.zst
tangerine-wallet-browser-ac43872c1a1468057974648c8ae90bf1edd708d7.zip
Enable send-v2 functionality.
Diffstat (limited to 'ui')
-rw-r--r--ui/app/actions.js14
-rw-r--r--ui/app/components/send/currency-display.js6
-rw-r--r--ui/app/components/send/from-dropdown.js17
-rw-r--r--ui/app/components/send/send-v2-container.js5
-rw-r--r--ui/app/send-v2.js39
5 files changed, 72 insertions, 9 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index b0ef7d0a3..9744bf67f 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -137,6 +137,7 @@ var actions = {
UPDATE_GAS_PRICE: 'UPDATE_GAS_PRICE',
updateGasLimit,
updateGasPrice,
+ setSelectedAddress,
// app messages
confirmSeedWords: confirmSeedWords,
showAccountDetail: showAccountDetail,
@@ -699,6 +700,19 @@ function setSelectedToken (tokenAddress) {
}
}
+function setSelectedAddress (address) {
+ return (dispatch) => {
+ dispatch(actions.showLoadingIndication())
+ log.debug(`background.setSelectedAddress`)
+ background.setSelectedAddress(address, (err) => {
+ dispatch(actions.hideLoadingIndication())
+ if (err) {
+ return dispatch(actions.displayWarning(err.message))
+ }
+ })
+ }
+}
+
function showAccountDetail (address) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
diff --git a/ui/app/components/send/currency-display.js b/ui/app/components/send/currency-display.js
index ed9847fdb..d56c119f1 100644
--- a/ui/app/components/send/currency-display.js
+++ b/ui/app/components/send/currency-display.js
@@ -100,9 +100,9 @@ CurrencyDisplay.prototype.render = function () {
this.setState({ value: newValue })
}
},
- onBlur: event => this.handleChangeInHexWei(event.target.value.split(' ')[0]),
- onKeyUp: event => resetCaretIfPastEnd(value || initValueToRender, event),
- onClick: event => resetCaretIfPastEnd(value || initValueToRender, event),
+ onBlur: event => !readOnly && this.handleChangeInHexWei(event.target.value.split(' ')[0]),
+ onKeyUp: event => !readOnly && resetCaretIfPastEnd(value || initValueToRender, event),
+ onClick: event => !readOnly && resetCaretIfPastEnd(value || initValueToRender, event),
}),
]),
diff --git a/ui/app/components/send/from-dropdown.js b/ui/app/components/send/from-dropdown.js
index e8e1d43f0..fd6fb7e64 100644
--- a/ui/app/components/send/from-dropdown.js
+++ b/ui/app/components/send/from-dropdown.js
@@ -19,7 +19,14 @@ FromDropdown.prototype.getListItemIcon = function (currentAccount, selectedAccou
: null
}
-FromDropdown.prototype.renderDropdown = function (accounts, selectedAccount, closeDropdown) {
+FromDropdown.prototype.renderDropdown = function () {
+ const {
+ accounts,
+ selectedAccount,
+ closeDropdown,
+ onSelect,
+ } = this.props
+
return h('div', {}, [
h('div.send-v2__from-dropdown__close-area', {
@@ -30,7 +37,10 @@ FromDropdown.prototype.renderDropdown = function (accounts, selectedAccount, clo
...accounts.map(account => h(AccountListItem, {
account,
- handleClick: () => console.log('Select identity'),
+ handleClick: () => {
+ onSelect(account.address)
+ closeDropdown()
+ },
icon: this.getListItemIcon(account, selectedAccount),
}))
@@ -43,7 +53,6 @@ FromDropdown.prototype.render = function () {
const {
accounts,
selectedAccount,
- setFromField,
openDropdown,
closeDropdown,
dropdownOpen,
@@ -57,7 +66,7 @@ FromDropdown.prototype.render = function () {
icon: h(`i.fa.fa-caret-down.fa-lg`, { style: { color: '#dedede' } })
}),
- dropdownOpen && this.renderDropdown(accounts, selectedAccount, closeDropdown),
+ dropdownOpen && this.renderDropdown(),
])
diff --git a/ui/app/components/send/send-v2-container.js b/ui/app/components/send/send-v2-container.js
index c3af1c972..5935a8fee 100644
--- a/ui/app/components/send/send-v2-container.js
+++ b/ui/app/components/send/send-v2-container.js
@@ -62,5 +62,10 @@ function mapDispatchToProps (dispatch) {
estimateGas: params => dispatch(actions.estimateGas(params)),
getGasPrice: () => dispatch(actions.getGasPrice()),
updateTokenExchangeRate: token => dispatch(actions.updateTokenExchangeRate(token)),
+ signTokenTx: (tokenAddress, toAddress, amount, txData) => (
+ dispatch(actions.signTokenTx(tokenAddress, toAddress, amount, txData))
+ ),
+ signTx: txParams => dispatch(actions.signTx(txParams)),
+ setSelectedAddress: address => dispatch(actions.setSelectedAddress(address))
}
}
diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js
index 314f6a666..f04b95800 100644
--- a/ui/app/send-v2.js
+++ b/ui/app/send-v2.js
@@ -105,6 +105,7 @@ SendTransactionScreen.prototype.render = function () {
selectedToken,
showCustomizeGasModal,
selectedAccount,
+ setSelectedAddress,
primaryCurrency = 'ETH',
gasLimit,
gasPrice,
@@ -150,7 +151,7 @@ SendTransactionScreen.prototype.render = function () {
dropdownOpen,
accounts,
selectedAccount,
- setFromField: () => console.log('Set From Field'),
+ onSelect: address => setSelectedAddress(address),
openDropdown: () => this.setState({ dropdownOpen: true }),
closeDropdown: () => this.setState({ dropdownOpen: false }),
conversionRate,
@@ -235,9 +236,43 @@ SendTransactionScreen.prototype.render = function () {
// Buttons underneath card
h('div.send-v2__footer', [
h('button.send-v2__cancel-btn', {}, 'Cancel'),
- h('button.send-v2__next-btn', {}, 'Next'),
+ h('button.send-v2__next-btn', {
+ onClick: event => this.onSubmit(event),
+ }, 'Next'),
]),
])
)
}
+
+SendTransactionScreen.prototype.onSubmit = function (event) {
+ event.preventDefault()
+ const {
+ to,
+ amount,
+ } = this.state
+ const {
+ gasLimit: gas,
+ gasPrice,
+ signTokenTx,
+ signTx,
+ selectedToken,
+ selectedAccount: { address: from },
+ } = this.props
+
+ const txParams = {
+ from,
+ value: '0',
+ gas,
+ gasPrice,
+ }
+
+ if (!selectedToken) {
+ txParams.value = amount
+ txParams.to = to
+ }
+
+ selectedToken
+ ? signTokenTx(selectedToken.address, to, amount, txParams)
+ : signTx(txParams)
+}