Browse Source

get both private and public native addr

all-modes
pbca26 8 years ago
parent
commit
4ba4d6be0e
  1. 109
      react/src/actions/actionCreators.js
  2. 2
      react/src/components/dashboard/coinTileItem.js
  3. 10
      react/src/components/dashboard/walletsNativeReceive.js
  4. 44
      react/src/components/dashboard/walletsNativeSend.js
  5. 1
      react/src/components/dashboard/walletsNativeTxHistory.js

109
react/src/actions/actionCreators.js

@ -48,8 +48,6 @@ export function toggleDashboardActiveSection(name) {
} }
export function toggleDashboardTxInfoModal(display, txIndex) { export function toggleDashboardTxInfoModal(display, txIndex) {
console.log('toggleTxInfoModal', txIndex);
return { return {
type: DASHBOARD_ACTIVE_TXINFO_MODAL, type: DASHBOARD_ACTIVE_TXINFO_MODAL,
showTransactionInfo: display, showTransactionInfo: display,
@ -811,7 +809,12 @@ function getKMDAddressesNativeState(json) {
} }
} }
export function getKMDAddressesNative(coin, pubpriv) { export function getKMDAddressesNative(coin) {
const type = ['public', 'private'];
return dispatch => {
Promise.all(type.map((_type, index) => {
return new Promise((resolve, reject) => {
var payload, var payload,
ajax_data_to_hex = '', ajax_data_to_hex = '',
ajax_function_input = '', ajax_function_input = '',
@ -819,11 +822,11 @@ export function getKMDAddressesNative(coin, pubpriv) {
passthru_agent = getPassthruAgent(coin), passthru_agent = getPassthruAgent(coin),
tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'); tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
if ( pubpriv === 'public' ) { if ( _type === 'public' ) {
ajax_function_input = 'getaddressesbyaccount'; ajax_function_input = 'getaddressesbyaccount';
tmplistaddr_hex_input = '222200'; tmplistaddr_hex_input = '222200';
} }
if ( pubpriv === 'private' ) { if ( _type === 'private' ) {
ajax_function_input = 'z_listaddresses'; ajax_function_input = 'z_listaddresses';
tmplistaddr_hex_input = ''; tmplistaddr_hex_input = '';
} }
@ -847,8 +850,7 @@ export function getKMDAddressesNative(coin, pubpriv) {
}; };
} }
return dispatch => { fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
@ -857,42 +859,14 @@ export function getKMDAddressesNative(coin, pubpriv) {
dispatch(triggerToaster(true, 'getKMDAddressesNative', 'Error', 'error')); dispatch(triggerToaster(true, 'getKMDAddressesNative', 'Error', 'error'));
}) })
.then(response => response.json()) .then(response => response.json())
.then(json => dispatch(getKMDAddressesNativeState(json, dispatch))) .then(json => resolve(json))
}
}
/*function KMDListAddresses(pubpriv) {
NProgress.done(true);
NProgress.configure({
template: templates.nprogressBar
}); });
NProgress.start(); }))
.then(result => {
dispatch(getKMDAddressesNativeState(result[0].concat(result[1])));
$.ajax({
async: false,
type: 'POST',
data: JSON.stringify(ajax_data),
url: 'http://127.0.0.1:' + config.iguanaPort,
success: function(data, textStatus, jqXHR) {
var AjaxOutputData = JSON.parse(data); // Ajax output gets the whole list of unspent coin with addresses
result = AjaxOutputData;
},
error: function(xhr, textStatus, error) {
console.log('failed getting Coin History.');
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
Iguana_ServiceUnavailable();
}
console.log(textStatus);
console.log(error);
}
}); });
}
NProgress.done(); }
return result;
}*/
function getDebugLogState(json) { function getDebugLogState(json) {
const _data = json.result.replace('\n', '\r\n'); const _data = json.result.replace('\n', '\r\n');
@ -1175,6 +1149,59 @@ export function getNativeTxHistoryState(json) {
} }
} }
function handleGetNewKMDAddresses(pubpriv, coin, dispatch) {
dispatch(triggerToaster(true, translate('KMD_NATIVE.NEW_ADDR_GENERATED'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
dispatch(getKMDAddressesNative(coin));
return {};
}
export function getNewKMDAddresses(coin, pubpriv) {
var payload,
ajax_function_input = '';
if ( pubpriv === 'public' ) {
ajax_function_input = 'getnewaddress';
}
if ( pubpriv === 'private' ) {
ajax_function_input = 'z_getnewaddress';
}
if (getPassthruAgent(coin) === 'iguana') {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': getPassthruAgent(coin),
'method': 'passthru',
'asset': coin,
'function': ajax_function_input,
'hex': ''
};
} else {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': coin,
'method': 'passthru',
'function': ajax_function_input,
'hex': ''
};
}
return dispatch => {
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getNewKMDAddresses', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(handleGetNewKMDAddresses(pubpriv, coin, dispatch)))
.catch(function(ex) {
dispatch(handleGetNewKMDAddresses(pubpriv, coin, dispatch))
})
}
}
/*function Shepherd_SendPendValue() { /*function Shepherd_SendPendValue() {
Shepherd_SysInfo().then(function(result){ Shepherd_SysInfo().then(function(result){
var ram_data = formatBytes(result.totalmem_bytes) var ram_data = formatBytes(result.totalmem_bytes)

2
react/src/components/dashboard/coinTileItem.js

@ -38,7 +38,7 @@ class CoinTileItem extends React.Component {
Store.dispatch(getSyncInfoNative(coin)); Store.dispatch(getSyncInfoNative(coin));
Store.dispatch(getKMDBalanceTotal(coin)); Store.dispatch(getKMDBalanceTotal(coin));
Store.dispatch(getNativeTxHistory(coin)); Store.dispatch(getNativeTxHistory(coin));
Store.dispatch(getKMDAddressesNative(coin, 'public')); Store.dispatch(getKMDAddressesNative(coin));
}, coin === 'KMD' ? 15000 : 3000); }, coin === 'KMD' ? 15000 : 3000);
Store.dispatch(startInterval('sync', _iguanaActiveHandle)); Store.dispatch(startInterval('sync', _iguanaActiveHandle));
} else { } else {

10
react/src/components/dashboard/walletsNativeReceive.js

@ -1,5 +1,7 @@
import React from 'react'; import React from 'react';
import { translate } from '../../translate/translate'; import { translate } from '../../translate/translate';
import { getNewKMDAddresses } from '../../actions/actionCreators';
import Store from '../../store';
class WalletsNativeReceive extends React.Component { class WalletsNativeReceive extends React.Component {
constructor(props) { constructor(props) {
@ -35,6 +37,10 @@ class WalletsNativeReceive extends React.Component {
} }
} }
getNewAddress(type) {
Store.dispatch(getNewKMDAddresses(this.props.ActiveCoin.coin, type));
}
render() { render() {
if (this.props && this.props.ActiveCoin && this.props.ActiveCoin.nativeActiveSection === 'receive') { if (this.props && this.props.ActiveCoin && this.props.ActiveCoin.nativeActiveSection === 'receive') {
return ( return (
@ -52,12 +58,12 @@ class WalletsNativeReceive extends React.Component {
</a> </a>
<ul className="dropdown-menu dropdown-menu-right" aria-labelledby="GetNewRecievingAddress" role="menu"> <ul className="dropdown-menu dropdown-menu-right" aria-labelledby="GetNewRecievingAddress" role="menu">
<li role="presentation"> <li role="presentation">
<a href="javascript:void(0)" data-extcoin="COIN" id="kmd_get_new_taddr" role="menuitem"> <a href="javascript:void(0)" data-extcoin="COIN" id="kmd_get_new_taddr" role="menuitem" onClick={() => this.getNewAddress('public')}>
<i className="icon fa-eye" aria-hidden="true"></i> {translate('INDEX.TRANSPARENT_ADDRESS')} <i className="icon fa-eye" aria-hidden="true"></i> {translate('INDEX.TRANSPARENT_ADDRESS')}
</a> </a>
</li> </li>
<li data-extcoin="COIN" role="presentation"> <li data-extcoin="COIN" role="presentation">
<a href="javascript:void(0)" data-extcoin="COIN" id="kmd_get_new_zaddr" role="menuitem"> <a href="javascript:void(0)" data-extcoin="COIN" id="kmd_get_new_zaddr" role="menuitem" onClick={() => this.getNewAddress('private')}>
<i className="icon fa-eye-slash" aria-hidden="true"></i> {translate('INDEX.PRIVATE_Z_ADDRESS')} <i className="icon fa-eye-slash" aria-hidden="true"></i> {translate('INDEX.PRIVATE_Z_ADDRESS')}
</a> </a>
</li> </li>

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

@ -2,6 +2,34 @@ import React from 'react';
import { translate } from '../../translate/translate'; import { translate } from '../../translate/translate';
class WalletsNativeSend extends React.Component { class WalletsNativeSend extends React.Component {
constructor(props) {
super(props);
this.state = {
form: null,
to: null,
amount: 0,
fee: 0.0001,
};
this.updateInput = this.updateInput.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
renderAddressList() {
return this.props.ActiveCoin.addresses.map((address) =>
<option key={address} value={address}>{address}</option>
);
}
updateInput(e) {
this.setState({
[e.target.name]: e.target.value,
});
}
handleSubmit() {
console.log(this.state);
}
render() { render() {
if (this.props && this.props.ActiveCoin && this.props.ActiveCoin.nativeActiveSection === 'send') { if (this.props && this.props.ActiveCoin && this.props.ActiveCoin.nativeActiveSection === 'send') {
return ( return (
@ -18,30 +46,32 @@ class WalletsNativeSend extends React.Component {
<div className="row"> <div className="row">
<div className="col-xlg-12 form-group form-material"> <div className="col-xlg-12 form-group form-material">
<label className="control-label" data-extcoin="COIN" htmlFor="kmd_wallet_send_from">{translate('INDEX.SEND_FROM')}</label> <label className="control-label" data-extcoin="COIN" htmlFor="kmd_wallet_send_from">{translate('INDEX.SEND_FROM')}</label>
<select className="form-control form-material showkmdwalletaddrs show-tick" data-extcoin="COIN" id="kmd_wallet_send_from" title="Select Transparent or Private Address" data-size="5"></select> <select className="form-control form-material showkmdwalletaddrs show-tick" name="from" onChange={this.updateInput} data-extcoin="COIN" id="kmd_wallet_send_from" title="Select Transparent or Private Address" data-size="5">
{this.renderAddressList()}
</select>
</div> </div>
<div className="col-xlg-12 form-group form-material"> <div className="col-xlg-12 form-group form-material">
<label className="control-label" data-extcoin="COIN" htmlFor="kmd_wallet_sendto">{translate('INDEX.SEND_TO')}</label> <label className="control-label" data-extcoin="COIN" htmlFor="kmd_wallet_sendto">{translate('INDEX.SEND_TO')}</label>
<input type="text" className="form-control" data-extcoin="COIN" id="kmd_wallet_sendto" name="kmd_wallet_sendto" placeholder="Enter Transparent or Private address" autoComplete="off" required /> <input type="text" className="form-control" data-extcoin="COIN" name="to" onChange={this.updateInput} id="kmd_wallet_sendto" placeholder="Enter Transparent or Private address" autoComplete="off" required />
</div> </div>
<div className="col-lg-6 form-group form-material"> <div className="col-lg-6 form-group form-material">
<label className="control-label" htmlFor="kmd_wallet_amount" data-extcoin="COIN" id="kmd_wallet_amount_label"> <label className="control-label" htmlFor="kmd_wallet_amount" data-extcoin="COIN" id="kmd_wallet_amount_label">
<span data-extcoinname="COIN"></span> <span data-extcoinname="COIN"></span>
</label> </label>
<input type="text" className="form-control" data-extcoin="COIN" id="kmd_wallet_amount" name="kmd_wallet_amount" placeholder="0.000" autoComplete="off" /> <input type="text" className="form-control" name="amount" onChange={this.updateInput} data-extcoin="COIN" id="kmd_wallet_amount" placeholder="0.000" autoComplete="off" />
</div> </div>
<div className="col-lg-6 form-group form-material"> <div className="col-lg-6 form-group form-material">
<label className="control-label" data-extcoin="COIN" htmlFor="kmd_wallet_fee">{translate('INDEX.FEE')}</label> <label className="control-label" data-extcoin="COIN" htmlFor="kmd_wallet_fee">{translate('INDEX.FEE')}</label>
<input type="text" className="form-control" data-extcoin="COIN" id="kmd_wallet_fee" name="kmd_wallet_fee" placeholder="0.000" value="0.0001" autoComplete="off" /> <input type="text" className="form-control" name="fee" onChange={this.updateInput} data-extcoin="COIN" id="kmd_wallet_fee" placeholder="0.000" value={this.state.fee} autoComplete="off" />
</div> </div>
<div className="col-lg-12"> <div className="col-lg-12">
<span data-extcoin="KMD"> <span data-extcoin="KMD">
<b>{translate('INDEX.TOTAL')} (<span data-extcoinname="COIN"></span> - txfee):</b> <span data-extcoin="COIN" id="kmd_wallet_total_value">0.000</span> <span data-extcoin="COIN" id="kmd_wallet_total_coinname" data-extcoinname="COIN"></span> <b>{translate('INDEX.TOTAL')}:</b> {this.state.amount} + {this.state.fee}/kb {this.props.ActiveCoin.coin}
</span> </span>
</div> </div>
<div className="col-lg-12"> <div className="col-lg-12">
<button type="submit" className="btn btn-primary waves-effect waves-light pull-right" data-toggle="modal" id="kmd_wallet_send_coins_btn"> <button type="button" className="btn btn-primary waves-effect waves-light pull-right" data-toggle="modal" id="kmd_wallet_send_coins_btn" onClick={this.handleSubmit}>
{translate('INDEX.SEND')} <span data-extcoinname="COIN"></span> {translate('INDEX.SEND')} {this.state.amount} {this.props.ActiveCoin.coin}
</button> </button>
</div> </div>
</div> </div>

1
react/src/components/dashboard/walletsNativeTxHistory.js

@ -10,6 +10,7 @@ class WalletsNativeTxHistory extends React.Component {
} }
// TODO: implement sorting and pagination // TODO: implement sorting and pagination
// z transactions
toggleTxInfoModal(display, txIndex) { toggleTxInfoModal(display, txIndex) {
Store.dispatch(toggleDashboardTxInfoModal(display, txIndex)); Store.dispatch(toggleDashboardTxInfoModal(display, txIndex));

Loading…
Cancel
Save