Browse Source

native send, opids list

all-modes
pbca26 8 years ago
parent
commit
92ce252059
  1. 67
      react/src/actions/actionCreators.js
  2. BIN
      react/src/assets/images/cryptologo/GAME.png
  3. 4
      react/src/components/dashboard/coinTileItem.js
  4. 8
      react/src/components/dashboard/walletsNativeReceive.js
  5. 97
      react/src/components/dashboard/walletsNativeSend.js
  6. 8
      react/src/reducers/activeCoin.js

67
react/src/actions/actionCreators.js

@ -39,6 +39,7 @@ export const DASHBOARD_ACTIVE_SECTION = 'DASHBOARD_ACTIVE_SECTION';
export const DASHBOARD_ACTIVE_TXINFO_MODAL = 'DASHBOARD_ACTIVE_TXINFO_MODAL';
export const DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE = 'DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE';
export const DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY = 'DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY';
export const DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS = 'DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS';
export function toggleDashboardActiveSection(name) {
return {
@ -1341,11 +1342,75 @@ export function sendNativeTx(coin, _payload) {
dispatch(triggerToaster(true, 'sendNativeTx', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success')));
.then(json => dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success')))
.catch(function(ex) {
dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
console.log('parsing failed', ex);
})
});
}
}
export function getKMDOPIDState(json) {
return {
type: DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS,
opids: json,
}
}
export function getKMDOPID(opid, coin) {
var tmpopid_output = '',
ajax_data_to_hex;
if ( opid === undefined ) {
ajax_data_to_hex = null;
} else {
ajax_data_to_hex = '["' + opid + '"]';
}
return dispatch => {
return iguanaHashHex(ajax_data_to_hex).then((hashHexJson) => {
if (hashHexJson === '5b226e756c6c225d00') {
hashHexJson = '';
}
var payload,
passthru_agent = getPassthruAgent(coin),
tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
if (passthru_agent == 'iguana') {
payload = {
'userpass': tmpIguanaRPCAuth,
'agent': passthru_agent,
'method': 'passthru',
'asset': coin,
'function': 'z_getoperationstatus',
'hex': hashHexJson
};
} else {
payload = {
'userpass': tmpIguanaRPCAuth,
'agent': passthru_agent,
'method': 'passthru',
'function': 'z_getoperationstatus',
'hex': hashHexJson
};
}
fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getKMDOPID', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(getKMDOPIDState(json)))
})
}
}
/*function Shepherd_SendPendValue() {
Shepherd_SysInfo().then(function(result){
var ram_data = formatBytes(result.totalmem_bytes)

BIN
react/src/assets/images/cryptologo/GAME.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

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

@ -11,7 +11,8 @@ import {
getSyncInfoNative,
getKMDBalanceTotal,
getNativeTxHistory,
getKMDAddressesNative
getKMDAddressesNative,
getKMDOPID
} from '../../actions/actionCreators';
import Store from '../../store';
@ -39,6 +40,7 @@ class CoinTileItem extends React.Component {
Store.dispatch(getKMDBalanceTotal(coin));
Store.dispatch(getNativeTxHistory(coin));
Store.dispatch(getKMDAddressesNative(coin));
Store.dispatch(getKMDOPID(null, coin));
}, coin === 'KMD' ? 15000 : 3000);
Store.dispatch(startInterval('sync', _iguanaActiveHandle));
} else {

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

@ -1,6 +1,6 @@
import React from 'react';
import { translate } from '../../translate/translate';
import { getNewKMDAddresses } from '../../actions/actionCreators';
import { getNewKMDAddresses, copyCoinAddress } from '../../actions/actionCreators';
import Store from '../../store';
// TODO: add addr balance
@ -20,6 +20,10 @@ class WalletsNativeReceive extends React.Component {
}));
}
copyZAddress(address) {
Store.dispatch(copyCoinAddress(address));
}
renderAddressList(type) {
console.log(this.props.ActiveCoin.addresses[type]);
if (this.props.ActiveCoin.addresses[type] && this.props.ActiveCoin.addresses[type].length) {
@ -29,6 +33,8 @@ class WalletsNativeReceive extends React.Component {
<span className={type === 'public' ? 'label label-default' : 'label label-dark'}>
<i className={type === 'public' ? 'icon fa-eye' : 'icon fa-eye-slash'}></i> {type === 'public' ? translate('IAPI.PUBLIC_SM') : translate('KMD_NATIVE.PRIVATE')}
</span>
&nbsp;&nbsp;
<button className="btn btn-default btn-xs clipboard-edexaddr" data-edexcoin="COIN" id="edexcoin_active_addr_clipboard" data-clipboard-text="" onClick={() => this.copyZAddress(address.address)}><i className="icon wb-copy" aria-hidden="true"></i> {translate('INDEX.COPY')}</button>
</td>
<td>{type === 'public' ? address.address : address.address.substring(0, 34) + '...'}</td>
<td>{address.amount}</td>

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

@ -1,6 +1,7 @@
import React from 'react';
import { translate } from '../../translate/translate';
import { sendNativeTx } from '../../actions/actionCreators';
import { secondsToString } from '../../util/time';
import { sendNativeTx, getKMDOPID } from '../../actions/actionCreators';
import Store from '../../store';
class WalletsNativeSend extends React.Component {
@ -65,6 +66,94 @@ class WalletsNativeSend extends React.Component {
);
}
renderOPIDLabel(opid) {
if (opid.status === 'queued') {
return (
<span className="label label-warning">
<i className="icon fa-eye"></i> <span>{translate('KMD_NATIVE.QUEUED')}</span>
</span>
);
}
if (opid.status === 'executing') {
return (
<span className="label label-info">
<i className="icon fa-eye"></i> <span>{translate('KMD_NATIVE.EXECUTING')}</span>
</span>
);
}
if (opid.status === 'failed') {
return (
<span className="label label-danger">
<i className="icon fa-eye"></i> <span>{translate('KMD_NATIVE.FAILED')}</span>
</span>
);
}
if (opid.status === 'success') {
return (
<span className="label label-success">
<i className="icon fa-eye"></i> <span>{translate('KMD_NATIVE.SUCCESS')}</span>
</span>
);
}
}
renderOPIDResult(opid) {
var isWaitingStatus = true;
if (opid.status === 'queued') {
isWaitingStatus = false;
return (
<i>{translate('KMD_NATIVE.PLEASE_REFRESH')}...</i>
);
}
if (opid.status === 'executing') {
isWaitingStatus = false;
return (
<i>{translate('KMD_NATIVE.PLEASE_REFRESH')}...</i>
);
}
if (opid.status === 'failed') {
isWaitingStatus = false;
return (
<span>
<b>Error Code:</b> <span>{opid.error.code}</span>
<br />
<b>{translate('KMD_NATIVE.MESSAGE')}:</b> <span>{opid.error.message}</span>
</span>
);
}
if (opid.status === 'success') {
isWaitingStatus = false;
return (
<span>
<b>txid:</b> <span>{opid.result.txid}</span>
<br />
<b>{translate('KMD_NATIVE.EXECUTION_SECONDS')}:</b> <span>{opid.execution_secs}</span>
</span>
);
}
if (isWaitingStatus) {
return (
<span>Waiting...</span>
);
}
}
renderOPIDList() {
if (this.props.ActiveCoin.opids && this.props.ActiveCoin.opids.length) {
return this.props.ActiveCoin.opids.map((opid) =>
<tr key={opid.id}>
<td>{this.renderOPIDLabel(opid)}</td>
<td>{opid.id}</td>
<td>{secondsToString(opid.creation_time)}</td>
<td>{this.renderOPIDResult(opid)}</td>
</tr>
);
} else {
return null;
}
}
openDropMenu() {
this.setState(Object.assign({}, this.state, {
addressSelectorOpen: !this.state.addressSelectorOpen,
@ -89,6 +178,9 @@ class WalletsNativeSend extends React.Component {
handleSubmit() {
console.log(this.state);
Store.dispatch(sendNativeTx(this.props.ActiveCoin.coin, this.state));
setTimeout(function() {
Store.dispatch(getKMDOPID(null, this.props.ActiveCoin.coin));
}, 1000);
}
render() {
@ -163,6 +255,9 @@ class WalletsNativeSend extends React.Component {
<th>{translate('INDEX.RESULT')}</th>
</tr>
</thead>
<tbody>
{this.renderOPIDList()}
</tbody>
<tfoot>
<tr>
<th>{translate('INDEX.STATUS')}</th>

8
react/src/reducers/activeCoin.js

@ -8,7 +8,8 @@ import {
DASHBOARD_ACTIVE_TXINFO_MODAL,
ACTIVE_COIN_GET_ADDRESSES,
DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE,
DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY
DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY,
DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS
} from '../actions/actionCreators';
export function ActiveCoin(state = {
@ -21,6 +22,7 @@ export function ActiveCoin(state = {
showTransactionInfo: false,
showTransactionInfoTxIndex: null,
txhistory: [],
opids: null,
}, action) {
switch (action.type) {
case DASHBOARD_ACTIVE_COIN_CHANGE:
@ -68,6 +70,10 @@ export function ActiveCoin(state = {
return Object.assign({}, state, {
txhistory: action.txhistory,
});
case DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS:
return Object.assign({}, state, {
opids: action.opids,
});
default:
return state;
}

Loading…
Cancel
Save