Browse Source

native send address dropdown fix; substract fee toggle

all-modes
pbca26 8 years ago
parent
commit
a45e06aa56
  1. 46
      react/src/actions/actions/nativeSend.js
  2. 53
      react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js
  3. 20
      react/src/components/dashboard/walletsNativeSend/walletsNativeSend.render.js
  4. 2
      react/src/translate/en.js

46
react/src/actions/actions/nativeSend.js

@ -71,10 +71,20 @@ export function sendNativeTx(coin, _payload) {
cmd: payload.function,
params:
(_payload.addressType === 'public' && _payload.sendTo.length !== 95) || !_payload.sendFrom ?
[
_payload.sendTo,
_payload.amount
]
(_payload.substractFee ?
[
_payload.sendTo,
_payload.amount,
'',
'',
true
]
:
[
_payload.sendTo,
_payload.amount
]
)
:
[
_payload.sendFrom,
@ -134,25 +144,31 @@ export function sendNativeTx(coin, _payload) {
json.indexOf('"},"id":"jl777"')
);
dispatch(
triggerToaster(
true,
_message,
translate('TOASTR.WALLET_NOTIFICATION'),
'error'
)
);
if (json.indexOf('"code":-4') > -1) {
dispatch(
triggerToaster(
true,
translate('TOASTR.WALLET_NOTIFICATION'),
translate('API.WALLETDAT_MISMATCH'),
translate('TOASTR.WALLET_NOTIFICATION'),
'info',
false
)
);
} else if (json.indexOf('"code":-5') > -1) {
dispatch(
triggerToaster(
`Invalid ${coin} address`,
translate('TOASTR.WALLET_NOTIFICATION'),
'error',
)
);
} else {
dispatch(
triggerToaster(
_message,
translate('TOASTR.WALLET_NOTIFICATION'),
'error'
)
);
}
} else {
dispatch(

53
react/src/components/dashboard/walletsNativeSend/walletsNativeSend.js

@ -31,6 +31,7 @@ class WalletsNativeSend extends React.Component {
fee: 0,
addressSelectorOpen: false,
renderAddressDropdown: true,
substractFee: false,
};
this.updateInput = this.updateInput.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
@ -41,10 +42,18 @@ class WalletsNativeSend extends React.Component {
this.setRecieverFromScan = this.setRecieverFromScan.bind(this);
this.renderOPIDListCheck = this.renderOPIDListCheck.bind(this);
this.WalletsNativeSendFormRender = _WalletsNativeSendFormRender.bind(this);
this.isTransparentTx = this.isTransparentTx.bind(this);
this.toggleSubstractFee = this.toggleSubstractFee.bind(this);
}
WalletsNativeSendFormRender() {
return this._WalletsNativeSendFormRender();
return _WalletsNativeSendFormRender.call(this);
}
toggleSubstractFee() {
this.setState({
substractFee: !this.state.substractFee,
});
}
componentWillMount() {
@ -166,20 +175,20 @@ class WalletsNativeSend extends React.Component {
const _satatusDef = {
queued: {
icon: 'warning',
label: 'QUEUED'
label: 'QUEUED',
},
executing: {
icon: 'info',
label: 'EXECUTING'
label: 'EXECUTING',
},
failed: {
icon: 'danger',
label: 'FAILED'
label: 'FAILED',
},
success: {
icon: 'success',
label: 'SUCCESS'
}
label: 'SUCCESS',
},
};
return (
@ -219,7 +228,7 @@ class WalletsNativeSend extends React.Component {
isWaitingStatus = false;
return (
<span>
<strong>txid:</strong> <span>{ opid.result.txid }</span>
<strong>{ translate('KMD_NATIVE.TXID') }:</strong> <span>{ opid.result.txid }</span>
<br />
<strong>{ translate('KMD_NATIVE.EXECUTION_SECONDS') }:</strong> <span>{ opid.execution_secs }</span>
</span>
@ -302,6 +311,7 @@ class WalletsNativeSend extends React.Component {
fee: 0,
addressSelectorOpen: false,
renderAddressDropdown: true,
substractFee: false,
});
}
@ -365,11 +375,12 @@ class WalletsNativeSend extends React.Component {
validateSendFormData() {
let valid = true;
if (!this.state.sendTo || this.state.sendTo.length < 34) {
if (!this.state.sendTo ||
this.state.sendTo.length < 34) {
Store.dispatch(
triggerToaster(
translate('SEND.SEND_TO_ADDRESS_MIN_LENGTH'),
'',
translate('TOASTR.WALLET_NOTIFICATION'),
'error'
)
);
@ -380,7 +391,7 @@ class WalletsNativeSend extends React.Component {
Store.dispatch(
triggerToaster(
translate('SEND.AMOUNT_POSITIVE_NUMBER'),
'',
translate('TOASTR.WALLET_NOTIFICATION'),
'error'
)
);
@ -391,7 +402,19 @@ class WalletsNativeSend extends React.Component {
Store.dispatch(
triggerToaster(
translate('SEND.INSUFFICIENT_FUNDS'),
'',
translate('TOASTR.WALLET_NOTIFICATION'),
'error'
)
);
valid = false;
}
if (this.state.sendTo.length > 34 &&
(!this.state.sendFrom || this.state.sendFrom.length < 34)) {
Store.dispatch(
triggerToaster(
translate('SEND.SELECT_SOURCE_ADDRESS'),
translate('TOASTR.WALLET_NOTIFICATION'),
'error'
)
);
@ -401,6 +424,14 @@ class WalletsNativeSend extends React.Component {
return valid;
}
isTransparentTx() {
if (((this.state.sendFrom && this.state.sendFrom.length === 34) || !this.state.sendFrom) &&
(this.state.sendTo && this.state.sendTo.length === 34)) {
return true;
}
return false;
}
render() {
if (this.props &&

20
react/src/components/dashboard/walletsNativeSend/walletsNativeSend.render.js

@ -27,6 +27,7 @@ export const AddressListRender = function() {
style={{ display: this.state.sendFrom === null ? 'inline-block' : 'none' }}></span>
</a>
</li>
{ this.renderAddressByType('public') }
{ this.renderAddressByType('private') }
</ul>
</div>
@ -74,7 +75,7 @@ export const _WalletsNativeSendFormRender = function() {
{ this.state.renderAddressDropdown &&
<div className="row">
<div className="col-xlg-12 form-group form-material">
<label className="control-label">{ translate('INDEX.SEND_FROM') }</label>
<label className="control-label padding-bottom-10">{ translate('INDEX.SEND_FROM') }</label>
{ this.renderAddressList() }
</div>
</div>
@ -112,6 +113,23 @@ export const _WalletsNativeSendFormRender = function() {
placeholder="0.000"
autoComplete="off" />
</div>
<div className={ 'col-lg-6 form-group form-material' + (this.isTransparentTx() ? '' : ' hide') }>
<span className="pointer">
<label className="switch">
<input
type="checkbox"
checked={ this.state.substractFee } />
<div
className="slider"
onClick={ () => this.toggleSubstractFee() }></div>
</label>
<div
className="toggle-label"
onClick={ () => this.toggleSubstractFee() }>
Substract fee from amount
</div>
</span>
</div>
<div className="col-lg-6 form-group form-material hide">
<label
className="control-label"

2
react/src/translate/en.js

@ -544,6 +544,7 @@ export const _lang = {
'MESSAGE': 'Message',
'EXECUTION_SECONDS': 'Execution Seconds',
'WAIT_UNTIL_SYNCED': 'Transaction history is unavailable during synchronization progresss',
'TXID': 'Transaction ID',
},
'LOGIN': {
'QUICK_ACCESS': 'Quick access',
@ -638,6 +639,7 @@ export const _lang = {
'FEE_POSITIVE_NUMBER': 'Fee must be a positive number',
'TOTAL_AMOUNT_POSITIVE_NUMBER': 'Total amount (amount - fee) must be a positive number',
'INSUFFICIENT_FUNDS': 'You don\'t have the necessary funds to make this transaction',
'SELECT_SOURCE_ADDRESS': 'Select source (from) address',
},
'FIAT_CURRENCIES': {
'AUD': 'Australian Dollar (AUD)',

Loading…
Cancel
Save