Browse Source

zaddr balance fix

all-modes
pbca26 8 years ago
parent
commit
0108e81c39
  1. 85
      react/src/actions/actions/addressBalance.js
  2. 2
      react/src/components/dashboard/walletsNativeBalance.js

85
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,90 @@ 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,
};
}
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) {
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') {

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

@ -45,7 +45,7 @@ class WalletsNativeBalance extends React.Component {
<div className="pull-left padding-vertical-10">
<i className="icon fa-money font-size-24 vertical-align-bottom margin-right-5"></i>{ translate('INDEX.INTEREST_EARNED') }
</div>
<span className="pull-right padding-top-10 font-size-22">{ this.props.Dashboard.progress.interest ? this.props.Dashboard.progress.interest : '-' }</span>
<span className="pull-right padding-top-10 font-size-22">{ this.props.Dashboard.progress && this.props.Dashboard.progress.interest ? this.props.Dashboard.progress.interest : '-' }</span>
</div>
</div>
</div>

Loading…
Cancel
Save