diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ca309165..343ef0c7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Current Master +- [#334](https://github.com/poanetwork/nifty-wallet/pull/334) - (Feature) Ability to set tx value for payable methods - [#333](https://github.com/poanetwork/nifty-wallet/pull/333) - (Fix) Support RSK testnet explorer links - [#332](https://github.com/poanetwork/nifty-wallet/pull/332) - (Chore) Return to main screen from removal of imported account - [#330](https://github.com/poanetwork/nifty-wallet/pull/330) - (Fix) Derive correct addresses for custom networks (RSK/ETC) diff --git a/old-ui/app/components/delete-rpc.js b/old-ui/app/components/delete-rpc.js index f72473125..48eddaee0 100644 --- a/old-ui/app/components/delete-rpc.js +++ b/old-ui/app/components/delete-rpc.js @@ -6,7 +6,7 @@ import actions from '../../../ui/app/actions' class DeleteRpc extends ConfirmScreen { static propTypes = { } - + render () { const props = this.props return ( diff --git a/old-ui/app/components/send/choose-contract-executor.js b/old-ui/app/components/send/choose-contract-executor.js index 0236b582e..7e0ecd969 100644 --- a/old-ui/app/components/send/choose-contract-executor.js +++ b/old-ui/app/components/send/choose-contract-executor.js @@ -184,7 +184,7 @@ class ChooseContractExecutor extends Component { return new Promise((resolve) => { try { - web3.eth.contract(abi).at(txParams.to)[method].call((err, output) => { + web3.eth.contract(abi).at(txParams.to)[method].call((_err, output) => { resolve(output) }) } catch (e) { diff --git a/old-ui/app/components/send/send-contract.js b/old-ui/app/components/send/send-contract.js index 376ca99e6..90586cdac 100644 --- a/old-ui/app/components/send/send-contract.js +++ b/old-ui/app/components/send/send-contract.js @@ -12,6 +12,7 @@ import abi from 'web3-eth-abi' import Web3 from 'web3' import copyToClipboard from 'copy-to-clipboard' import CopyButton from '../copy/copy-button' +import { normalizeEthStringToWei } from '../../util' class SendTransactionField extends Component { constructor (props) { @@ -130,6 +131,7 @@ class SendTransactionScreen extends PersistentForm { methodOutputsView: [], isConstantMethod: false, inputValues: props.inputValues || {}, + txValue: props.txValue || '0x', outputValues: props.outputValues || {}, copyDisabled: true, } @@ -167,6 +169,7 @@ class SendTransactionScreen extends PersistentForm { methodABI: opt.metadata, outputValues: {}, inputValues: {}, + txValue: '0x', }, () => { this.generateMethodFieldsView(opt.metadata) }) @@ -251,7 +254,7 @@ class SendTransactionScreen extends PersistentForm { } const textTypeProps = { key: Math.random(), - placeholder: params.type, + placeholder: params.placeholder || params.type, } if (params.type === 'bool' && isInput) { field = ( @@ -277,17 +280,25 @@ class SendTransactionScreen extends PersistentForm { handleInputChange (val, type, ind) { const { inputValues } = this.state + let { txValue } = this.state if (val) { if (type === 'bool') { inputValues[ind] = (val === 'true') + } else if (type === 'value') { + const valWei = normalizeEthStringToWei(val) + txValue = '0x' + parseInt(valWei, 10).toString(16) } else { inputValues[ind] = val } } else { delete inputValues[ind] + if (type === 'value') { + txValue = '0x' + } } this.setState({ inputValues, + txValue, }) } @@ -302,9 +313,13 @@ class SendTransactionScreen extends PersistentForm { const methodInputs = metadata && metadata.inputs const methodOutputsView = [] const methodOutputs = metadata && metadata.outputs + if (metadata.stateMutability === 'payable') { + methodInputsView.push(this.generateMethodField({'name': 'tx value', 'type': 'value', 'placeholder': 'tx value in Ether' }, methodInputs.length, true)) + } methodInputs.forEach((input, ind) => { methodInputsView.push(this.generateMethodField(input, ind, true)) }) + methodOutputs.forEach((output, ind) => { methodOutputsView.push(this.generateMethodField(output, ind, false)) }) @@ -448,7 +463,7 @@ class SendTransactionScreen extends PersistentForm { } onSubmit = () => { - const { inputValues, methodABI, methodSelected } = this.state + const { inputValues, txValue, methodABI, methodSelected } = this.state const { address } = this.props const txData = this.encodeFunctionCall() @@ -456,7 +471,7 @@ class SendTransactionScreen extends PersistentForm { this.props.hideWarning() const txParams = { - value: '0x', + value: txValue, data: txData, to: address, } diff --git a/ui/app/actions.js b/ui/app/actions.js index 30fed7e42..a45bff18f 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -1000,7 +1000,7 @@ function signTypedMsg (msgData) { function signTx (txData) { return (dispatch) => { - global.ethQuery.sendTransaction(txData, (err, data) => { + global.ethQuery.sendTransaction(txData, (err, _data) => { if (err) { return dispatch(actions.displayWarning(err.message)) }