diff --git a/react/src/actions/actions/addressBalance.js b/react/src/actions/actions/addressBalance.js index 3713e34..ad77083 100644 --- a/react/src/actions/actions/addressBalance.js +++ b/react/src/actions/actions/addressBalance.js @@ -5,7 +5,8 @@ import { triggerToaster, Config, shepherdGroomPost, - getPassthruAgent + getPassthruAgent, + iguanaHashHex } from '../actionCreators'; import { logGuiHttp, @@ -171,7 +172,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { }; } - // if api cache option is off if (mode === 'basilisk') { payload = { 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, @@ -235,17 +235,109 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { sum += filteredArray[i]; } + if (sum === 0 && + a === 1) { + + } + newAddressArray[a][b] = { address: result[a][b], amount: currentAddress === result[a][b] || mode === 'native' ? sum : 'N/A', + type: a === 0 ? 'public': 'private', }; } } - dispatch(getKMDAddressesNativeState({ - 'public': newAddressArray[0], - 'private': newAddressArray[1] - })); + // get zaddr balance + if (result[1] && + result[1].length) { + Promise.all(result[1].map((_address, index) => { + return new Promise((resolve, reject) => { + const _timestamp = Date.now(); + let ajaxDataToHex = `["${_address}"]`; + + iguanaHashHex(ajaxDataToHex, dispatch).then((hashHexJson) => { + if (getPassthruAgent(coin) === 'iguana') { + payload = { + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, + 'agent': getPassthruAgent(coin), + 'method': 'passthru', + 'asset': coin, + 'function': 'z_getbalance', + 'hex': hashHexJson, + }; + } else { + payload = { + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, + 'agent': getPassthruAgent(coin), + 'method': 'passthru', + 'function': 'z_getbalance', + 'hex': hashHexJson, + }; + } + dispatch(logGuiHttp({ + 'timestamp': _timestamp, + 'function': 'getKMDAddressesNative+ZBalance', + 'type': 'post', + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, + 'payload': payload, + 'status': 'pending', + })); + + fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, + { + method: 'POST', + body: JSON.stringify(payload), + }) + .catch(function(error) { + console.log(error); + dispatch(logGuiHttp({ + 'timestamp': _timestamp, + 'status': 'error', + 'response': error, + })); + dispatch(triggerToaster(true, 'getKMDAddressesNative+ZBalance', 'Error', 'error')); + }) + .then(response => response.json()) + .then(function(json) { + if (json && + json.error) { + resolve(0); + dispatch(logGuiHttp({ + 'timestamp': _timestamp, + 'status': 'error', + 'response': json, + })); + dispatch(triggerToaster(true, 'getKMDAddressesNative+ZBalance', 'Error', 'error')); + } else { + resolve(json); + newAddressArray[1][index] = { + address: _address, + amount: json, + type: 'private', + }; + dispatch(logGuiHttp({ + 'timestamp': _timestamp, + 'status': 'success', + 'response': json, + })); + } + }); + }); + }); + })) + .then(zresult => { + dispatch(getKMDAddressesNativeState({ + 'public': newAddressArray[0], + 'private': newAddressArray[1] + })); + }); + } else { + dispatch(getKMDAddressesNativeState({ + 'public': newAddressArray[0], + 'private': newAddressArray[1] + })); + } } if (mode === 'basilisk') { diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index 1e91293..e775326 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -583,7 +583,7 @@ class WalletsData extends React.Component {
-
+
@@ -598,23 +598,17 @@ class WalletsData extends React.Component {
diff --git a/react/src/components/dashboard/walletsNativeSend.js b/react/src/components/dashboard/walletsNativeSend.js index 1d82938..666881e 100644 --- a/react/src/components/dashboard/walletsNativeSend.js +++ b/react/src/components/dashboard/walletsNativeSend.js @@ -54,7 +54,7 @@ class WalletsNativeSend extends React.Component { this.props.ActiveCoin.addresses[type].length) { return this.props.ActiveCoin.addresses[type].map((address) =>
  • - this.updateAddressSelection(address.address, type, address.amount) }> [ { address.amount } { this.props.ActiveCoin.coin } ]  { address.address } + this.updateAddressSelection(address.address, type, address.amount) }> [ { address.amount } { this.props.ActiveCoin.coin } ]  { type === 'public' ? address.address : address.address.substring(0, 34) + '...' }
  • ); } else { diff --git a/react/src/components/dashboard/walletsNativeSyncProgress.js b/react/src/components/dashboard/walletsNativeSyncProgress.js index 15a44e3..0a052c0 100644 --- a/react/src/components/dashboard/walletsNativeSyncProgress.js +++ b/react/src/components/dashboard/walletsNativeSyncProgress.js @@ -31,19 +31,32 @@ class WalletsNativeSyncProgress extends React.Component { renderActivatingBestChainProgress() { if (this.props.Settings && - this.props.Settings.debugLog && - this.props.Dashboard.progress.remoteKMDNode) { + this.props.Settings.debugLog) { if (this.props.Settings.debugLog.indexOf('UpdateTip') > -1) { let temp = this.props.Settings.debugLog.split(' '); let currentBestChain; + let currentProgress; for (let i = 0; i < temp.length; i++) { if (temp[i].indexOf('height=') > -1) { currentBestChain = temp[i].replace('height=', ''); } + if (temp[i].indexOf('progress=') > -1) { + currentProgress = Number(temp[i].replace('progress=', '')) * 100; + } } - return(`: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (blocks ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})`); + // fallback to local data if remote node is inaccessible + if (this.props.Dashboard.progress.remoteKMDNode && + !this.props.Dashboard.progress.remoteKMDNode.blocks) { + return ( + `: ${currentProgress}%` + ); + } else { + return( + `: ${Math.floor(currentBestChain * 100 / this.props.Dashboard.progress.remoteKMDNode.blocks)}% (blocks ${currentBestChain} / ${this.props.Dashboard.progress.remoteKMDNode.blocks})` + ); + } } else { return ( ... @@ -57,15 +70,15 @@ class WalletsNativeSyncProgress extends React.Component { return _translationComponents.map((_translation) => - {_translation} + { _translation }
    ); } renderChainActivationNotification() { - if ((this.props.Dashboard.progress.blocks < this.props.Dashboard.progress.longestchain) || - this.props.Dashboard.progress.remoteKMDNode) { + if ((!this.props.Dashboard.progress.blocks && !this.props.Dashboard.progress.longestchain) || + (this.props.Dashboard.progress.blocks < this.props.Dashboard.progress.longestchain)) { return (