diff --git a/assets/scripts/dashboard.js b/assets/scripts/dashboard.js
index 8397a7b..ae6560d 100644
--- a/assets/scripts/dashboard.js
+++ b/assets/scripts/dashboard.js
@@ -58,7 +58,7 @@ var Dashboard = function() {
var selected_coinmode = sessionStorage.getItem('edexTmpMode')
if ( selected_coinmode == 'Basilisk' ) {
- getDEXGetBalance(active_edexcoin).then(function(result){
+ getDEXGetBalance_cache(active_edexcoin).then(function(result){
console.log(result)
if ( result.interest !== undefined ) {
$('#edexcoin_getbalance_interest').show()
@@ -737,8 +737,8 @@ function edexCoinBtnAction() {
$('#edex-footer').hide();
$('#btn_edexcoin_basilisk').show();
$('#edexcoin-wallet-waitingrt-alert').hide()
- StopShowCoinHistory();
- sessionStorage.setItem('edexTmpRefresh', "stop");
+ //sessionStorage.setItem('edexTmpRefresh', "stop");
+ sessionStorage.setItem('edexTmpRefresh', "start");
}
if ( selected_coinmode == 'Full' ) {
$('#edex-footer').show();
@@ -809,7 +809,7 @@ function edexCoinBtnAction() {
&& selected_coin !== 'CARB'
&& selected_coin !== 'ANC'
&& selected_coin !== 'FRK') {
- getDEXGetBalance(selected_coin).then(function(result){
+ getDEXGetBalance_cache(selected_coin).then(function(result){
//console.log(result)
if ( result.interest !== undefined ) {
$('#edexcoin_getbalance_interest').show()
@@ -928,6 +928,28 @@ function EdexfillTxHistory(coin) {
template: '
'
});
NProgress.start();
+ var active_edexcoinmodecode = sessionStorage.getItem('edexTmpMode');
+ if ( active_edexcoinmodecode === 'Basilisk' ) {
+ EdexGetTxList_cache(coin).then(function(result){
+ //console.log(result)
+
+ var edex_txhistory_table = '';
+ edex_txhistory_table = $('#edex-tx-history-tbl').DataTable( { data: result,
+ "order": [[ 3, "desc" ]],
+ select: true,
+ retrieve: true
+ });
+
+ edex_txhistory_table.destroy();
+ edex_txhistory_table = $('#edex-tx-history-tbl').DataTable( { data: result,
+ "order": [[ 3, "desc" ]],
+ select: true,
+ retrieve: true
+ });
+ });
+ }
+
+ if ( active_edexcoinmodecode === 'Full' ) {
EdexGetTxList(coin).then(function(result){
//console.log(result)
@@ -945,10 +967,11 @@ function EdexfillTxHistory(coin) {
retrieve: true
});
});
+ }
}
function getDEXCoinBalance(coin) {
- getDEXGetBalance(coin).then(function(result){
+ getDEXGetBalance_cache(coin).then(function(result){
console.log(result)
});
}
@@ -974,6 +997,7 @@ function getDEXGetBalance(coin) {
var total_interest = 0
Promise.all(data.result.map((coinaddr_value,coinaddr_index) => {
let params = {'userpass':tmpIguanaRPCAuth,"agent":"dex","method":"getbalance","address":coinaddr_value,"symbol":coin};
+ console.log(params)
return new Promise((resolve, reject) => {
$.ajax({
data: JSON.stringify(params),
@@ -981,6 +1005,7 @@ function getDEXGetBalance(coin) {
type: 'POST',
dataType: 'json',
}).then(data => {
+ console.log(data)
total_balance = total_balance + data.balance
if (data.interest !== undefined) {
total_interest = total_interest + data.interest
@@ -1005,6 +1030,54 @@ function getDEXGetBalance(coin) {
}
+function getDEXGetBalance_cache(coin) {
+ NProgress.done(true);
+ NProgress.configure({
+ template: ''
+ });
+ NProgress.start();
+ return new Promise((resolve) =>{
+ Shepherd_GetBasiliskCache().then(function(result){
+ var _data = JSON.parse(result)
+ var query = _data.result.basilisk
+ //console.log(query[coin].addresses)
+
+ var total_balance = 0
+ var total_interest = 0
+ Promise.all(query[coin].addresses.map((coinaddr_value,coinaddr_index) => {
+ return new Promise((resolve, reject) => {
+ //console.log(coinaddr_index)
+ //console.log(coinaddr_value)
+ if ( query[coin][coinaddr_value].getbalance !== undefined ) {
+ var data = query[coin][coinaddr_value].getbalance
+ //console.log(data)
+ total_balance = parseFloat(total_balance) + parseFloat(data.balance)
+ if (data.interest !== undefined) {
+ total_interest = parseFloat(total_interest) + parseFloat(data.interest)
+ total_final = parseFloat(total_balance) + parseFloat(total_interest)
+ pass_data = {"total":total_balance.toFixed(8),"interest":total_interest.toFixed(8),"totalbalance":total_final.toFixed(8)}
+ }
+ if (data.interest == undefined) {
+ pass_data = {"total":total_balance.toFixed(8)}
+ }
+ } else {
+ pass_data = {"total":0.00000000}
+ }
+ //console.log(pass_data)
+ //return pass_data
+ resolve(pass_data)
+ })
+ })).then(result => {
+ //console.log(result)
+ //console.log(result[result.length-1])
+ resolve(result[result.length-1])
+ NProgress.done();
+ })
+ })
+ })
+}
+
+
function getDEXGetBalance2(coin) {
NProgress.done(true);
NProgress.configure({
@@ -1037,7 +1110,7 @@ function getDEXGetBalance2(coin) {
ajax_call_2.done(function(data) {
//console.log(tmp_coin_addr);
- //console.log(data);
+ console.log(data);
if (data.error === 'less than required responses') {
toastr.error("Less than required responses. Please try again.", "Basilisk Notification")
}
@@ -1658,6 +1731,105 @@ function EdexGetTxList(coin) {
})
}
+function EdexGetTxList_cache(coin) {
+ NProgress.done(true);
+ NProgress.configure({
+ template: ''
+ });
+ NProgress.start();
+ return new Promise((resolve) =>{
+ Shepherd_GetBasiliskCache().then(function(result){
+ var _data = JSON.parse(result)
+ var query = _data.result.basilisk
+ //console.log(query[coin].addresses)
+ var active_edexcoinmodecode = sessionStorage.getItem('edexTmpMode');
+ var total_utxos = []
+
+ Promise.all(query[coin].addresses.map((coinaddr_value,coinaddr_index) => {
+ return new Promise((resolve, reject) => {
+ //console.log(coinaddr_index)
+ //console.log(coinaddr_value)
+ var data = query[coin][coinaddr_value].listtransactions
+ //console.log(data)
+ total_utxos = $.merge(total_utxos, data)
+ resolve(total_utxos)
+ })
+ })).then(result => {
+ let result_data = result[result.length-1]
+ //console.log(result_data)
+
+ let compiled_result = []
+ $.each(result_data, function(index, value) {
+ //console.log(value)
+ if ( active_edexcoinmodecode == 'Basilisk' && coin !== 'BTC' && coin !== 'SYS') {
+ var tmp_category = '';
+ var tmp_amount = result_data[index].amount;
+ if(!("amount" in result_data[index])) {
+ tmp_amount = 'Unknown'
+ }
+ var tmp_addr = null
+ if(!("paid" in result_data[index])) {
+ tmp_addr = ' Z Address not listed by wallet!'
+ }
+ if(("paid" in result_data[index])) {
+ var first_addr = Object.keys(result_data[index].paid['vouts'][0]);
+ var tmp_addr = first_addr[0];
+ //console.log(result_data[index].paid['vouts'][0])
+
+ }
+
+ //tmp_secondsToString = ' Unknown'
+ //if(("blocktime" in result_data[index])) {
+ //console.log('blocktime FOUND');
+ //var tmp_secondsToString = secondsToString(result_data[index].blocktime)
+ //}
+
+ var tmp_secondsToString = secondsToString(result_data[index].timestamp)
+
+ if (isNaN(tmp_secondsToString)) {
+ //tmp_secondsToString = 'Unknown';
+ }
+
+ //console.log(result_data[index].type)
+ if ( result_data[index].type == 'sent' ) {
+ tmp_category = ' OUT';
+ }
+ if ( result_data[index].type == 'received' ) {
+ tmp_category = ' IN';
+ }
+ if ( result_data[index].type == 'generate' ) {
+ tmp_category = ' Mined';
+ }if ( result_data[index].type == 'immature' ) {
+ tmp_category = ' Immature';
+ }
+ if ( result_data[index].type == 'unknown' ) {
+ tmp_category = ' Unknown';
+ }
+
+
+ if(!("confirmations" in result_data[index])) {
+ tmp_confirms = ' Unknown';
+ }
+ if(("confirmations" in result_data[index])) {
+ tmp_confirms = result_data[index].confirmations
+ }
+
+ //console.log(tmp_addr);
+ //tmplisttransactions = {"category": result_data[index].category,"confirmations": result_data[index].confirmations,"amount": result_data[index].amount,"time": result_data[index].time,"address": result_data[index].address,"txid": result_data[index].txid}
+ tmplisttransactions = [tmp_category,tmp_confirms,tmp_amount,tmp_secondsToString,tmp_addr,'']
+ //console.log(tmplisttransactions);
+ compiled_result.push(tmplisttransactions);
+ }
+ })
+
+ //console.log(compiled_result)
+ resolve(compiled_result);
+ NProgress.done();
+ })
+ })
+ })
+}
+
/*function EdexGetTxList(coin) {
return new Promise((resolve) =>{
diff --git a/assets/scripts/iguana_api.js b/assets/scripts/iguana_api.js
index 350d6f1..7e9f7ab 100644
--- a/assets/scripts/iguana_api.js
+++ b/assets/scripts/iguana_api.js
@@ -646,6 +646,9 @@ function Iguana_addcoin(addcoin_data) {
console.log('command NOT executed from login. RELOADING WALLET WIDGETS...');
refreshEDEXCoinWalletList()
//Iguana_DEXImportAll();
+ Shepherd_FetchBasiliskData().then(function(result){
+ console.log(result)
+ })
//EDEXMainAddr(addcoin_data.coin).then(function(result){
//console.log(result)
//Iguana_DEXImportAddr(addcoin_data.coin,result);
@@ -1831,3 +1834,49 @@ function Shepherd_herdlist(data) {
})
}
+
+
+function Shepherd_FetchBasiliskData() {
+ return new Promise((resolve) =>{
+ var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth');
+ parse_session_data = sessionStorage.getItem('IguanaActiveAccount')
+ parse_session_data = JSON.parse(JSON.parse(parse_session_data))
+ session_pubkey = parse_session_data.pubkey
+
+ var ajax_data = {'userpass':tmpIguanaRPCAuth,'pubkey':session_pubkey}
+
+ $.ajax({
+ type: 'GET',
+ data: ajax_data,
+ url: 'http://127.0.0.1:17777/shepherd/allcoins',
+ contentType: 'application/json', // send as JSON
+ }).done(function(data) {
+ //console.log(data)
+ resolve(data)
+ })
+ })
+}
+
+
+
+function Shepherd_GetBasiliskCache() {
+ return new Promise((resolve) =>{
+ var parse_session_data = sessionStorage.getItem('IguanaActiveAccount')
+ parse_session_data = JSON.parse(JSON.parse(parse_session_data))
+ session_pubkey = parse_session_data.pubkey
+
+ var 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) {
+ //console.log(data)
+ resolve(data)
+ })
+ })
+}
+
+
diff --git a/assets/scripts/login.js b/assets/scripts/login.js
index 4009c05..cb66be4 100644
--- a/assets/scripts/login.js
+++ b/assets/scripts/login.js
@@ -99,7 +99,10 @@ var Login = function() {
$('body').removeClass( "page-login layout-full page-dark" ).addClass( "" );
$('link[id=loginStyle]')[0].disabled=true;
//refreshEDEXCoinWalletList()
- location.reload();
+ Shepherd_FetchBasiliskData().then(function(result){
+ console.log(result)
+ location.reload();
+ })
}
else {
// If something goes wrong, alert the error message that our service returned
@@ -821,7 +824,7 @@ var Login = function() {
handleCheckLogin();
handleLoginAnotherWallet();
handleAddCoinLoginBtn();
- handleAddCoinOSOptions();
+ //handleAddCoinOSOptions();
}