Browse Source

basilisk main addr listtransactions

all-modes
pbca26 8 years ago
parent
commit
96ad1336c1
  1. 155
      react/src/actions/actionCreators.js
  2. 15
      react/src/components/dashboard/coinTileItem.js
  3. 4
      react/src/components/dashboard/walletsTxInfo.js

155
react/src/actions/actionCreators.js

@ -888,7 +888,7 @@ function getKMDAddressesNativeState(json) {
} }
} }
export function getKMDAddressesNative(coin, mode) { export function getKMDAddressesNative(coin, mode, currentAddress) {
const type = ['public', 'private']; const type = ['public', 'private'];
if (mode !== 'native') { if (mode !== 'native') {
@ -993,133 +993,17 @@ export function getKMDAddressesNative(coin, mode) {
} }
// if api cache option is off // if api cache option is off
/*function Shepherd_GetBasiliskCache() {
return new Promise((resolve) => {
var parse_session_data = sessionStorage.getItem('IguanaActiveAccount');
parse_session_data = JSON.parse(JSON.parse(parse_session_data));
var session_pubkey = parse_session_data.pubkey,
ajax_data = { 'pubkey': session_pubkey };
$.ajax({
type: 'GET',
data: ajax_data,
url: 'http://127.0.0.1:17777/shepherd/cache',
contentType: 'application/json' // send as JSON
})
.done(function(data) {
resolve(data);
data = JSON.parse(data);
if (data.result === 'JSON parse error') {
Shepherd_GroomData_Delete()
.then(function(result) {
console.log('error reading cache, flushing...');
});
}
});
});
}*/
if (mode === 'basilisk') { if (mode === 'basilisk') {
payload = { payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'dex', 'agent': 'dex',
'method': 'listunspent', 'method': 'listunspent',
'address': 'RDbGxL8QYdEp8sMULaVZS2E6XThcTKT9Jd', 'address': currentAddress,
'symbol': coin 'symbol': coin
}; };
} }
if (mode === 'basilisk') { fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
const _addressArray = mode === 'basilisk' ? result[0].result : result;
Promise.all(_addressArray.map((_address, index) => {
console.log('addrlength', _addressArray.length);
return new Promise((resolve, reject) => {
console.log(_address);
resolve(_address);
});
}))
.then(result => {
console.log('addrres', result);
fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getKMDAddressesNative+Balance', 'Error', 'error'));
})
.then(response => response.json())
.then(function(json) {
console.log('getaddrjson', result[0]);
if (mode === 'full' || mode === 'basilisk') {
result[0] = result[0].result;
}
if (mode !== 'basilisk') {
const allAddrArray = json.map(res => res.address).filter((x, i, a) => a.indexOf(x) == i);
for (let a=0; a < allAddrArray.length; a++) {
const filteredArray = json.filter(res => res.address === allAddrArray[a]).map(res => res.amount);
let isNewAddr = true;
for (let x=0; x < result.length && isNewAddr; x++) {
for (let y=0; y < result[x].length && isNewAddr; y++) {
if (allAddrArray[a] === result[x][y]) {
isNewAddr = false;
}
}
}
if (isNewAddr) {
if (allAddrArray[a].substring(0, 2) === 'zc' || allAddrArray[a].substring(0, 2) === 'zt') {
result[1][result[1].length] = allAddrArray[a];
} else {
result[0][result[0].length] = allAddrArray[a];
}
console.log('new addr ' + allAddrArray[a] + ' | ' + allAddrArray[a].substring(0, 2));
}
}
}
let newAddressArray = [];
for (let a=0; a < result.length; a++) {
newAddressArray[a] = [];
for (let b=0; b < result[a].length; b++) {
var filteredArray;
if (mode === 'basilisk') {
filteredArray = json.map(res => res.amount);
} else {
filteredArray = json.filter(res => res.address === result[a][b]).map(res => res.amount);
}
let sum = 0;
for (let i=0; i < filteredArray.length; i++) {
sum += filteredArray[i];
}
newAddressArray[a][b] = {
address: result[a][b],
amount: sum,
};
}
}
dispatch(getKMDAddressesNativeState({
'public': newAddressArray[0],
'private': newAddressArray[1]
}));
})
});
}
/*fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
@ -1129,7 +1013,6 @@ export function getKMDAddressesNative(coin, mode) {
}) })
.then(response => response.json()) .then(response => response.json())
.then(function(json) { .then(function(json) {
console.log('getaddrjson', result[0]);
if (mode === 'full' || mode === 'basilisk') { if (mode === 'full' || mode === 'basilisk') {
result[0] = result[0].result; result[0] = result[0].result;
} }
@ -1181,7 +1064,7 @@ export function getKMDAddressesNative(coin, mode) {
newAddressArray[a][b] = { newAddressArray[a][b] = {
address: result[a][b], address: result[a][b],
amount: sum, amount: currentAddress === result[a][b] ? sum : 'N/A',
}; };
} }
} }
@ -1190,11 +1073,39 @@ export function getKMDAddressesNative(coin, mode) {
'public': newAddressArray[0], 'public': newAddressArray[0],
'private': newAddressArray[1] 'private': newAddressArray[1]
})); }));
})*/ })
}) })
} }
} }
/*function Shepherd_GetBasiliskCache() {
return new Promise((resolve) => {
var parse_session_data = sessionStorage.getItem('IguanaActiveAccount');
parse_session_data = JSON.parse(JSON.parse(parse_session_data));
var session_pubkey = parse_session_data.pubkey,
ajax_data = { 'pubkey': session_pubkey };
$.ajax({
type: 'GET',
data: ajax_data,
url: 'http://127.0.0.1:17777/shepherd/cache',
contentType: 'application/json' // send as JSON
})
.done(function(data) {
resolve(data);
data = JSON.parse(data);
if (data.result === 'JSON parse error') {
Shepherd_GroomData_Delete()
.then(function(result) {
console.log('error reading cache, flushing...');
});
}
});
});
}*/
function getDebugLogState(json) { function getDebugLogState(json) {
const _data = json.result.replace('\n', '\r\n'); const _data = json.result.replace('\n', '\r\n');

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

@ -25,6 +25,11 @@ class CoinTileItem extends React.Component {
}; };
} }
// TODO: 1) cache native/full node data to file
// 2) limit amount of req per update e.g. list of addresses don't change too often
// 3) limit req in basilisk as much as possible incl. activehandle
// 4) add pending requests store
dashboardChangeActiveCoin(coin, mode) { dashboardChangeActiveCoin(coin, mode) {
if (coin !== this.props.ActiveCoin.coin) { if (coin !== this.props.ActiveCoin.coin) {
Store.dispatch(stopInterval('sync', this.props.Interval.interval)); Store.dispatch(stopInterval('sync', this.props.Interval.interval));
@ -34,7 +39,7 @@ class CoinTileItem extends React.Component {
var _iguanaActiveHandle = setInterval(function() { var _iguanaActiveHandle = setInterval(function() {
Store.dispatch(getSyncInfo(coin)); Store.dispatch(getSyncInfo(coin));
Store.dispatch(iguanaEdexBalance(coin, mode)); Store.dispatch(iguanaEdexBalance(coin, mode));
Store.dispatch(getKMDAddressesNative(coin, mode));//getAddressesByAccount(coin)); Store.dispatch(getKMDAddressesNative(coin, mode)); //getAddressesByAccount(coin));
Store.dispatch(getFullTransactionsList(coin)); Store.dispatch(getFullTransactionsList(coin));
}, 3000); }, 3000);
Store.dispatch(startInterval('sync', _iguanaActiveHandle)); Store.dispatch(startInterval('sync', _iguanaActiveHandle));
@ -52,10 +57,12 @@ class CoinTileItem extends React.Component {
} }
if (mode === 'basilisk') { if (mode === 'basilisk') {
var _iguanaActiveHandle = setInterval(function() { var _iguanaActiveHandle = setInterval(function() {
Store.dispatch(getBasiliskTransactionsList(coin, 'RDbGxL8QYdEp8sMULaVZS2E6XThcTKT9Jd')); if (this.props && this.props.Dashboard && this.props.Dashboard.activeHandle && this.props.Dashboard.activeHandle[coin]) {
Store.dispatch(getBasiliskTransactionsList(coin, this.props.Dashboard.activeHandle[coin]));
Store.dispatch(getKMDAddressesNative(coin, mode, this.props.Dashboard.activeHandle[coin]));
}
Store.dispatch(iguanaEdexBalance(coin, mode)); Store.dispatch(iguanaEdexBalance(coin, mode));
Store.dispatch(getKMDAddressesNative(coin, mode)); }.bind(this), 3000);
}, 3000);
Store.dispatch(startInterval('sync', _iguanaActiveHandle)); Store.dispatch(startInterval('sync', _iguanaActiveHandle));
// basilisk // basilisk
} }

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

@ -66,7 +66,7 @@ class WalletsTxInfo extends React.Component {
<tr> <tr>
<td>category</td> <td>category</td>
<td> <td>
{txInfo.category} {txInfo.category || txInfo.type}
</td> </td>
</tr> </tr>
<tr> <tr>
@ -84,7 +84,7 @@ class WalletsTxInfo extends React.Component {
<tr> <tr>
<td>blocktime</td> <td>blocktime</td>
<td> <td>
{secondsToString(txInfo.blocktime)} {secondsToString(txInfo.blocktime || txInfo.timestamp)}
</td> </td>
</tr> </tr>
<tr> <tr>

Loading…
Cancel
Save