1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-22 17:33:23 +01:00

Merge pull request #189 from MetaMask/hotfixsendTx

ui - sendTx - re-add warning and fix form parsing
This commit is contained in:
Dan Finlay 2016-05-18 13:57:49 -07:00
commit c85c594d5b

View File

@ -21,6 +21,8 @@ function mapStateToProps(state) {
warning: state.appState.warning, warning: state.appState.warning,
} }
result.error = result.warning && result.warning.split('.')[0]
result.account = result.accounts[result.address] result.account = result.accounts[result.address]
result.identity = result.identities[result.address] result.identity = result.identities[result.address]
result.balance = result.account ? numericBalance(result.account.balance) : null result.balance = result.account ? numericBalance(result.account.balance) : null
@ -130,9 +132,13 @@ SendTransactionScreen.prototype.render = function() {
'Send Transaction', 'Send Transaction',
]), ]),
// error message
state.error && h('span.error.flex-center', state.error),
// 'to' field // 'to' field
h('section.flex-row.flex-center', [ h('section.flex-row.flex-center', [
h('input.address.large-input', { h('input.large-input', {
name: 'address',
placeholder: 'Recipient Address', placeholder: 'Recipient Address',
}) })
]), ]),
@ -140,7 +146,8 @@ SendTransactionScreen.prototype.render = function() {
// 'amount' and send button // 'amount' and send button
h('section.flex-row.flex-center', [ h('section.flex-row.flex-center', [
h('input.ether.large-input', { h('input.large-input', {
name: 'amount',
placeholder: 'Amount', placeholder: 'Amount',
type: 'number', type: 'number',
style: { style: {
@ -174,7 +181,8 @@ SendTransactionScreen.prototype.render = function() {
// 'data' field // 'data' field
h('section.flex-row.flex-center', [ h('section.flex-row.flex-center', [
h('input.txData.large-input', { h('input.large-input', {
name: 'txData',
placeholder: '0x01234', placeholder: '0x01234',
style: { style: {
width: '100%', width: '100%',
@ -183,8 +191,6 @@ SendTransactionScreen.prototype.render = function() {
}), }),
]), ]),
// state.warning ? h('span.error', state.warning.split('.')[0]) : null,
]) ])
) )
@ -201,11 +207,10 @@ SendTransactionScreen.prototype.back = function() {
} }
SendTransactionScreen.prototype.onSubmit = function(event) { SendTransactionScreen.prototype.onSubmit = function(event) {
var recipient = document.querySelector('input.address').value var recipient = document.querySelector('input[name="address"]').value
var inputAmount = parseFloat(document.querySelector('input.ether').value) var inputAmount = parseFloat(document.querySelector('input[name="amount"]').value)
var currency = document.querySelector('select.currency').value var value = util.normalizeNumberToWei(inputAmount, 'ether')
var value = util.normalizeNumberToWei(inputAmount, currency)
var balance = this.props.balance var balance = this.props.balance
@ -227,7 +232,7 @@ SendTransactionScreen.prototype.onSubmit = function(event) {
value: '0x' + value.toString(16), value: '0x' + value.toString(16),
} }
var txData = document.querySelector('textarea.txData').value var txData = document.querySelector('input[name="txData"]').value
if (txData) txParams.data = txData if (txData) txParams.data = txData
this.props.dispatch(actions.signTx(txParams)) this.props.dispatch(actions.signTx(txParams))