diff --git a/react/src/actions/actions/nativeSend.js b/react/src/actions/actions/nativeSend.js index e6cbfbc..fc3e3e2 100644 --- a/react/src/actions/actions/nativeSend.js +++ b/react/src/actions/actions/nativeSend.js @@ -286,15 +286,18 @@ export function getKMDOPID(opid, coin) { } } -export function sendFromPromise(coin, address, amount) { +export function sendToAddressPromise(coin, address, amount) { return new Promise((resolve, reject) => { const payload = { mode: null, chain: coin, - cmd: 'sendfrom', + cmd: 'sendtoaddress', params: [ address, - amount + amount, + 'KMD interest claim request', + 'KMD interest claim request', + true ] }; @@ -314,7 +317,7 @@ export function sendFromPromise(coin, address, amount) { console.log(error); dispatch( triggerToaster( - 'sendFrom', + 'sendToAddress', 'Error', 'error' ) @@ -322,7 +325,7 @@ export function sendFromPromise(coin, address, amount) { }) .then(response => response.json()) .then(json => { - resolve(json.result ? json.result : json); + resolve(json); }) }); } \ No newline at end of file diff --git a/react/src/components/dashboard/claimInterestModal/claimInterestModal.js b/react/src/components/dashboard/claimInterestModal/claimInterestModal.js index 95b70bb..94e05f5 100755 --- a/react/src/components/dashboard/claimInterestModal/claimInterestModal.js +++ b/react/src/components/dashboard/claimInterestModal/claimInterestModal.js @@ -6,7 +6,8 @@ import { getListUnspent, getRawTransaction, copyString, - sendFromPromise + sendToAddressPromise, + triggerToaster } from '../../../actions/actionCreators'; import { translate } from '../../../translate/translate'; import { @@ -36,12 +37,12 @@ class ClaimInterestModal extends React.Component { loadListUnspent() { let _transactionsList = []; - getListUnspent('KMD') + getListUnspent(this.props.ActiveCoin.coin) .then((json) => { if (json && json.length) { for (let i = 0; i < json.length; i++) { - getRawTransaction('KMD', json[i].txid) + getRawTransaction(this.props.ActiveCoin.coin, json[i].txid) .then((_json) => { _transactionsList.push({ address: json[i].address, @@ -64,11 +65,28 @@ class ClaimInterestModal extends React.Component { } claimInterest(address, amount) { - console.warn('claim interest', `${address} ${amount}`); - /*sendFromPromise(address, amount) + sendToAddressPromise(this.props.ActiveCoin.coin, this.state.transactionsList[0].address, this.props.ActiveCoin.balance.transparent) .then((json) => { - console.warn(json); - });*/ + if (json.error && + json.error.code) { + Store.dispatch( + triggerToaster( + json.error.message, + 'Error', + 'error' + ) + ); + } else if (json.result && json.result.length && json.result.length === 64) { + Store.dispatch( + triggerToaster( + `Your full balance is sent to address ${this.state.transactionsList[0].address}. Check back your new balance in a few minutes.`, + translate('TOASTR.WALLET_NOTIFICATION'), + 'success', + false + ) + ); + } + }); } checkTransactionsListLength() { diff --git a/react/src/components/dashboard/claimInterestModal/claimInterestModal.render.js b/react/src/components/dashboard/claimInterestModal/claimInterestModal.render.js index 8872fc2..8754965 100644 --- a/react/src/components/dashboard/claimInterestModal/claimInterestModal.render.js +++ b/react/src/components/dashboard/claimInterestModal/claimInterestModal.render.js @@ -30,14 +30,6 @@ export const _ClaimInterestTableRender = function() { <i className="fa-exclamation-circle red"></i> } </td> - <td> - <button - type="button" - className={ 'btn btn-success waves-effect waves-light' + (_transactionsList[i].interest < MIN_INTEREST_THRESHOLD ? ' show' : '') } - onClick={ () => this.claimInterest(_transactionsList[i].address, _transactionsList[i].amount) }> - <i className="icon fa-dollar"></i> Claim - </button> - </td> </tr> ); } @@ -46,7 +38,7 @@ export const _ClaimInterestTableRender = function() { return ( <span> <div className="padding-bottom-20"> - <strong>Requirements to accure interest:</strong> locktime field is set and amount is greater than 10 KMD + <strong>Requirements to accrue interest:</strong> locktime field is set and amount is greater than <strong>10 KMD</strong> </div> <div className="text-left padding-top-10 padding-bottom-10"> <label className="switch"> @@ -63,6 +55,12 @@ export const _ClaimInterestTableRender = function() { Show zero interest </div> </div> + <button + type="button" + className="btn btn-success waves-effect waves-light claim-btn" + onClick={ () => this.claimInterest() }> + <i className="icon fa-dollar"></i> Claim interest + </button> <div className="table-scroll"> <table className="table table-hover dataTable table-striped"> <thead> @@ -72,7 +70,6 @@ export const _ClaimInterestTableRender = function() { <th>Amount</th> <th>Interest</th> <th>Locktime</th> - <th></th> </tr> </thead> <tbody> @@ -85,7 +82,6 @@ export const _ClaimInterestTableRender = function() { <th>Amount</th> <th>Interest</th> <th>Locktime</th> - <th></th> </tr> </tfoot> </table> @@ -94,10 +90,6 @@ export const _ClaimInterestTableRender = function() { ); }; - //{ this.renderAddressList('public') } - //{ this.isNativeMode() && this.renderAddressList('private') } - - export const ClaimInterestModalRender = function() { return ( <span> diff --git a/react/src/components/dashboard/jumblr/jumblr.js b/react/src/components/dashboard/jumblr/jumblr.js index d75b948..a69dbd1 100755 --- a/react/src/components/dashboard/jumblr/jumblr.js +++ b/react/src/components/dashboard/jumblr/jumblr.js @@ -169,7 +169,7 @@ class Jumblr extends React.Component { json.error.code) { Store.dispatch( triggerToaster( - json.error.code, + json.error.message, 'Error', 'error' ) @@ -299,7 +299,7 @@ class Jumblr extends React.Component { } else { Store.dispatch( triggerToaster( - json.error.code, + json.error.message, 'Error', 'error' ) @@ -348,7 +348,7 @@ class Jumblr extends React.Component { json.error.code) { Store.dispatch( triggerToaster( - json.error.code, + json.error.message, 'Error', 'error' ) @@ -372,7 +372,7 @@ class Jumblr extends React.Component { } else { Store.dispatch( triggerToaster( - json.error.code, + json.error.message, 'Error', 'error' ) diff --git a/react/src/components/overrides.scss b/react/src/components/overrides.scss index ed599ec..b074e1f 100644 --- a/react/src/components/overrides.scss +++ b/react/src/components/overrides.scss @@ -851,6 +851,11 @@ select{ padding: 8px 30px 8px 0; } + .claim-btn { + position: absolute; + right: 29px; + top: 66px; + } .table-scroll { height: 366px; overflow-y: auto;