Browse Source

split actionCreators

all-modes
pbca26 8 years ago
parent
commit
ab9b797eda
  1. 3309
      react/src/actions/actionCreators.js
  2. 254
      react/src/actions/addCoin.js
  3. 345
      react/src/actions/addressBalance.js
  4. 53
      react/src/actions/atomic.js
  5. 175
      react/src/actions/basiliskCache.js
  6. 134
      react/src/actions/basiliskProcessAddress.js
  7. 40
      react/src/actions/basiliskTxHistory.js
  8. 44
      react/src/actions/coinList.js
  9. 21
      react/src/actions/copyAddress.js
  10. 68
      react/src/actions/createWallet.js
  11. 53
      react/src/actions/dexCoins.js
  12. 107
      react/src/actions/edexBalance.js
  13. 55
      react/src/actions/edexGetTx.js
  14. 58
      react/src/actions/fullTxHistory.js
  15. 76
      react/src/actions/getAddrByAccount.js
  16. 66
      react/src/actions/iguanaHelpers.js
  17. 80
      react/src/actions/iguanaInstance.js
  18. 58
      react/src/actions/log.js
  19. 67
      react/src/actions/logout.js
  20. 79
      react/src/actions/nativeBalance.js
  21. 87
      react/src/actions/nativeNewAddress.js
  22. 174
      react/src/actions/nativeSend.js
  23. 111
      react/src/actions/nativeSyncInfo.js
  24. 69
      react/src/actions/nativeTxHistory.js
  25. 175
      react/src/actions/notary.js
  26. 25
      react/src/actions/openAlias.js
  27. 245
      react/src/actions/sendFullBasilisk.js
  28. 318
      react/src/actions/settings.js
  29. 43
      react/src/actions/storeType.js
  30. 74
      react/src/actions/syncInfo.js
  31. 58
      react/src/actions/syncOnly.js
  32. 26
      react/src/actions/sysInfo.js
  33. 209
      react/src/actions/walletAuth.js
  34. 4
      react/src/components/addcoin/addcoin.js
  35. 9
      react/src/components/dashboard/coinTileItem.js
  36. 2
      react/src/components/dashboard/jumblr.js
  37. 10
      react/src/components/dashboard/navbar.js
  38. 5
      react/src/components/dashboard/receiveCoin.js
  39. 19
      react/src/components/dashboard/sendCoin.js
  40. 2
      react/src/components/dashboard/settings.js
  41. 9
      react/src/components/dashboard/syncOnly.js
  42. 17
      react/src/components/dashboard/walletsData.js
  43. 7
      react/src/components/dashboard/walletsNativeReceive.js
  44. 6
      react/src/components/dashboard/walletsNativeSend.js
  45. 2
      react/src/components/dashboard/walletsNav.js
  46. 10
      react/src/components/login/login.js
  47. 36
      react/src/components/main/main.js
  48. 2
      react/src/reducers/activeCoin.js
  49. 4
      react/src/reducers/addcoin.js
  50. 4
      react/src/reducers/atomic.js
  51. 2
      react/src/reducers/dashboard.js
  52. 4
      react/src/reducers/errors.js
  53. 5
      react/src/reducers/interval.js
  54. 2
      react/src/reducers/main.js
  55. 2
      react/src/reducers/settings.js
  56. 2
      react/src/reducers/syncOnly.js
  57. 4
      react/src/reducers/toaster.js
  58. 1
      react/src/util/auth.js

3309
react/src/actions/actionCreators.js

File diff suppressed because it is too large

254
react/src/actions/addCoin.js

@ -0,0 +1,254 @@
import * as storeType from './storeType';
import { translate } from '../translate/translate';
import {
triggerToaster,
Config,
toggleAddcoinModal,
getDexCoins
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
import {
startCurrencyAssetChain,
startAssetChain,
startCrypto,
checkCoinType,
checkAC
} from '../components/addcoin/payload';
export function addCoin(coin, mode, syncOnly, port) {
if (mode === '-1') {
return dispatch => {
dispatch(shepherdGetConfig(coin, mode));
}
} else {
if (checkCoinType(coin) === 'currency_ac') {
const _acData = startCurrencyAssetChain('', coin, mode);
return dispatch => {
dispatch(iguanaAddCoin(coin, mode, _acData));
}
}
if (checkCoinType(coin) === 'ac') {
const _acData = startAssetChain('', coin, mode);
return dispatch => {
dispatch(iguanaAddCoin(coin, mode, _acData));
}
}
if (checkCoinType(coin) === 'crypto') {
const _acData = startCrypto('', coin, mode);
if (syncOnly) {
const modeToValue = {
'1': 'full',
'0': 'basilisk',
'-1': 'native'
};
return dispatch => {
startIguanaInstance(modeToValue[mode] + '/sync', coin)
.then(function(json) {
setTimeout(function() {
console.log('started ' + coin + ' / ' + modeToValue[mode] + ' fork', json);
dispatch(iguanaAddCoin(coin, mode, _acData, json.result));
}, 2000);
});
}
} else {
if (port) {
return dispatch => {
dispatch(iguanaAddCoin(coin, mode, _acData, port));
}
} else {
return dispatch => {
dispatch(iguanaAddCoin(coin, mode, _acData));
}
}
}
}
}
}
export function iguanaAddCoin(coin, mode, acData, port) {
function _iguanaAddCoin(dispatch) {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'iguanaAddCoin',
'type': 'post',
'url': 'http://127.0.0.1:' + (port ? port : Config.iguanaCorePort),
'payload': acData,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + (port ? port : Config.iguanaCorePort), {
method: 'POST',
body: JSON.stringify(acData),
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, translate('TOASTR.FAILED_TO_ADDCOIN'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(addCoinResult(coin, mode, acData));
});
}
if (mode === 0) {
return dispatch => {
return _iguanaAddCoin(dispatch);
}
} else {
return dispatch => {
return _iguanaAddCoin(dispatch);
}
}
}
export function shepherdHerd(coin, mode, path) {
let acData;
let herdData = {
'ac_name': coin,
'ac_options': [
'-daemon=0',
'-server',
'-ac_name=' + coin,
'-addnode=78.47.196.146'
]
};
if (coin === 'ZEC') {
herdData = {
'ac_name': 'zcashd',
'ac_options': [
'-daemon=0',
'-server=1'
]
};
}
if (coin === 'KMD') {
herdData = {
'ac_name': 'komodod',
'ac_options': [
'-daemon=0',
'-addnode=78.47.196.146'
]
};
}
if (checkCoinType(coin) === 'crypto') {
acData = startCrypto(path.result, coin, mode);
}
if (checkCoinType(coin) === 'currency_ac') {
acData = startCurrencyAssetChain(path.result, coin, mode);
}
if (checkCoinType(coin) === 'ac') {
acData = startAssetChain(path.result, coin, mode);
const supply = startAssetChain(path.result, coin, mode, true);
herdData.ac_options.push('-ac_supply=' + supply);
}
console.log('herdData', herdData);
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/herd', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
'herd': coin !== 'ZEC' ? 'komodod' : 'zcashd',
'options': herdData
}),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, translate('FAILED_SHEPHERD_HERD'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error'));
})
.then(response => response.json())
.then(json => dispatch(iguanaAddCoin(coin, mode, acData)));
}
}
export function addCoinResult(coin, mode) {
const modeToValue = {
'1': 'full',
'0': 'basilisk',
'-1': 'native'
};
return dispatch => {
dispatch(triggerToaster(true, coin + ' ' + translate('TOASTR.STARTED_IN') + ' ' + modeToValue[mode] + ' ' + translate('TOASTR.MODE'), translate('TOASTR.COIN_NOTIFICATION'), 'success'));
dispatch(toggleAddcoinModal(false, false));
dispatch(getDexCoins());
}
}
export function _shepherdGetConfig(coin, mode) {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'chain': 'komodod' })
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'Failed to get mode config', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(shepherdHerd(coin, mode, json)));
}
}
export function shepherdGetConfig(coin, mode) {
if (coin === 'KMD' &&
mode === '-1') {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'chain': 'komodod' })
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'Failed to get KMD config', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(shepherdHerd(coin, mode, json)))
}
} else {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'chain': coin })
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'Failed to get mode config', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(shepherdHerd(coin, mode, json)));
}
}
}

345
react/src/actions/addressBalance.js

@ -0,0 +1,345 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config,
shepherdGroomPost,
getPassthruAgent
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
function getKMDAddressesNativeState(json) {
return {
type: storeType.ACTIVE_COIN_GET_ADDRESSES,
addresses: json,
}
}
export function getKMDAddressesNative(coin, mode, currentAddress) {
const type = ['public', 'private'];
if (mode !== 'native') {
type.pop();
}
return dispatch => {
Promise.all(type.map((_type, index) => {
return new Promise((resolve, reject) => {
let payload,
ajax_data_to_hex = '',
ajax_function_input = '',
tmplistaddr_hex_input = '',
passthru_agent = getPassthruAgent(coin),
tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
if (_type === 'public') {
ajax_function_input = 'getaddressesbyaccount';
tmplistaddr_hex_input = '222200';
}
if (_type === 'private') {
ajax_function_input = 'z_listaddresses';
tmplistaddr_hex_input = '';
}
if (passthru_agent === 'iguana') {
payload = {
'userpass': tmpIguanaRPCAuth,
'agent': passthru_agent,
'method': 'passthru',
'asset': coin,
'function': ajax_function_input,
'hex': tmplistaddr_hex_input,
};
} else {
payload = {
'userpass': tmpIguanaRPCAuth,
'agent': passthru_agent,
'method': 'passthru',
'function': ajax_function_input,
'hex': tmplistaddr_hex_input,
};
}
if (mode === 'full' || mode === 'basilisk') {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'coin': coin,
'agent': 'bitcoinrpc',
'method': 'getaddressesbyaccount',
'account': '*',
};
}
if (mode === 'basilisk') {
const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getKMDAddressesNative+addresslist+cache', 'Error', 'error'));
})
.then(response => response.json())
.then(function(json) {
json = json.result.basilisk;
if (json[coin].addresses) {
resolve({ 'result': json[coin].addresses });
}
})
} 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, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getKMDAddressesNative', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
resolve(json);
})
}
});
}))
.then(result => {
// TODO: split into 2 functions
const passthru_agent = getPassthruAgent(coin),
tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
let payload;
if (passthru_agent === 'iguana') {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': passthru_agent,
'method': 'passthru',
'asset': coin,
'function': 'listunspent',
'hex': '',
};
} else {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': passthru_agent,
'method': 'passthru',
'function': 'listunspent',
'hex': '',
};
}
if (mode === 'full') {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'coin': coin,
'method': 'listunspent',
'params': [
1,
9999999,
],
};
}
// if api cache option is off
if (mode === 'basilisk') {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'dex',
'method': 'listunspent',
'address': currentAddress,
'symbol': coin,
};
}
function calcBalance(result, json, dispatch, mode) {
if (mode === 'full' ||
mode === 'basilisk') {
result[0] = result[0].result;
}
if (mode !== 'basilisk' &&
json &&
json.length) {
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];
}
}
}
}
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: currentAddress === result[a][b] || mode === 'native' ? sum : 'N/A',
};
}
}
dispatch(getKMDAddressesNativeState({
'public': newAddressArray[0],
'private': newAddressArray[1]
}));
}
if (mode === 'basilisk') {
const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getKMDAddressesNative+addresslist+cache', 'Error', 'error'));
})
.then(response => response.json())
.then(function(json) {
let updatedCache = Object.assign({}, json.result);
json = json.result.basilisk;
// if listunspent is not in cache file retrieve new copy
// otherwise read from cache data
if (json[coin][currentAddress].refresh) {
calcBalance(result, json[coin][currentAddress].refresh.data, dispatch, mode);
} 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.iguanaCorePort + 1 : Config.iguanaCorePort),
'payload': payload,
'status': 'pending',
}));
fetch('http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 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+Balance', 'Error', 'error'));
})
.then(response => response.json())
.then(function(json) {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
updatedCache.basilisk[coin][currentAddress].refresh = {
'data': json,
'status': 'done',
'timestamp': Date.now(),
};
dispatch(shepherdGroomPost(pubkey, updatedCache));
calcBalance(result, json, dispatch, mode);
})
}
})
} 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.iguanaCorePort + 1 : Config.iguanaCorePort),
'payload': payload,
'status': 'pending',
}));
fetch('http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 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+Balance', 'Error', 'error'));
})
.then(response => response.json())
.then(function(json) {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
calcBalance(result, json, dispatch, mode);
})
}
})
}
}

53
react/src/actions/atomic.js

@ -0,0 +1,53 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function atomic(payload) {
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'atomic',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return 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, payload.method, 'Atomic Explorer error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(atomicState(json));
});
}
}
function atomicState(json) {
return {
type: storeType.ATOMIC,
response: json,
}
}

175
react/src/actions/basiliskCache.js

@ -0,0 +1,175 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function deleteCacheFile(_payload) {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom?', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'filename': _payload.pubkey }),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'deleteCacheFile', 'Error', 'error'))
})
.then(response => response.json())
.then(json => dispatch(fetchNewCacheData(_payload)));
}
}
export function getCacheFile(pubkey) {
const _pubkey = pubkey || JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
return new Promise((resolve, reject) => {
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom?filename=' + _pubkey, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getCacheFile', 'Error', 'error'))
})
.then(response => response.json())
.then(json => resolve(json))
})
}
export function fetchNewCacheData(_payload) {
const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
_pubkey = '&pubkey=' + _payload.pubkey,
_route = _payload.allcoins ? 'cache-all' : 'cache-one',
_coin = '&coin=' + _payload.coin,
_calls = '&calls=' + _payload.calls,
_address = _payload.address ? ('&address=' + _payload.address) : '',
_iguanaInstancePort = Config.useBasiliskInstance ? '&port=' + (Config.iguanaCorePort + 1) : '';
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/' + _route + _userpass + _pubkey + _coin + _calls + _address + _iguanaInstancePort, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'fetchNewCacheData', 'Error', 'error'));
})
.then(response => response.json())
.then(json => console.log(json))
}
}
export function getShepherdCache(pubkey, coin) {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getShepherdCache', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(getShepherdCacheState(json, pubkey, coin)))
}
}
function getShepherdCacheState(json, pubkey, coin) {
if (json.result &&
json.error &&
json.result.indexOf('no file with handle') > -1) {
return dispatch => {
dispatch(fetchNewCacheData({
'pubkey': pubkey,
'allcoins': false,
'coin': coin,
'calls': 'listtransactions:getbalance',
}));
}
} else {
return {
type: storeType.DASHBOARD_ACTIVE_COIN_GET_CACHE,
cache: json && json.result && json.result.basilisk ? json.result.basilisk : null,
}
}
}
export function fetchUtxoCache(_payload) {
const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
_pubkey = '&pubkey=' + _payload.pubkey,
_route = _payload.allcoins ? 'cache-all' : 'cache-one',
_coin = '&coin=' + _payload.coin,
_calls = '&calls=' + _payload.calls,
_address = _payload.address ? ('&address=' + _payload.address) : '',
_iguanaInstancePort = Config.useBasiliskInstance ? '&port=' + (Config.iguanaCorePort + 1) : '';
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/' + _route + _userpass + _pubkey + _coin + _calls + _address + _iguanaInstancePort, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'fetchNewCacheData', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(getShepherdCache(_pubkey)))
}
}
export function shepherdGroomPost(_filename, _payload) {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
'filename': _filename,
'payload': JSON.stringify(_payload),
}),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'shepherdGroomPost', 'Error', 'error'));
})
.then(response => response.json())
.then(json => console.log(json))
}
}
export function shepherdGroomPostPromise(_filename, _payload) {
return new Promise((resolve, reject) => {
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
'filename': _filename,
'payload': JSON.stringify(_payload),
}),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'shepherdGroomPostPromise', 'Error', 'error'));
})
.then(response => response.json())
.then(json => resolve(json))
})
}

134
react/src/actions/basiliskProcessAddress.js

@ -0,0 +1,134 @@
import * as storeType from './storeType';
import { translate } from '../translate/translate';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function checkAddressBasilisk(coin, address) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'dex',
'method': 'checkaddress',
'address': address,
'symbol': coin,
};
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'checkAddressBasilisk',
'type': 'post',
'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
'payload': payload,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 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, 'checkAddressBasilisk', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(checkAddressBasiliskHandle(json));
})
}
}
function checkAddressBasiliskHandle(json) {
if (json &&
json.error) {
return dispatch => {
dispatch(triggerToaster(true, json.error, translate('TOASTR.WALLET_NOTIFICATION'), 'error'));
}
}
if (json &&
json.coin &&
json.randipbits) {
return dispatch => {
dispatch(triggerToaster(true, 'Address already registered', translate('TOASTR.WALLET_NOTIFICATION'), 'warning'));
}
}
}
export function validateAddressBasilisk(coin, address) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'dex',
'method': 'validateaddress',
'address': address,
'symbol': coin,
};
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'validateAddressBasilisk',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 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, 'validateAddressBasilisk', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(validateAddressBasiliskHandle(json));
})
}
}
function validateAddressBasiliskHandle(json) {
return dispatch => {
if (json.iswatchonly === true) {
dispatch(triggerToaster(true, translate('TOASTR.VALIDATION_SUCCESS'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
}
if (json.iswatchonly === false) {
dispatch(triggerToaster(true, translate('TOASTR.ADDR_ISNT_REG'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
}
if (json.iswatchonly === undefined) {
dispatch(triggerToaster(true, translate('TOASTR.INVALID_QUERY_ALT'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
}
if (json.error === 'less than required responses') {
dispatch(triggerToaster(true, translate('TOASTR.LESS_RESPONSES_REQ'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
}
}
}

40
react/src/actions/basiliskTxHistory.js

@ -0,0 +1,40 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config,
getNativeTxHistoryState
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function getBasiliskTransactionsList(coin, address) {
const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getBasiliskTransactionsList+cache', 'Error', 'error'));
})
.then(response => response.json())
.then(function(json) {
if (json.result &&
!json.result.basilisk &&
json.result.indexOf('no file with handle') > -1) {
console.log('new cache');
}
json = json.result.basilisk;
if (json[coin][address].listtransactions) {
dispatch(getNativeTxHistoryState({ 'result': json[coin][address].listtransactions.data }));
}
})
}
}

44
react/src/actions/coinList.js

@ -0,0 +1,44 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function shepherdGetCoinList() {
return new Promise((resolve, reject) => {
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/coinslist', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'shepherdGetCoinList', 'Error', 'error'));
})
.then(response => response.json())
.then(json => resolve(json))
});
}
export function shepherdPostCoinList(data) {
return new Promise((resolve, reject) => {
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/coinslist', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'payload': data }),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'shepherdPostCoinList', 'Error', 'error'));
})
.then(response => response.json())
.then(json => resolve(json))
});
}

21
react/src/actions/copyAddress.js

@ -0,0 +1,21 @@
import { copyToClipboard } from '../util/copyToClipboard';
import { translate } from '../translate/translate';
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
export function copyCoinAddress(address) {
const _result = copyToClipboard(address);
if (_result) {
return dispatch => {
dispatch(triggerToaster(true, translate('DASHBOARD.ADDR_COPIED'), translate('TOASTR.COIN_NOTIFICATION'), 'success'));
}
} else {
return dispatch => {
dispatch(triggerToaster(true, 'Couldn\'t copy address to clipboard', translate('TOASTR.COIN_NOTIFICATION'), 'error'));
}
}
}

68
react/src/actions/createWallet.js

@ -0,0 +1,68 @@
import * as storeType from './storeType';
import { translate } from '../translate/translate';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
function createNewWalletState(json) {
if (json &&
json.result &&
json.result === 'success') {
return dispatch => {
dispatch(triggerToaster(true, translate('TOASTR.WALLET_CREATED_SUCCESFULLY'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'success'));
}
} else {
return dispatch => {
dispatch(triggerToaster(true, 'Couldn\'t create new wallet seed', translate('TOASTR.ACCOUNT_NOTIFICATION'), 'error'));
}
}
}
export function createNewWallet(_passphrase) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'bitcoinrpc',
'method': 'encryptwallet',
'passphrase': _passphrase,
};
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'createNewWallet',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return 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, 'createNewWallet', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(createNewWalletState(json));
})
}
}

53
react/src/actions/dexCoins.js

@ -0,0 +1,53 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config,
dashboardCoinsState
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function getDexCoins() {
const _payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'InstantDEX',
'method': 'allcoins',
};
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getDexCoins',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': _payload,
'status': 'pending',
}));
return 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, 'Error getDexCoins', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(dashboardCoinsState(json));
});
}
}

107
react/src/actions/edexBalance.js

@ -0,0 +1,107 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function iguanaEdexBalance(coin) {
const _payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'bitcoinrpc',
'method': 'getbalance',
'coin': coin,
};
return dispatch => {
if (coin) {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'iguanaEdexBalance',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': _payload,
'status': 'pending',
}));
return 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, 'Error iguanaEdexBalance', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(iguanaEdexBalanceState(json)));
}
}
}
function iguanaEdexBalanceState(json) {
return {
type: storeType.DASHBOARD_ACTIVE_COIN_BALANCE,
balance: json && json.result ? json.result : 0,
}
}
export function getDexBalance(coin, mode, addr) {
Promise.all(addr.map((_addr, index) => {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'dex',
'method': 'listunspent',
'address': _addr,
'symbol': coin,
};
return new Promise((resolve, reject) => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getDexBalance',
'type': 'post',
'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
'payload': payload,
'status': 'pending',
}));
fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 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, 'getDexBalance', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
console.log(json);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
})
resolve(index);
});
}))
.then(result => {
console.log(result);
});
}

55
react/src/actions/edexGetTx.js

@ -0,0 +1,55 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function edexGetTransaction(data) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'symbol': data.coin,
'agent': 'dex',
'method': 'gettransaction',
'vout': 1,
'txid': data.txid
};
return new Promise((resolve, reject) => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'edexGetTransaction',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
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, 'edexGetTransaction', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
resolve(json);
})
});
}

58
react/src/actions/fullTxHistory.js

@ -0,0 +1,58 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config,
getNativeTxHistoryState
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function getFullTransactionsList(coin) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'coin': coin,
'method': 'listtransactions',
'params': [
0,
9999999,
[]
],
};
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, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getFullTransactionsList', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getNativeTxHistoryState(json));
})
}
}

76
react/src/actions/getAddrByAccount.js

@ -0,0 +1,76 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
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;
}
return {
type: storeType.ACTIVE_COIN_GET_ADDRESSES,
addresses: { 'public': json.result },
}
}
export function getAddressesByAccount(coin, mode) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'coin': coin,
'agent': 'bitcoinrpc',
'method': 'getaddressesbyaccount',
'account': '*',
};
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, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(updateErrosStack('activeHandle'));
dispatch(triggerToaster(true, 'getAddressesByAccount', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getAddressesByAccountState(json, coin, mode));
})
}
}

66
react/src/actions/iguanaHelpers.js

@ -0,0 +1,66 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
import { checkAC } from '../components/addcoin/payload';
export function getPassthruAgent(coin) {
let passthruAgent;
if (coin === 'KMD') { passthruAgent = 'komodo'; };
if (coin === 'ZEC') { passthruAgent = 'zcash'; };
if (checkAC(coin)) { passthruAgent = 'iguana'; };
return passthruAgent;
}
export function iguanaHashHex(data, dispatch) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'hash',
'method': 'hex',
'message': data,
};
return new Promise((resolve, reject) => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'iguanaHashHex',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
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, 'iguanaHashHex', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
resolve(json.hex);
})
})
}

80
react/src/actions/iguanaInstance.js

@ -0,0 +1,80 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function restartIguanaInstance(pmid) {
return new Promise((resolve, reject) => {
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/restart?pmid=' + pmid, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'restartIguanaInstance', 'Error', 'error'));
})
.then(response => response.json())
.then(json => resolve(json))
});
}
export function restartBasiliskInstance() {
return dispatch => {
getIguanaInstancesList()
.then(function(json) {
for (let port in json.result) {
if (json.result[port].mode === 'basilisk') {
restartIguanaInstance(json.result[port].pmid)
.then(function(json) {
console.log('restartBasiliskInstance', json);
});
}
}
});
}
}
export function startIguanaInstance(mode, coin) {
return new Promise((resolve, reject) => {
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
mode,
coin
}),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'startIguanaInstance', 'Error', 'error'));
})
.then(response => response.json())
.then(json => resolve(json))
});
}
export function getIguanaInstancesList() {
return new Promise((resolve, reject) => {
fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getIguanaInstanceList', 'Error', 'error'));
})
.then(response => response.json())
.then(json => resolve(json))
});
}

58
react/src/actions/log.js

@ -0,0 +1,58 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
export function logGuiHttp(payload) {
return dispatch => {
dispatch(guiLogState(payload));
// disabled for now
/*return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/guilog', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'logGuiHttp', 'Error', 'error'));
})
.then(response => response.json())*/
}
}
export function getAgamaLog(type) {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getlog?type=' + type, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getAgamaLog', 'Error', 'error'));
})
.then(response => response.json())
.then()
}
}
export function guiLogState(logData) {
return {
type: storeType.LOG_GUI_HTTP,
timestamp: logData.timestamp,
log: {
timestamp: logData.timestamp,
function: logData.function,
httpMethod: logData.type,
url: logData.url,
payload: logData.payload,
status: logData.status,
response: logData.response,
}
}
}

67
react/src/actions/logout.js

@ -0,0 +1,67 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
function logoutState(json, dispatch) {
sessionStorage.removeItem('IguanaActiveAccount');
return {
type: storeType.LOGIN,
isLoggedIn: false,
}
}
export function logout() {
return dispatch => {
dispatch(walletLock());
}
}
function walletLock() {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'bitcoinrpc',
'method': 'walletlock',
};
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'walletLock',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return 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, 'walletLock', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(logoutState(json));
})
}
}

79
react/src/actions/nativeBalance.js

@ -0,0 +1,79 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config,
getPassthruAgent
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function getKMDBalanceTotal(coin) {
let payload;
if (coin !== 'KMD' &&
coin !== 'ZEC') {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'iguana',
'method': 'passthru',
'asset': coin,
'function': 'z_gettotalbalance',
'hex': '3000',
};
} else {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': getPassthruAgent(coin),
'method': 'passthru',
'function': 'z_gettotalbalance',
'hex': '3000',
};
}
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getKMDBalanceTotal',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return 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, 'getKMDBalanceTotal', 'Error', 'error'));
})
.then(response => response.json())
.then(function(json) { // TODO: figure out why komodod spits out "parse error"
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
if (json &&
!json.error) {
dispatch(getNativeBalancesState(json));
}
})
}
}
export function getNativeBalancesState(json) {
return {
type: storeType.DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE,
balance: json && !json.error ? json : 0,
}
}

87
react/src/actions/nativeNewAddress.js

@ -0,0 +1,87 @@
import * as storeType from './storeType';
import { translate } from '../translate/translate';
import {
triggerToaster,
Config,
getPassthruAgent
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
function handleGetNewKMDAddresses(pubpriv, coin, dispatch) {
dispatch(triggerToaster(true, translate('KMD_NATIVE.NEW_ADDR_GENERATED'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
dispatch(getKMDAddressesNative(coin));
return {};
}
export function getNewKMDAddresses(coin, pubpriv) {
let payload,
ajax_function_input = '';
if (pubpriv === 'public') {
ajax_function_input = 'getnewaddress';
}
if (pubpriv === 'private') {
ajax_function_input = 'z_getnewaddress';
}
if (getPassthruAgent(coin) === 'iguana') {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': getPassthruAgent(coin),
'method': 'passthru',
'asset': coin,
'function': ajax_function_input,
'hex': '',
};
} else {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': coin,
'method': 'passthru',
'function': ajax_function_input,
'hex': '',
};
}
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getNewKMDAddresses',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return 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, 'getNewKMDAddresses', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(handleGetNewKMDAddresses(pubpriv, coin, dispatch));
})
.catch(function(ex) {
dispatch(handleGetNewKMDAddresses(pubpriv, coin, dispatch))
})
}
}

174
react/src/actions/nativeSend.js

@ -0,0 +1,174 @@
import * as storeType from './storeType';
import { translate } from '../translate/translate';
import {
triggerToaster,
Config,
getPassthruAgent,
iguanaHashHex
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function sendNativeTx(coin, _payload) {
let ajax_data_to_hex;
let payload;
let _apiMethod;
if (_payload.addressType === 'public') {
_apiMethod = 'sendtoaddress';
ajax_data_to_hex = '["' + _payload.sendTo + '", ' + (Number(_payload.amount) - Number(_payload.fee)) + ']';
} else {
_apiMethod = 'z_sendmany';
ajax_data_to_hex = '["' + _payload.sendFrom + '",[{"address":"' + _payload.sendTo + '","amount":' + (Number(_payload.amount) - Number(_payload.fee)) + '}]]';
}
return dispatch => {
return iguanaHashHex(ajax_data_to_hex, dispatch).then((hashHexJson) => {
if (getPassthruAgent(coin) === 'iguana') {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': getPassthruAgent(coin),
'method': 'passthru',
'asset': coin,
'function': _apiMethod,
'hex': hashHexJson,
};
} else {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': getPassthruAgent(coin),
'method': 'passthru',
'function': _apiMethod,
'hex': hashHexJson,
};
}
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'sendNativeTx',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
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, 'sendNativeTx', 'Error', 'error'));
})
.then(response => response.json())
.then(function(json) {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
if (json.error &&
json.error.toString().indexOf('code:') > -1) {
dispatch(triggerToaster(true, 'Send failed', translate('TOASTR.WALLET_NOTIFICATION'), 'error'));
} else {
dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
}
})
.catch(function(ex) {
dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
console.log('parsing failed', ex);
})
});
}
}
export function getKMDOPIDState(json) {
return {
type: storeType.DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS,
opids: json,
}
}
export function getKMDOPID(opid, coin) {
let tmpopid_output = '',
ajax_data_to_hex;
if (opid === undefined) {
ajax_data_to_hex = null;
} else {
ajax_data_to_hex = '["' + opid + '"]';
}
return dispatch => {
return iguanaHashHex(ajax_data_to_hex, dispatch).then((hashHexJson) => {
if (hashHexJson === '5b226e756c6c225d00') {
hashHexJson = '';
}
let payload,
passthru_agent = getPassthruAgent(coin),
tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
if (passthru_agent == 'iguana') {
payload = {
'userpass': tmpIguanaRPCAuth,
'agent': passthru_agent,
'method': 'passthru',
'asset': coin,
'function': 'z_getoperationstatus',
'hex': hashHexJson,
};
} else {
payload = {
'userpass': tmpIguanaRPCAuth,
'agent': passthru_agent,
'method': 'passthru',
'function': 'z_getoperationstatus',
'hex': hashHexJson,
};
}
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getKMDOPID',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
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, 'getKMDOPID', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getKMDOPIDState(json));
})
})
}
}

111
react/src/actions/nativeSyncInfo.js

@ -0,0 +1,111 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function getSyncInfoNativeKMD(skipDebug) {
const coin = 'KMD';
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, {
method: 'GET',
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getSyncInfoNativeKMD', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getSyncInfoNativeState({ 'remoteKMDNode': json }));
})
.then(function() {
if (!skipDebug) {
dispatch(getDebugLog('komodo', 1));
}
})
}
}
function getSyncInfoNativeState(json, coin, skipDebug) {
if (coin === 'KMD' &&
json &&
json.error) {
return getSyncInfoNativeKMD(skipDebug);
} else {
return {
type: storeType.SYNCING_NATIVE_MODE,
progress: json,
}
}
}
export function getSyncInfoNative(coin, skipDebug) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': getPassthruAgent(coin),
'method': 'passthru',
'asset': coin,
'function': 'getinfo',
'hex': '',
};
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, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getSyncInfo', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getSyncInfoNativeState(json, coin, skipDebug));
})
}
}

69
react/src/actions/nativeTxHistory.js

@ -0,0 +1,69 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config,
getPassthruAgent,
getNativeTxHistoryState
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function getNativeTxHistory(coin) {
let payload;
if (getPassthruAgent(coin) === 'iguana') {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'iguana',
'method': 'passthru',
'asset': coin,
'function': 'listtransactions',
'hex': '',
};
} else {
payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': getPassthruAgent(coin),
'method': 'passthru',
'function': 'listtransactions',
'hex': '',
};
}
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getNativeTxHistory',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return 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, 'getNativeTxHistory', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getNativeTxHistoryState(json));
})
}
}

175
react/src/actions/notary.js

@ -0,0 +1,175 @@
import * as storeType from './storeType';
import { translate } from '../translate/translate';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
function initNotaryNodesConSequence(nodes) {
return dispatch => {
Promise.all(nodes.map((node, index) => {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'dex',
'method': 'getinfo',
'symbol': node,
'timeout': 10000
};
return new Promise((resolve, reject) => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'initNotaryNodesConSequence+' + node,
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort) + '/api/dex/getinfo?userpass=' + ('tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth')) + '&symbol=' + node, {
method: 'GET',
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getInfoDexNode+' + node, 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(updateNotaryNodeConState(json, nodes.length, index, node));
})
});
}));
}
}
function updateNotaryNodeConState(json, totalNodes, currentNodeIndex, currentNodeName) {
if (currentNodeIndex === totalNodes - 1) {
return dispatch => {
dispatch(basiliskConnectionState(false));
};
} else {
if (json &&
json.error === 'less than required responses') {
return {
type: storeType.DASHBOARD_CONNECT_NOTARIES,
total: totalNodes - 1,
current: currentNodeIndex,
name: currentNodeName,
failedNode: currentNodeName,
}
} else {
return {
type: storeType.DASHBOARD_CONNECT_NOTARIES,
total: totalNodes - 1,
current: currentNodeIndex,
name: currentNodeName,
}
}
}
}
function connectAllNotaryNodes(json, dispatch) {
if (json &&
json.length) {
dispatch(initNotaryNodesConSequence(json));
return {
type: storeType.DASHBOARD_CONNECT_NOTARIES,
total: json.length - 1,
current: 0,
name: json[0],
}
}
}
export function connectNotaries() {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'dpow',
'method': 'notarychains',
};
return dispatch => {
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'connectNotaries', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(connectAllNotaryNodes(json, dispatch)))
}
}
function getDexNotariesState(json) {
if (json.error === 'less than required responses') {
return dispatch => {
dispatch(triggerToaster(true, translate('TOASTR.LESS_RESPONSES_REQ'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
}
} else {
return {
type: storeType.DASHBOARD_GET_NOTARIES_LIST,
notaries: json,
}
}
}
export function getDexNotaries(coin) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'dex',
'method': 'getnotaries',
'symbol': coin,
};
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'getDexNotaries',
'type': 'post',
'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
'payload': payload,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 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, 'getDexNotaries', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getDexNotariesState(json));
})
}
}

25
react/src/actions/openAlias.js

@ -0,0 +1,25 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function resolveOpenAliasAddress(email) {
const url = email.replace('@', '.');
return new Promise((resolve, reject) => {
fetch('https://dns.google.com/resolve?name=' + url + '&type=txt', {
method: 'GET',
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'resolveOpenAliasAddress', 'Error', 'error'));
})
.then(response => response.json())
.then(json => resolve(json))
});
}

245
react/src/actions/sendFullBasilisk.js

@ -0,0 +1,245 @@
import * as storeType from './storeType';
import { translate } from '../translate/translate';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function sendToAddress(coin, _payload) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'coin': coin,
'method': 'sendtoaddress',
'params': [
_payload.sendTo,
_payload.amount,
'EasyDEX',
'EasyDEXTransaction'
],
};
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'sendToAddress',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return 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, 'sendToAddress', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(sendToAddressState(json, dispatch));
})
}
}
export function sendFromAddress(coin, _payload) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'coin': coin,
'method': 'sendfrom',
'params': [
_payload.sendFrom,
_payload.sendTo,
_payload.amount,
'EasyDEX',
'EasyDEXTransaction'
],
};
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'sendFromAddress',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
return 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, 'sendFromAddress', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(sendToAddressState(json, dispatch));
})
}
}
export function iguanaUTXORawTX(data) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'symbol': data.coin,
'agent': 'basilisk',
'method': 'utxorawtx',
'vals': {
'timelock': 0,
'changeaddr': data.sendfrom,
'destaddr': data.sendtoaddr,
'txfee': data.txfee,
'amount': data.amount,
'sendflag': data.sendsig
},
'utxos': data.utxos,
};
console.log('iguanaUTXORawTXExport', payload);
return new Promise((resolve, reject) => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'iguanaUTXORawTX',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
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, 'iguanaUTXORawTX', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
resolve(json);
})
});
}
export function dexSendRawTX(data) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'dex',
'method': 'sendrawtransaction',
'signedtx': data.signedtx,
'symbol': data.coin
};
return new Promise((resolve, reject) => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'dexSendRawTX',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': payload,
'status': 'pending',
}));
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, 'dexSendRawTX', 'Error', 'error'));
})
.then(function(response) {
const _response = response.text().then(function(text) { return text; });
return _response;
})
.then(function(json) {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
resolve(json);
})
});
}
function sendToAddressState(json, dispatch) {
if (json &&
json.error) {
dispatch(triggerToaster(true, json.error, 'Error', 'error'));
return {
type: storeType.DASHBOARD_ACTIVE_COIN_SENDTO,
lastSendToResponse: json,
}
} else if (json && json.result && json.complete) {
dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
return {
type: storeType.DASHBOARD_ACTIVE_COIN_SENDTO,
lastSendToResponse: json,
}
}
}
export function sendToAddressStateAlt(json) {
return {
type: storeType.DASHBOARD_ACTIVE_COIN_SENDTO,
lastSendToResponse: json,
}
}
export function clearLastSendToResponseState() {
return {
type: storeType.DASHBOARD_ACTIVE_COIN_SENDTO,
lastSendToResponse: null,
}
}

318
react/src/actions/settings.js

@ -0,0 +1,318 @@
import * as storeType from './storeType';
import { translate } from '../translate/translate';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
function getAppInfoState(json) {
return {
type: storeType.LOAD_APP_INFO,
info: json,
}
}
export function getAppInfo() {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appinfo', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getAppInfo', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(getAppInfoState(json)))
}
}
export function settingsWifkeyState(json, coin) {
return {
type: storeType.GET_WIF_KEY,
wifkey: json[coin + 'wif'],
address: json[coin],
}
}
function parseImportPrivKeyResponse(json, dispatch) {
if (json.error === 'illegal privkey') {
return dispatch => {
dispatch(triggerToaster(true, 'Illegal privkey', translate('TOASTR.SETTINGS_NOTIFICATION'), 'error'));
}
}
if (json.error === 'privkey already in wallet') {
return dispatch => {
dispatch(triggerToaster(true, 'Privkey already in wallet', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning'));
}
}
if (json &&
json.result !== undefined &&
json.result == 'success') {
return dispatch => {
dispatch(triggerToaster(true, translate('TOASTR.PRIV_KEY_IMPORTED'), translate('TOASTR.SETTINGS_NOTIFICATION'), 'success'));
}
}
}
export function importPrivKey(wifKey) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'method': 'importprivkey',
'params': [
wifKey,
'imported'
],
};
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, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'importPrivKey', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(parseImportPrivKeyResponse(json, dispatch));
})
.catch(function(ex) {
dispatch(parseImportPrivKeyResponse({
'error': 'privkey already in wallet'
}, dispatch));
console.log('parsing failed', ex);
})
}
}
function getDebugLogState(json) {
const _data = json.result.replace('\n', '\r\n');
return {
type: storeType.GET_DEBUG_LOG,
data: _data,
}
}
export function getDebugLog(target, linesCount) {
const payload = {
'herdname': target,
'lastLines': linesCount
};
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/debuglog', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getDebugLog', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(getDebugLogState(json)))
}
}
export function getPeersList(coin) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'SuperNET',
'method': 'getpeers',
'activecoin': coin,
};
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, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getPeersList', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getPeersListState(json, dispatch));
})
}
}
export function getPeersListState(json) {
let peersList = {};
if (json &&
json.rawpeers &&
json.rawpeers.length) {
for (let i = 0; i < json.rawpeers.length; i++) {
peersList[json.rawpeers[i].coin] = json.rawpeers[i].peers;
}
}
return {
type: storeType.GET_PEERS_LIST,
supernetPeers: json && json.supernet[0] ? json.supernet : null,
rawPeers: peersList,
}
}
function addPeerNodeState(json, dispatch) {
if (json.error === 'addnode needs active coin, do an addcoin first') {
return dispatch => {
dispatch(triggerToaster(true, 'Addnode needs active coin', translate('TOASTR.SETTINGS_NOTIFICATION'), 'error'));
}
}
if (json.result === 'peer was already connected') {
return dispatch => {
dispatch(triggerToaster(true, 'Peer was already connected', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning'));
}
}
if (json.result === 'addnode connection was already pending') {
return dispatch => {
dispatch(triggerToaster(true, 'Addnode connection was already pending', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning'));
}
}
if (json.result === 'addnode submitted') {
return dispatch => {
dispatch(triggerToaster(true, 'Peer is added', translate('TOASTR.SETTINGS_NOTIFICATION'), 'success'));
}
}
}
export function addPeerNode(coin, ip) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'iguana',
'method': 'addnode',
'activecoin': coin,
'ipaddr': ip,
};
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, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'addPeerNode', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(addPeerNodeState(json, dispatch));
})
}
}
export function saveAppConfig(_payload) {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appconf', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'payload': _payload }),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'saveAppConfig', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(getAppConfig()))
}
}
function getAppConfigState(json) {
return {
type: storeType.LOAD_APP_CONFIG,
config: json,
}
}
export function getAppConfig() {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appconf', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getAppConfig', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(getAppConfigState(json)))
}
}

43
react/src/actions/storeType.js

@ -0,0 +1,43 @@
export const TOASTER_MESSAGE = 'TOASTER_MESSAGE';
export const DISPLAY_ADDCOIN_MODAL = 'DISPLAY_ADDCOIN_MODAL';
export const GET_ACTIVE_COINS = 'GET_ACTIVE_COINS';
export const LOGIN = 'LOGIN';
export const ACTIVE_HANDLE = 'ACTIVE_HANDLE';
export const DASHBOARD_SECTION_CHANGE = 'DASHBOARD_SECTION_CHANGE';
export const DASHBOARD_ACTIVE_COIN_CHANGE = 'DASHBOARD_ACTIVE_COIN_CHANGE';
export const GET_MAIN_ADDRESS = 'GET_MAIN_ADDRESS';
export const DASHBOARD_ACTIVE_COIN_BALANCE = 'DASHBOARD_ACTIVE_COIN_BALANCE';
export const DASHBOARD_ACTIVE_COIN_SEND_FORM = 'DASHBOARD_ACTIVE_COIN_SEND_FORM';
export const DASHBOARD_ACTIVE_COIN_RECEIVE_FORM = 'DASHBOARD_ACTIVE_COIN_RECEIVE_FORM';
export const DASHBOARD_ACTIVE_COIN_RESET_FORMS = 'DASHBOARD_ACTIVE_COIN_RESET_FORMS';
export const ATOMIC = 'ATOMIC';
export const GET_WIF_KEY = 'GET_WIF_KEY';
export const GET_PEERS_LIST = 'GET_PEERS_LIST';
export const GET_DEBUG_LOG = 'GET_DEBUG_LOG';
export const BASILISK_REFRESH = 'BASILISK_REFRESH';
export const BASILISK_CONNECTION = 'BASILISK_CONNECTION';
export const SYNCING_FULL_MODE = 'SYNCING_FULL_MODE';
export const SYNCING_NATIVE_MODE = 'SYNCING_NATIVE_MODE';
export const ACTIVE_COIN_GET_ADDRESSES = 'ACTIVE_COIN_GET_ADDRESSES';
export const START_INTERVAL= 'START_INTERVAL';
export const STOP_INTERVAL= 'STOP_INTERVAL';
export const DASHBOARD_ACTIVE_SECTION = 'DASHBOARD_ACTIVE_SECTION';
export const DASHBOARD_ACTIVE_TXINFO_MODAL = 'DASHBOARD_ACTIVE_TXINFO_MODAL';
export const DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE = 'DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE';
export const DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY = 'DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY';
export const DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS = 'DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS';
export const DASHBOARD_ACTIVE_COIN_SENDTO = 'DASHBOARD_ACTIVE_COIN_SENDTO';
export const DASHBOARD_ACTIVE_COIN_GET_CACHE = 'DASHBOARD_ACTIVE_COIN_GET_CACHE';
export const DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR = 'DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR';
export const DASHBOARD_GET_NOTARIES_LIST = 'DASHBOARD_GET_NOTARIES_LIST';
export const DASHBOARD_DISPLAY_NOTARIES_MODAL = 'DASHBOARD_DISPLAY_NOTARIES_MODAL';
export const DASHBOARD_CONNECT_NOTARIES = 'DASHBOARD_CONNECT_NOTARIES';
export const VIEW_CACHE_DATA = 'VIEW_CACHE_DATA';
export const SYNC_ONLY_MODAL_TOGGLE = 'SYNC_ONLY_MODAL_TOGGLE';
export const SYNC_ONLY_DATA = 'SYNC_ONLY_DATA';
export const LOAD_APP_CONFIG = 'LOAD_APP_CONFIG';
export const SAVE_APP_CONFIG = 'SAVE_APP_CONFIG';
export const SERVICE_ERROR = 'SERVICE_ERROR';
export const DASHBOARD_ACTIVE_ADDRESS = 'DASHBOARD_ACTIVE_ADDRESS';
export const LOAD_APP_INFO = 'LOAD_APP_INFO';
export const LOG_GUI_HTTP = 'LOG_GUI_HTTP';

74
react/src/actions/syncInfo.js

@ -0,0 +1,74 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
// TODO: add custom json parser
function getSyncInfoState(json) {
try {
JSON.parse(json);
json = JSON.parse(json);
} catch(e) {
//
}
return {
type: storeType.SYNCING_FULL_MODE,
progress: json,
}
}
export function getSyncInfo(coin) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'coin': coin,
'agent': 'bitcoinrpc',
'method': 'getinfo',
};
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, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'getSyncInfo', 'Error', 'error'));
})
.then(function(response) {
const _response = response.text().then(function(text) { return text; });
return _response;
})
.then(function(json) {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
if (json.indexOf('coin is busy processing') === -1) {
dispatch(getSyncInfoState(json, dispatch));
}
})
}
}

58
react/src/actions/syncOnly.js

@ -0,0 +1,58 @@
import * as storeType from './storeType';
import { translate } from '../translate/translate';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function toggleSyncOnlyModal(display) {
return {
type: storeType.SYNC_ONLY_MODAL_TOGGLE,
display,
}
}
function getSyncOnlyForksState(json) {
return {
type: storeType.SYNC_ONLY_DATA,
forks: JSON.parse(json.result),
}
}
export function getSyncOnlyForks() {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/info/show', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getSyncOnlyForks', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(getSyncOnlyForksState(json)))
}
}
export function stopIguanaFork(pmid) {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/stop?pmid=' + pmid, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'stopIguanaFork', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(triggerToaster(true, 'Iguana instance is stopped', translate('TOASTR.SERVICE_NOTIFICATION'), 'success')))
}
}

26
react/src/actions/sysInfo.js

@ -0,0 +1,26 @@
import * as storeType from './storeType';
import {
triggerToaster,
Config
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function shepherdGetSysInfo() {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/sysinfo', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
}
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'Failed to get sys info', 'Error', 'error'))
})
.then(response => response.json())
.then(json => console.log(json));
}
}

209
react/src/actions/walletAuth.js

@ -0,0 +1,209 @@
import * as storeType from './storeType';
import { translate } from '../translate/translate';
import {
triggerToaster,
Config,
getMainAddressState
} from './actionCreators';
import {
logGuiHttp,
guiLogState
} from './log';
export function encryptWallet(_passphrase, cb, coin) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'bitcoinrpc',
'method': 'encryptwallet',
'passphrase': _passphrase,
};
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, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'error',
'response': error,
}));
dispatch(triggerToaster(true, 'encryptWallet', 'Error', 'error'));
})
.then(dispatch(walletPassphrase(_passphrase)))
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(cb.call(this, json, coin));
});
}
}
export function walletPassphrase(_passphrase) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'bitcoinrpc',
'method': 'walletpassphrase',
'password': _passphrase,
'timeout': '300000',
};
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, {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(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,
}));
})
}
}
export function iguanaWalletPassphrase(_passphrase) {
const _payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'handle': '',
'password': _passphrase,
'timeout': '2592000',
'agent': 'bitcoinrpc',
'method': 'walletpassphrase',
};
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'iguanaWalletPassphrase',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': _payload,
'status': 'pending',
}));
return 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, 'Error iguanaWalletPassphrase', 'Error', 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(iguanaWalletPassphraseState(json, dispatch));
});
}
}
export function iguanaActiveHandle(getMainAddress) {
const _payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'SuperNET',
'method': 'activehandle',
};
return dispatch => {
const _timestamp = Date.now();
dispatch(logGuiHttp({
'timestamp': _timestamp,
'function': 'iguanaActiveHandle',
'type': 'post',
'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
'payload': _payload,
'status': 'pending',
}));
return 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(updateErrosStack('activeHandle'));
dispatch(triggerToaster(true, translate('TOASTR.IGUANA_ARE_YOU_SURE'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error'));
})
.then(response => response.json())
.then(json => {
dispatch(logGuiHttp({
'timestamp': _timestamp,
'status': 'success',
'response': json,
}));
dispatch(getMainAddress ? getMainAddressState(json) : iguanaActiveHandleState(json));
});
}
}
function iguanaWalletPassphraseState(json, dispatch) {
sessionStorage.setItem('IguanaActiveAccount', JSON.stringify(json));
dispatch(triggerToaster(true, translate('TOASTR.LOGIN_SUCCESSFULL'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'success'));
dispatch(getMainAddressState(json));
dispatch(iguanaActiveHandleState(json));
return {
type: storeType.LOGIN,
isLoggedIn: json && json.pubkey ? true : false,
}
}
function iguanaActiveHandleState(json) {
return {
type: storeType.ACTIVE_HANDLE,
isLoggedIn: sessionStorage.getItem('IguanaActiveAccount') && JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey === json.pubkey && json.status === 'unlocked' ? true : false,
handle: json,
}
}

4
react/src/components/addcoin/addcoin.js

@ -3,9 +3,9 @@ import { translate } from '../../translate/translate';
import {
addCoin,
toggleAddcoinModal,
triggerToaster,
shepherdGetCoinList,
shepherdPostCoinList,
triggerToaster
shepherdPostCoinList
} from '../../actions/actionCreators';
import Store from '../../store';
import AddCoinOptionsCrypto from './addcoinOptionsCrypto';

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

@ -8,16 +8,15 @@ import {
startInterval,
stopInterval,
iguanaEdexBalance,
getSyncInfoNative,
getKMDBalanceTotal,
getNativeTxHistory,
getKMDAddressesNative,
getKMDOPID,
getFullTransactionsList,
getBasiliskTransactionsList,
changeActiveAddress,
getShepherdCache,
fetchNewCacheData,
changeActiveAddress
getKMDOPID,
getNativeTxHistory,
getKMDBalanceTotal
} from '../../actions/actionCreators';
import Store from '../../store';

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

@ -22,7 +22,7 @@ class Jumblr extends React.Component {
const _translationComponents = translate(_translationID).split('<br>');
return _translationComponents.map((_translation) =>
<span>
<span key={ `jumblr-label-${Math.random(0, 9) * 10}` }>
{_translation}
<br />
</span>

10
react/src/components/dashboard/navbar.js

@ -3,11 +3,11 @@ import { translate } from '../../translate/translate';
import {
dashboardChangeSection,
toggleAddcoinModal,
logout,
stopInterval,
toggleSyncOnlyModal,
startInterval,
getSyncOnlyForks
toggleSyncOnlyModal,
getSyncOnlyForks,
logout
} from '../../actions/actionCreators';
import Store from '../../store';
@ -44,7 +44,7 @@ class Navbar extends React.Component {
openSyncOnlyModal() {
Store.dispatch(getSyncOnlyForks());
var _iguanaActiveHandle = setInterval(function() {
const _iguanaActiveHandle = setInterval(function() {
Store.dispatch(getSyncOnlyForks());
}.bind(this), 3000);
Store.dispatch(startInterval('syncOnly', _iguanaActiveHandle));
@ -63,7 +63,7 @@ class Navbar extends React.Component {
<button type="button" className="navbar-toggle collapsed">
<i className="icon md-more" aria-hidden="true"></i>
</button>
<div className="navbar-brand navbar-brand-center site-gridmenu-toggle" data-toggle="gridmenu">
<div className="navbar-brand navbar-brand-center site-gridmenu-toggle">
<img
className="navbar-brand-logo hidden-xs" src="assets/images/easydex-logo-dashboard.png"
title="SuperNET Iguana" />

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

@ -1,10 +1,9 @@
import React from 'react';
import { translate } from '../../translate/translate';
import {
copyCoinAddress,
checkAddressBasilisk,
importAddressBasilisk,
validateAddressBasilisk,
copyCoinAddress
validateAddressBasilisk
} from '../../actions/actionCreators';
import Store from '../../store';

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

@ -7,23 +7,26 @@ import {
secondsElapsedToString,
secondsToString
} from '../../util/time';
import { edexGetTxIDList, edexRemoveTXID } from '../../util/cacheFormat';
import {
sendToAddress,
edexGetTxIDList,
edexRemoveTXID
} from '../../util/cacheFormat';
import {
sendFromAddress,
sendNativeTx,
getKMDOPID,
resolveOpenAliasAddress,
triggerToaster,
iguanaUTXORawTX,
clearLastSendToResponseState,
sendToAddressStateAlt,
dexSendRawTX,
fetchUtxoCache,
basiliskRefresh,
shepherdGroomPostPromise,
edexGetTransaction,
getCacheFile,
shepherdGroomPostPromise
fetchUtxoCache,
sendToAddress,
iguanaUTXORawTX,
clearLastSendToResponseState,
sendToAddressStateAlt,
dexSendRawTX
} from '../../actions/actionCreators';
import Store from '../../store';

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

@ -299,7 +299,7 @@ class Settings extends React.Component {
const _translationComponents = translate(_translationID).split('<br>');
return _translationComponents.map((_translation) =>
<span>
<span key={ `settings-label-${Math.random(0, 9) * 10}` }>
{ _translation }
<br />
</span>

9
react/src/components/dashboard/syncOnly.js

@ -1,11 +1,11 @@
import React from 'react';
import { translate } from '../../translate/translate';
import {
toggleSyncOnlyModal,
stopInterval,
addCoin,
toggleSyncOnlyModal,
stopIguanaFork,
restartIguanaInstance,
addCoin
restartIguanaInstance
} from '../../actions/actionCreators';
import Store from '../../store';
@ -231,7 +231,8 @@ class SyncOnly extends React.Component {
const forkInfo = this.props.SyncOnly.forks[port];
if (forkInfo &&
forkInfo.registry && forkInfo.getinfo) {
forkInfo.registry &&
forkInfo.getinfo) {
items.push(
<div key={ port } style={{ width: '100%' }} className="padding-bottom-60">
<div className="avatar">

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

@ -6,18 +6,18 @@ import { sortByDate } from '../../util/sort';
import {
basiliskRefresh,
basiliskConnection,
getDexNotaries,
toggleDashboardTxInfoModal,
getBasiliskTransactionsList,
changeMainBasiliskAddress,
displayNotariesModal,
deleteCacheFile,
connectNotaries,
toggleViewCacheModal,
fetchNewCacheData,
fetchUtxoCache,
changeActiveAddress,
restartBasiliskInstance,
changeActiveAddress
connectNotaries,
getDexNotaries,
deleteCacheFile,
fetchNewCacheData,
fetchUtxoCache
} from '../../actions/actionCreators';
import Store from '../../store';
@ -82,14 +82,9 @@ class WalletsData extends React.Component {
}
}
componentDidMount() {
console.log('use cache = ', this.state.useCache);
}
toggleCacheApi() {
const _useCache = !this.state.useCache;
console.log('useCache is set to', _useCache);
sessionStorage.setItem('useCache', _useCache);
this.setState(Object.assign({}, this.state, {
useCache: _useCache,

7
react/src/components/dashboard/walletsNativeReceive.js

@ -1,14 +1,11 @@
import React from 'react';
import { translate } from '../../translate/translate';
import {
getNewKMDAddresses,
copyCoinAddress
copyCoinAddress,
getNewKMDAddresses
} from '../../actions/actionCreators';
import Store from '../../store';
// TODO: implement sorting
// TODO: importaddress, importprivkey(?)
class WalletsNativeReceive extends React.Component {
constructor(props) {
super(props);

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

@ -3,10 +3,10 @@ import Config from '../../config';
import { translate } from '../../translate/translate';
import { secondsToString } from '../../util/time';
import {
sendNativeTx,
getKMDOPID,
resolveOpenAliasAddress,
triggerToaster
triggerToaster,
sendNativeTx,
getKMDOPID
} from '../../actions/actionCreators';
import Store from '../../store';

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

@ -72,7 +72,7 @@ class WalletsNav extends React.Component {
<div
className="page-header page-header-bordered header-easydex"
id="header-dashboard"
style={{ paddingBottom: '20px', marginBottom: this.props.ActiveCoin.mode !== 'basilisk' && this.props.Dashboard.progress ? '0' : '0' }}>
style={{ paddingBottom: '20px', marginBottom: this.props.ActiveCoin.mode === 'basilisk' ? '30px' : '0' }}>
<ol className="breadcrumb">
<strong>{ translate('INDEX.MY') } <span id="edexcoin-active">{ this.props && this.props.ActiveCoin ? this.props.ActiveCoin.coin : '-' }</span> { translate('INDEX.ADDRESS') }: </strong> <span id="edexcoin_active_addr">{ this.props && this.props.Dashboard && this.props.Dashboard.activeHandle ? this.props.Dashboard.activeHandle[this.props.ActiveCoin.coin] : '-' }</span> <button className="btn btn-default btn-xs clipboard-edexaddr" id="edexcoin_active_addr_clipboard" onClick={ () => this.copyMyAddress(this.props.Dashboard.activeHandle[this.props.ActiveCoin.coin]) }><i className="icon wb-copy" aria-hidden="true"></i> { translate('INDEX.COPY') }</button>
</ol>

10
react/src/components/login/login.js

@ -3,13 +3,13 @@ import { translate } from '../../translate/translate';
import {
toggleAddcoinModal,
iguanaWalletPassphrase,
createNewWallet,
iguanaActiveHandle,
toggleSyncOnlyModal,
startInterval,
stopInterval,
getDexCoins,
toggleSyncOnlyModal,
getSyncOnlyForks,
getDexCoins
createNewWallet
} from '../../actions/actionCreators';
import Store from '../../store';
import { PassPhraseGenerator } from '../../util/crypto/passphrasegenerator';
@ -41,7 +41,7 @@ class Login extends React.Component {
openSyncOnlyModal() {
Store.dispatch(getSyncOnlyForks());
var _iguanaActiveHandle = setInterval(function() {
const _iguanaActiveHandle = setInterval(function() {
Store.dispatch(getSyncOnlyForks());
}.bind(this), 3000);
Store.dispatch(startInterval('syncOnly', _iguanaActiveHandle));
@ -79,7 +79,7 @@ class Login extends React.Component {
});
if (!this.props.Interval.interval.activeCoins) {
var _iguanaActiveCoins = setInterval(function() {
const _iguanaActiveCoins = setInterval(function() {
Store.dispatch(getDexCoins());
}.bind(this), 10000);
Store.dispatch(startInterval('activeCoins', _iguanaActiveCoins));

36
react/src/components/main/main.js

@ -3,14 +3,14 @@ import Config from '../../config';
import WalletMain from './walletMain';
import { iguanaSetRPCAuth } from '../../util/auth';
import Store from '../../store';
import { getDexCoins, iguanaActiveHandle } from '../../actions/actionCreators';
import {
getDexCoins,
iguanaActiveHandle
} from '../../actions/actionCreators';
class Main extends React.Component {
constructor(props) {
super(props);
this.success = this.success.bind(this);
this.error = this.error.bind(this);
this.loading = this.loading.bind(this);
this.isWalletUnlocked = this.isWalletUnlocked.bind(this);
this.state = {
isLoggedIn: false,
@ -22,7 +22,7 @@ class Main extends React.Component {
componentDidMount() {
Store.dispatch(iguanaActiveHandle());
var _iguanaActiveHandle = setInterval(function() {
const _iguanaActiveHandle = setInterval(function() {
Store.dispatch(iguanaActiveHandle());
}, 30000);
@ -32,36 +32,12 @@ class Main extends React.Component {
}
componentWillMount() {
console.log('mounting main component');
// set userpass param
Store.dispatch(getDexCoins());
iguanaSetRPCAuth();
if (sessionStorage.getItem('session')) {
this.setState({
user: JSON.parse(sessionStorage.getItem('')),
});
}
}
error(response) {
console.error(response);
}
loading() {
console.log('loading');
}
success(response) {
sessionStorage.setItem('session', JSON.stringify(''));
this.setState({
user: JSON.parse(sessionStorage.getItem('session')),
});
}
isWalletUnlocked() {
/*if (!this.state.seed) {
return (<div>add coin form</div>);
}*/
return (
<WalletMain {...this.props} />
);
@ -70,7 +46,7 @@ class Main extends React.Component {
render() {
return (
<div>
{this.isWalletUnlocked()}
{ this.isWalletUnlocked() }
</div>
);
}

2
react/src/reducers/activeCoin.js

@ -16,7 +16,7 @@ import {
DASHBOARD_GET_NOTARIES_LIST,
DASHBOARD_DISPLAY_NOTARIES_MODAL,
DASHBOARD_ACTIVE_ADDRESS,
} from '../actions/actionCreators';
} from '../actions/storeType';
// TODO: refactor

4
react/src/reducers/addcoin.js

@ -1,4 +1,6 @@
import { DISPLAY_ADDCOIN_MODAL } from '../actions/actionCreators'
import {
DISPLAY_ADDCOIN_MODAL
} from '../actions/storeType';
export function AddCoin(state = {
display: false,

4
react/src/reducers/atomic.js

@ -1,4 +1,6 @@
import { ATOMIC } from '../actions/actionCreators';
import {
ATOMIC
} from '../actions/storeType';
export function Atomic(state = {
response: null,

2
react/src/reducers/dashboard.js

@ -9,7 +9,7 @@ import {
VIEW_CACHE_DATA,
LOG_GUI_HTTP,
TOGGLE_NOTIFICATIONS_MODAL
} from '../actions/actionCreators';
} from '../actions/storeType';
export function Dashboard(state = {
activeSection: 'wallets',

4
react/src/reducers/errors.js

@ -1,4 +1,6 @@
import { SERVICE_ERROR } from '../actions/actionCreators';
import {
SERVICE_ERROR
} from '../actions/storeType';
export function Errors(state = {
errors: {},

5
react/src/reducers/interval.js

@ -1,4 +1,7 @@
import { START_INTERVAL, STOP_INTERVAL } from '../actions/actionCreators'
import {
START_INTERVAL,
STOP_INTERVAL
} from '../actions/storeType'
export function Interval(state = {
interval: {},

2
react/src/reducers/main.js

@ -2,7 +2,7 @@ import {
GET_ACTIVE_COINS,
LOGIN,
ACTIVE_HANDLE
} from '../actions/actionCreators';
} from '../actions/storeType';
export function Main(state = {
isLoggedIn: false,

2
react/src/reducers/settings.js

@ -4,7 +4,7 @@ import {
GET_DEBUG_LOG,
LOAD_APP_CONFIG,
LOAD_APP_INFO
} from '../actions/actionCreators';
} from '../actions/storeType';
export function Settings(state = {
wifkey: null,

2
react/src/reducers/syncOnly.js

@ -1,7 +1,7 @@
import {
SYNC_ONLY_MODAL_TOGGLE,
SYNC_ONLY_DATA
} from '../actions/actionCreators';
} from '../actions/storeType';
export function SyncOnly(state = {
display: false,

4
react/src/reducers/toaster.js

@ -1,4 +1,6 @@
import { TOASTER_MESSAGE } from '../actions/actionCreators';
import {
TOASTER_MESSAGE
} from '../actions/storeType';
export function toaster(state = {
display: false,

1
react/src/util/auth.js

@ -11,5 +11,4 @@ try {
export function iguanaSetRPCAuth() {
sessionStorage.setItem('IguanaRPCAuth', appSessionHash);
console.log('passphraseGen', appSessionHash);
}
Loading…
Cancel
Save