Browse Source

basilisk balances fix

all-modes
pbca26 8 years ago
parent
commit
a9c282089b
  1. 35
      react/src/actions/actionCreators.js
  2. 5
      react/src/components/dashboard/coinTileItem.js
  3. 6
      react/src/components/dashboard/sendCoin.js
  4. 3
      react/src/components/dashboard/walletsData.js

35
react/src/actions/actionCreators.js

@ -925,7 +925,7 @@ export function addPeerNode(coin, ip) {
} }
} }
export function getAddressesByAccountState(json, coin, mode) { export function setBasiliskMainAddress(json, coin, mode) {
if (mode === 'full') { if (mode === 'full') {
let publicAddressArray = []; let publicAddressArray = [];
@ -942,6 +942,31 @@ export function getAddressesByAccountState(json, coin, mode) {
if (mode === 'basilisk') { if (mode === 'basilisk') {
getDexBalance(coin, mode, json.result); getDexBalance(coin, mode, json.result);
} }
const _mainAddr = []
return {
type: ACTIVE_COIN_GET_ADDRESSES,
addresses: { 'public': [] },
}
}
export function getAddressesByAccountState(json, coin, mode) {
if (mode === 'full' || mode === 'basilisk') {
let publicAddressArray = [];
for (let i = 0; i < json.result.length; i++) {
publicAddressArray.push({
'address': json.result[i],
'amount': 'N/A'
});
}
json.result = publicAddressArray;
}
/*if (mode === 'basilisk') {
getDexBalance(coin, mode, json.result);
}*/
return { return {
type: ACTIVE_COIN_GET_ADDRESSES, type: ACTIVE_COIN_GET_ADDRESSES,
@ -971,7 +996,7 @@ export function getAddressesByAccount(coin, mode) {
dispatch(triggerToaster(true, 'getAddressesByAccount', 'Error', 'error')); dispatch(triggerToaster(true, 'getAddressesByAccount', 'Error', 'error'));
}) })
.then(response => response.json()) .then(response => response.json())
.then(json => dispatch(getAddressesByAccountState(json, coin, mode, dispatch))) .then(json => dispatch(getAddressesByAccountState(json, coin, mode)))
} }
} }
@ -1403,13 +1428,13 @@ export function fetchUtxoCache(_payload) {
function getShepherdCacheState(json, pubkey, coin) { function getShepherdCacheState(json, pubkey, coin) {
if (json.result && json.error && json.result.indexOf('no file with handle') > -1) { if (json.result && json.error && json.result.indexOf('no file with handle') > -1) {
console.log('request new cache', true); console.log('request new cache', { 'pubkey': pubkey, 'coin': coin });
return dispatch => { return dispatch => {
dispatch(fetchNewCacheData({ dispatch(fetchNewCacheData({
'pubkey': pubkey, 'pubkey': pubkey,
'allcoins': false, 'allcoins': false,
'coin': coin, 'coin': coin,
'calls': 'listtransactions:getbalance:listunspent', 'calls': 'listtransactions:getbalance',
})); }));
} }
} else { } else {
@ -1605,7 +1630,7 @@ export function getSyncInfoNative(coin, skipDebug) {
} }
} }
export function getDexBalance(coin, addr) { export function getDexBalance(coin, mode, addr) {
Promise.all(addr.map((_addr, index) => { Promise.all(addr.map((_addr, index) => {
const payload = { const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),

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

@ -62,11 +62,14 @@ class CoinTileItem extends React.Component {
if (mode === 'basilisk') { if (mode === 'basilisk') {
const useAddress = this.props.ActiveCoin.mainBasiliskAddress ? this.props.ActiveCoin.mainBasiliskAddress : this.props.Dashboard.activeHandle[coin]; const useAddress = this.props.ActiveCoin.mainBasiliskAddress ? this.props.ActiveCoin.mainBasiliskAddress : this.props.Dashboard.activeHandle[coin];
Store.dispatch(iguanaActiveHandle(true)); Store.dispatch(iguanaActiveHandle(true));
Store.dispatch(getKMDAddressesNative(coin, mode, useAddress));
Store.dispatch(getShepherdCache(JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey, coin)); Store.dispatch(getShepherdCache(JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey, coin));
if (this.props && this.props.Dashboard && this.props.Dashboard.activeHandle && this.props.Dashboard.activeHandle[coin]) { if (this.props && this.props.Dashboard && this.props.Dashboard.activeHandle && this.props.Dashboard.activeHandle[coin]) {
if (!this.props.ActiveCoin.addresses) {
Store.dispatch(getAddressesByAccount(coin, mode));
}
Store.dispatch(getBasiliskTransactionsList(coin, useAddress)); Store.dispatch(getBasiliskTransactionsList(coin, useAddress));
Store.dispatch(getKMDAddressesNative(coin, mode, useAddress));
//Store.dispatch(iguanaEdexBalance(coin, mode)); //Store.dispatch(iguanaEdexBalance(coin, mode));
} }
} }

6
react/src/components/dashboard/sendCoin.js

@ -212,9 +212,10 @@ class SendCoin extends React.Component {
let _amount = address.amount; let _amount = address.amount;
if (this.props.ActiveCoin.mode === 'basilisk') { if (this.props.ActiveCoin.mode === 'basilisk') {
_amount = this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address.address].getbalance.data && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address.address].getbalance.data.balance ? this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address.address].getbalance.data.balance : 'N/A'; _amount = this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address.address] && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address.address].getbalance.data && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address.address].getbalance.data.balance ? this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address.address].getbalance.data.balance : 'N/A';
} }
if (_amount !== 'N/A') {
items.push( items.push(
<li <li
data-original-index="2" data-original-index="2"
@ -226,6 +227,7 @@ class SendCoin extends React.Component {
</li> </li>
); );
} }
}
return items; return items;
} }
@ -238,7 +240,7 @@ class SendCoin extends React.Component {
if (this.state.sendFrom) { if (this.state.sendFrom) {
let _amount; let _amount;
if (this.state._sendFromAmount === 0 && if (this.state.sendFromAmount === 0 &&
this.props.ActiveCoin.mode === 'basilisk') { this.props.ActiveCoin.mode === 'basilisk') {
_amount = this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.state.sendFrom].getbalance.data && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.state.sendFrom].getbalance.data.balance ? this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.state.sendFrom].getbalance.data.balance : 'N/A'; _amount = this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.state.sendFrom].getbalance.data && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.state.sendFrom].getbalance.data.balance ? this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.state.sendFrom].getbalance.data.balance : 'N/A';
} else { } else {

3
react/src/components/dashboard/walletsData.js

@ -108,6 +108,7 @@ class WalletsData extends React.Component {
'allcoins': false, 'allcoins': false,
'coin': this.props.ActiveCoin.coin, 'coin': this.props.ActiveCoin.coin,
'calls': 'listtransactions:getbalance', 'calls': 'listtransactions:getbalance',
'address': this.state.currentAddress,
})); }));
} }
@ -455,7 +456,7 @@ class WalletsData extends React.Component {
return this.props.ActiveCoin.addresses.public[i].amount; return this.props.ActiveCoin.addresses.public[i].amount;
} else { } else {
const address = this.props.ActiveCoin.addresses.public[i].address; const address = this.props.ActiveCoin.addresses.public[i].address;
const _amount = this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address].getbalance.data && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address].getbalance.data.balance ? this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address].getbalance.data.balance : 'N/A'; const _amount = this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address] && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address].getbalance.data && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address].getbalance.data.balance ? this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][address].getbalance.data.balance : 'N/A';
return _amount; return _amount;
} }
} }

Loading…
Cancel
Save