Browse Source

gui logger wip#2

all-modes
pbca26 8 years ago
parent
commit
2114bf7a61
  1. 370
      react/src/actions/actionCreators.js

370
react/src/actions/actionCreators.js

@ -745,7 +745,7 @@ export function iguanaActiveHandle(getMainAddress) {
dispatch(logGuiHttp({ dispatch(logGuiHttp({
'timestamp': _timestamp, 'timestamp': _timestamp,
'status': 'error', 'status': 'error',
'response': json, 'response': error,
})); }));
dispatch(updateErrosStack('activeHandle')); dispatch(updateErrosStack('activeHandle'));
dispatch(triggerToaster(true, translate('TOASTR.IGUANA_ARE_YOU_SURE'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error')); dispatch(triggerToaster(true, translate('TOASTR.IGUANA_ARE_YOU_SURE'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error'));
@ -771,6 +771,7 @@ export function iguanaEdexBalance(coin) {
}; };
return dispatch => { return dispatch => {
if (coin) {
const _timestamp = Date.now(); const _timestamp = Date.now();
dispatch(logGuiHttp({ dispatch(logGuiHttp({
'timestamp': _timestamp, 'timestamp': _timestamp,
@ -797,6 +798,7 @@ export function iguanaEdexBalance(coin) {
.then(response => response.json()) .then(response => response.json())
.then(json => dispatch(iguanaEdexBalanceState(json))); .then(json => dispatch(iguanaEdexBalanceState(json)));
} }
}
} }
export function atomic(payload) { export function atomic(payload) {
@ -828,22 +830,42 @@ export function encryptWallet(_passphrase, cb, coin) {
'agent': 'bitcoinrpc', 'agent': 'bitcoinrpc',
'method': 'encryptwallet', 'method': 'encryptwallet',
'passphrase': _passphrase, 'passphrase': _passphrase,
// 'immediate': 60000,
// 'timeout': 60000
}; };
return dispatch => { return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'encryptWallet',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'encryptWallet', 'Error', 'error')); dispatch(triggerToaster(true, 'encryptWallet', 'Error', 'error'));
}) })
.then(dispatch(walletPassphrase(_passphrase))) .then(dispatch(walletPassphrase(_passphrase)))
.then(response => response.json()) .then(response => response.json())
.then(json => dispatch(cb.call(this, json, coin))); .then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(cb.call(this, json, coin))
});
} }
} }
@ -853,18 +875,39 @@ export function walletPassphrase(_passphrase) {
'agent': 'bitcoinrpc', 'agent': 'bitcoinrpc',
'method': 'walletpassphrase', 'method': 'walletpassphrase',
'password': _passphrase, 'password': _passphrase,
'timeout': '2592000', 'timeout': '300000',
// 'immediate': 60000,
}; };
return dispatch => { return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'walletpassphrase',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(triggerToaster(true, 'walletPassphrase', 'Error', 'error')); dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'walletPassphrase', 'Error', 'error'))
})
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
}) })
} }
} }
@ -903,21 +946,41 @@ export function getFullTransactionsList(coin) {
9999999, 9999999,
[] []
], ],
// 'immediate': 60000,
// 'timeout': 60000
}; };
return dispatch => { return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getFullTransactionsList',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getFullTransactionsList', 'Error', 'error')); dispatch(triggerToaster(true, 'getFullTransactionsList', 'Error', 'error'));
}) })
.then(response => response.json()) .then(response => response.json())
.then(json => dispatch(getNativeTxHistoryState(json))) .then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getNativeTxHistoryState(json));
})
} }
} }
@ -930,11 +993,8 @@ export function getBasiliskTransactionsList(coin, address) {
'count': 100, 'count': 100,
'skip': 0, 'skip': 0,
'symbol': coin, 'symbol': coin,
// 'immediate': 60000,
// 'timeout': 60000
}; };
//if (sessionStorage.getItem('useCache')) {
const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey; const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
return dispatch => { return dispatch => {
@ -960,20 +1020,6 @@ export function getBasiliskTransactionsList(coin, address) {
} }
}) })
} }
/*} else {
return dispatch => {
return fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.basiliskPort : Config.iguanaCorePort), {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getBasiliskTransactionsList', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(getNativeTxHistoryState(json)))
}
}*/
} }
export function getPeersList(coin) { export function getPeersList(coin) {
@ -982,21 +1028,41 @@ export function getPeersList(coin) {
'agent': 'SuperNET', 'agent': 'SuperNET',
'method': 'getpeers', 'method': 'getpeers',
'activecoin': coin, 'activecoin': coin,
// 'immediate': 60000,
// 'timeout': 60000
}; };
return dispatch => { return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getPeersList',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getPeersList', 'Error', 'error')); dispatch(triggerToaster(true, 'getPeersList', 'Error', 'error'));
}) })
.then(response => response.json()) .then(response => response.json())
.then(json => dispatch(getPeersListState(json, dispatch))) .then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getPeersListState(json, dispatch));
})
} }
} }
@ -1030,21 +1096,41 @@ export function addPeerNode(coin, ip) {
'method': 'addnode', 'method': 'addnode',
'activecoin': coin, 'activecoin': coin,
'ipaddr': ip, 'ipaddr': ip,
// 'immediate': 60000,
// 'timeout': 60000
}; };
return dispatch => { return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'addPeerNode',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'addPeerNode', 'Error', 'error')); dispatch(triggerToaster(true, 'addPeerNode', 'Error', 'error'));
}) })
.then(response => response.json()) .then(response => response.json())
.then(json => dispatch(addPeerNodeState(json, dispatch))) .then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(addPeerNodeState(json, dispatch));
})
} }
} }
@ -1065,7 +1151,6 @@ export function setBasiliskMainAddress(json, coin, mode) {
if (mode === 'basilisk') { if (mode === 'basilisk') {
getDexBalance(coin, mode, json.result); getDexBalance(coin, mode, json.result);
} }
const _mainAddr = []
return { return {
type: ACTIVE_COIN_GET_ADDRESSES, type: ACTIVE_COIN_GET_ADDRESSES,
@ -1074,7 +1159,8 @@ export function setBasiliskMainAddress(json, coin, mode) {
} }
export function getAddressesByAccountState(json, coin, mode) { export function getAddressesByAccountState(json, coin, mode) {
if (mode === 'full' || mode === 'basilisk') { if (mode === 'full' ||
mode === 'basilisk') {
let publicAddressArray = []; let publicAddressArray = [];
for (let i = 0; i < json.result.length; i++) { for (let i = 0; i < json.result.length; i++) {
@ -1087,10 +1173,6 @@ export function getAddressesByAccountState(json, coin, mode) {
json.result = publicAddressArray; json.result = publicAddressArray;
} }
/*if (mode === 'basilisk') {
getDexBalance(coin, mode, json.result);
}*/
return { return {
type: ACTIVE_COIN_GET_ADDRESSES, type: ACTIVE_COIN_GET_ADDRESSES,
addresses: { 'public': json.result }, addresses: { 'public': json.result },
@ -1104,22 +1186,42 @@ export function getAddressesByAccount(coin, mode) {
'agent': 'bitcoinrpc', 'agent': 'bitcoinrpc',
'method': 'getaddressesbyaccount', 'method': 'getaddressesbyaccount',
'account': '*', 'account': '*',
// 'immediate': 60000,
// 'timeout': 60000
}; };
return dispatch => { return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getAddressesByAccount',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(updateErrosStack('activeHandle')); dispatch(updateErrosStack('activeHandle'));
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))) .then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getAddressesByAccountState(json, coin, mode));
})
} }
} }
@ -1161,17 +1263,30 @@ export function getSyncInfo(coin) {
'coin': coin, 'coin': coin,
'agent': 'bitcoinrpc', 'agent': 'bitcoinrpc',
'method': 'getinfo', 'method': 'getinfo',
// 'immediate': 60000,
// 'timeout': 60000
}; };
return dispatch => { return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getSyncInfo',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getSyncInfo', 'Error', 'error')); dispatch(triggerToaster(true, 'getSyncInfo', 'Error', 'error'));
}) })
.then(function(response) { .then(function(response) {
@ -1180,6 +1295,11 @@ export function getSyncInfo(coin) {
return _response; return _response;
}) })
.then(function(json) { .then(function(json) {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
if (json.indexOf('coin is busy processing') === -1) { if (json.indexOf('coin is busy processing') === -1) {
dispatch(getSyncInfoState(json, dispatch)); dispatch(getSyncInfoState(json, dispatch));
} }
@ -1204,18 +1324,18 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
return dispatch => { return dispatch => {
Promise.all(type.map((_type, index) => { Promise.all(type.map((_type, index) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var payload, let payload,
ajax_data_to_hex = '', ajax_data_to_hex = '',
ajax_function_input = '', ajax_function_input = '',
tmplistaddr_hex_input = '', tmplistaddr_hex_input = '',
passthru_agent = getPassthruAgent(coin), passthru_agent = getPassthruAgent(coin),
tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'); tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
if ( _type === 'public' ) { if (_type === 'public') {
ajax_function_input = 'getaddressesbyaccount'; ajax_function_input = 'getaddressesbyaccount';
tmplistaddr_hex_input = '222200'; tmplistaddr_hex_input = '222200';
} }
if ( _type === 'private' ) { if (_type === 'private') {
ajax_function_input = 'z_listaddresses'; ajax_function_input = 'z_listaddresses';
tmplistaddr_hex_input = ''; tmplistaddr_hex_input = '';
} }
@ -1228,8 +1348,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
'asset': coin, 'asset': coin,
'function': ajax_function_input, 'function': ajax_function_input,
'hex': tmplistaddr_hex_input, 'hex': tmplistaddr_hex_input,
// 'immediate': 60000,
// 'timeout': 60000
}; };
} else { } else {
payload = { payload = {
@ -1238,8 +1356,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
'method': 'passthru', 'method': 'passthru',
'function': ajax_function_input, 'function': ajax_function_input,
'hex': tmplistaddr_hex_input, 'hex': tmplistaddr_hex_input,
// 'immediate': 60000,
// 'timeout': 60000
}; };
} }
@ -1250,12 +1366,10 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
'agent': 'bitcoinrpc', 'agent': 'bitcoinrpc',
'method': 'getaddressesbyaccount', 'method': 'getaddressesbyaccount',
'account': '*', 'account': '*',
// 'immediate': 60000,
// 'timeout': 60000
}; };
} }
if (/*sessionStorage.getItem('useCache') &&*/ mode === 'basilisk') { if (mode === 'basilisk') {
const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey; const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, { fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
@ -1277,16 +1391,38 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
} }
}) })
} else { } else {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getKMDAddressesNative',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
fetch('http://127.0.0.1:' + Config.iguanaCorePort, { fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getKMDAddressesNative', 'Error', 'error')); dispatch(triggerToaster(true, 'getKMDAddressesNative', 'Error', 'error'));
}) })
.then(response => response.json()) .then(response => response.json())
.then(json => resolve(json)) .then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
resolve(json);
})
} }
}); });
})) }))
@ -1294,7 +1430,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
// TODO: split into 2 functions // TODO: split into 2 functions
const passthru_agent = getPassthruAgent(coin), const passthru_agent = getPassthruAgent(coin),
tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'); tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
var payload; let payload;
if (passthru_agent === 'iguana') { if (passthru_agent === 'iguana') {
payload = { payload = {
@ -1304,8 +1440,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
'asset': coin, 'asset': coin,
'function': 'listunspent', 'function': 'listunspent',
'hex': '', 'hex': '',
// 'immediate': 60000,
// 'timeout': 60000
}; };
} else { } else {
payload = { payload = {
@ -1314,8 +1448,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
'method': 'passthru', 'method': 'passthru',
'function': 'listunspent', 'function': 'listunspent',
'hex': '', 'hex': '',
// 'immediate': 60000,
// 'timeout': 60000
}; };
} }
@ -1328,8 +1460,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
1, 1,
9999999, 9999999,
], ],
// 'immediate': 60000,
// 'timeout': 60000
}; };
} }
@ -1341,24 +1471,18 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
'method': 'listunspent', 'method': 'listunspent',
'address': currentAddress, 'address': currentAddress,
'symbol': coin, 'symbol': coin,
// 'immediate': 60000,
// 'timeout': 60000
}; };
} }
function calcBalance(result, json, dispatch, mode) { function calcBalance(result, json, dispatch, mode) {
//console.log('result', result);
if (mode === 'full' || mode === 'basilisk') { if (mode === 'full' || mode === 'basilisk') {
result[0] = result[0].result; result[0] = result[0].result;
} }
//console.log('calc result', result);
//console.log('calc json', json);
if (mode !== 'basilisk' && json && json.length) { if (mode !== 'basilisk' && json && json.length) {
const allAddrArray = json.map(res => res.address).filter((x, i, a) => a.indexOf(x) == i); const allAddrArray = json.map(res => res.address).filter((x, i, a) => a.indexOf(x) == i);
for (let a=0; a < allAddrArray.length; a++) { for (let a = 0; a < allAddrArray.length; a++) {
const filteredArray = json.filter(res => res.address === allAddrArray[a]).map(res => res.amount); const filteredArray = json.filter(res => res.address === allAddrArray[a]).map(res => res.amount);
let isNewAddr = true; let isNewAddr = true;
@ -1376,7 +1500,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
} else { } else {
result[0][result[0].length] = allAddrArray[a]; result[0][result[0].length] = allAddrArray[a];
} }
console.log('new addr ' + allAddrArray[a] + ' | ' + allAddrArray[a].substring(0, 2));
} }
} }
} }
@ -1394,8 +1517,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
} else { } else {
filteredArray = json.filter(res => res.address === result[a][b]).map(res => res.amount); filteredArray = json.filter(res => res.address === result[a][b]).map(res => res.amount);
} }
//console.log('filteredArray', filteredArray);
//console.log('addr', result[a][b]);
let sum = 0; let sum = 0;
@ -1416,7 +1537,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
})); }));
} }
if (/*sessionStorage.getItem('useCache') &&*/ mode === 'basilisk') { if (mode === 'basilisk') {
const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey; const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, { fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
@ -1438,16 +1559,36 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
if (json[coin][currentAddress].refresh) { if (json[coin][currentAddress].refresh) {
calcBalance(result, json[coin][currentAddress].refresh.data, dispatch, mode); calcBalance(result, json[coin][currentAddress].refresh.data, dispatch, mode);
} else { } else {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getKMDAddressesNative+Balance',
'type': 'post',
'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.basiliskPort : Config.iguanaCorePort),
'payload': payload,
'status': 'pending',
}));
fetch('http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.basiliskPort : Config.iguanaCorePort), { fetch('http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.basiliskPort : Config.iguanaCorePort), {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getKMDAddressesNative+Balance', 'Error', 'error')); dispatch(triggerToaster(true, 'getKMDAddressesNative+Balance', 'Error', 'error'));
}) })
.then(response => response.json()) .then(response => response.json())
.then(function(json) { .then(function(json) {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
updatedCache.basilisk[coin][currentAddress].refresh = { updatedCache.basilisk[coin][currentAddress].refresh = {
'data': json, 'data': json,
'status': 'done', 'status': 'done',
@ -1459,16 +1600,36 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
} }
}) })
} else { } else {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getKMDAddressesNative+Balance',
'type': 'post',
'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.basiliskPort : Config.iguanaCorePort),
'payload': payload,
'status': 'pending',
}));
fetch('http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.basiliskPort : Config.iguanaCorePort), { fetch('http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.basiliskPort : Config.iguanaCorePort), {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getKMDAddressesNative+Balance', 'Error', 'error')); dispatch(triggerToaster(true, 'getKMDAddressesNative+Balance', 'Error', 'error'));
}) })
.then(response => response.json()) .then(response => response.json())
.then(function(json) { .then(function(json) {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
calcBalance(result, json, dispatch, mode); calcBalance(result, json, dispatch, mode);
}) })
} }
@ -1477,9 +1638,6 @@ export function getKMDAddressesNative(coin, mode, currentAddress) {
} }
export function shepherdGroomPost(_filename, _payload) { export function shepherdGroomPost(_filename, _payload) {
console.log('shepherdGroomPost to file ', _filename);
console.log('shepherdGroomPost payload ', _payload);
return dispatch => { return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', { return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', {
method: 'POST', method: 'POST',
@ -1501,9 +1659,6 @@ export function shepherdGroomPost(_filename, _payload) {
} }
export function shepherdGroomPostPromise(_filename, _payload) { export function shepherdGroomPostPromise(_filename, _payload) {
console.log('shepherdGroomPostPromise to file ', _filename);
console.log('shepherdGroomPostPromise payload ', _payload);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', { fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', {
method: 'POST', method: 'POST',
@ -1551,7 +1706,6 @@ 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', { 'pubkey': pubkey, 'coin': coin });
return dispatch => { return dispatch => {
dispatch(fetchNewCacheData({ dispatch(fetchNewCacheData({
'pubkey': pubkey, 'pubkey': pubkey,
@ -1643,21 +1797,41 @@ export function importPrivKey(wifKey) {
wifKey, wifKey,
'imported' 'imported'
], ],
// 'immediate': 60000,
// 'timeout': 60000
}; };
return dispatch => { return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'importPrivKey',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST', method: 'POST',
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'importPrivKey', 'Error', 'error')); dispatch(triggerToaster(true, 'importPrivKey', 'Error', 'error'));
}) })
.then(response => response.json()) .then(response => response.json())
.then(json => dispatch(parseImportPrivKeyResponse(json, dispatch))) .then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(parseImportPrivKeyResponse(json, dispatch));
})
.catch(function(ex) { .catch(function(ex) {
dispatch(parseImportPrivKeyResponse({ 'error': 'privkey already in wallet' }, dispatch)); dispatch(parseImportPrivKeyResponse({ 'error': 'privkey already in wallet' }, dispatch));
console.log('parsing failed', ex); console.log('parsing failed', ex);
@ -1686,15 +1860,37 @@ export function getSyncInfoNativeKMD(skipDebug) {
const coin = 'KMD'; const coin = 'KMD';
return dispatch => { return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getSyncInfoNativeKMD',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort + '/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=' + coin,
'payload': payload,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + Config.iguanaCorePort + '/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=' + coin, { return fetch('http://127.0.0.1:' + Config.iguanaCorePort + '/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=' + coin, {
method: 'GET', method: 'GET',
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getSyncInfoNativeKMD', 'Error', 'error')); dispatch(triggerToaster(true, 'getSyncInfoNativeKMD', 'Error', 'error'));
}) })
.then(response => response.json()) .then(response => response.json())
.then(json => dispatch(getSyncInfoNativeState({ 'remoteKMDNode': json }))) .then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getSyncInfoNativeState({ 'remoteKMDNode': json }));
})
.then(function() { .then(function() {
if (!skipDebug) { if (!skipDebug) {
dispatch(getDebugLog('komodo', 1)); dispatch(getDebugLog('komodo', 1));
@ -1726,17 +1922,13 @@ function getPassthruAgent(coin) {
} }
export function getSyncInfoNative(coin, skipDebug) { export function getSyncInfoNative(coin, skipDebug) {
var payload = {}; const payload = {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': getPassthruAgent(coin), 'agent': getPassthruAgent(coin),
'method': 'passthru', 'method': 'passthru',
'asset': coin, 'asset': coin,
'function': 'getinfo', 'function': 'getinfo',
'hex': '', 'hex': '',
// 'immediate': 60000,
// 'timeout': 60000
}; };
return dispatch => { return dispatch => {

Loading…
Cancel
Save