diff --git a/react/src/actions/addCoin.js b/react/src/actions/addCoin.js index dfa13a0..7fd8e06 100644 --- a/react/src/actions/addCoin.js +++ b/react/src/actions/addCoin.js @@ -4,7 +4,8 @@ import { triggerToaster, Config, toggleAddcoinModal, - getDexCoins + getDexCoins, + startIguanaInstance } from './actionCreators'; import { logGuiHttp, @@ -49,10 +50,10 @@ export function addCoin(coin, mode, syncOnly, port) { }; return dispatch => { - startIguanaInstance(modeToValue[mode] + '/sync', coin) + startIguanaInstance(`${modeToValue[mode]}/sync`, coin) .then(function(json) { setTimeout(function() { - console.log('started ' + coin + ' / ' + modeToValue[mode] + ' fork', json); + console.log(`started ${coin} / ${modeToValue[mode]} fork`, json); dispatch(iguanaAddCoin(coin, mode, _acData, json.result)); }, 2000); }); @@ -79,12 +80,12 @@ export function iguanaAddCoin(coin, mode, acData, port) { 'timestamp': _timestamp, 'function': 'iguanaAddCoin', 'type': 'post', - 'url': 'http://127.0.0.1:' + (port ? port : Config.iguanaCorePort), + '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), { + return fetch(`http://127.0.0.1:${(port ? port : Config.iguanaCorePort)}`, { method: 'POST', body: JSON.stringify(acData), }) @@ -126,7 +127,7 @@ export function shepherdHerd(coin, mode, path) { 'ac_options': [ '-daemon=0', '-server', - '-ac_name=' + coin, + `-ac_name=${coin}`, '-addnode=78.47.196.146' ] }; @@ -160,12 +161,12 @@ export function shepherdHerd(coin, mode, path) { 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); + herdData.ac_options.push(`-ac_supply=${supply}`); } console.log('herdData', herdData); return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/herd', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/herd`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -192,7 +193,7 @@ export function addCoinResult(coin, mode) { }; return dispatch => { - dispatch(triggerToaster(true, coin + ' ' + translate('TOASTR.STARTED_IN') + ' ' + modeToValue[mode] + ' ' + translate('TOASTR.MODE'), translate('TOASTR.COIN_NOTIFICATION'), 'success')); + dispatch(triggerToaster(true, `${coin} ${translate('TOASTR.STARTED_IN')} ${modeToValue[mode]} ${translate('TOASTR.MODE')}`, translate('TOASTR.COIN_NOTIFICATION'), 'success')); dispatch(toggleAddcoinModal(false, false)); dispatch(getDexCoins()); } @@ -200,7 +201,7 @@ export function addCoinResult(coin, mode) { export function _shepherdGetConfig(coin, mode) { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/getconf`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -220,7 +221,7 @@ export function shepherdGetConfig(coin, mode) { if (coin === 'KMD' && mode === '-1') { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/getconf`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -236,7 +237,7 @@ export function shepherdGetConfig(coin, mode) { } } else { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/getconf`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/react/src/actions/addressBalance.js b/react/src/actions/addressBalance.js index 8bf3e5f..63150d0 100644 --- a/react/src/actions/addressBalance.js +++ b/react/src/actions/addressBalance.js @@ -28,43 +28,43 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 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'); + ajaxFunctionInput = '', + tmplistaddrHexInput = '', + passthruAgent = getPassthruAgent(coin), + tmpIguanaRPCAuth = `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`; if (_type === 'public') { - ajax_function_input = 'getaddressesbyaccount'; - tmplistaddr_hex_input = '222200'; + ajaxFunctionInput = 'getaddressesbyaccount'; + tmplistaddrHexInput = '222200'; } if (_type === 'private') { - ajax_function_input = 'z_listaddresses'; - tmplistaddr_hex_input = ''; + ajaxFunctionInput = 'z_listaddresses'; + tmplistaddrHexInput = ''; } - if (passthru_agent === 'iguana') { + if (passthruAgent === 'iguana') { payload = { 'userpass': tmpIguanaRPCAuth, - 'agent': passthru_agent, + 'agent': passthruAgent, 'method': 'passthru', 'asset': coin, - 'function': ajax_function_input, - 'hex': tmplistaddr_hex_input, + 'function': ajaxFunctionInput, + 'hex': tmplistaddrHexInput, }; } else { payload = { 'userpass': tmpIguanaRPCAuth, - 'agent': passthru_agent, + 'agent': passthruAgent, 'method': 'passthru', - 'function': ajax_function_input, - 'hex': tmplistaddr_hex_input, + 'function': ajaxFunctionInput, + 'hex': tmplistaddrHexInput, }; } - if (mode === 'full' || mode === 'basilisk') { + if (mode === 'full' || + mode === 'basilisk') { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'coin': coin, 'agent': 'bitcoinrpc', 'method': 'getaddressesbyaccount', @@ -75,7 +75,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { if (mode === 'basilisk') { const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey; - fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/cache?pubkey=${pubkey}`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -99,12 +99,12 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'timestamp': _timestamp, 'function': 'getKMDAddressesNative', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) @@ -131,14 +131,14 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { })) .then(result => { // TODO: split into 2 functions - const passthru_agent = getPassthruAgent(coin), - tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'); + const passthruAgent = getPassthruAgent(coin), + tmpIguanaRPCAuth = `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`; let payload; - if (passthru_agent === 'iguana') { + if (passthruAgent === 'iguana') { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), - 'agent': passthru_agent, + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, + 'agent': passthruAgent, 'method': 'passthru', 'asset': coin, 'function': 'listunspent', @@ -146,8 +146,8 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { }; } else { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), - 'agent': passthru_agent, + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, + 'agent': passthruAgent, 'method': 'passthru', 'function': 'listunspent', 'hex': '', @@ -156,7 +156,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { if (mode === 'full') { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'coin': coin, 'method': 'listunspent', 'params': [ @@ -169,7 +169,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { // if api cache option is off if (mode === 'basilisk') { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'dex', 'method': 'listunspent', 'address': currentAddress, @@ -247,7 +247,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { if (mode === 'basilisk') { const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey; - fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/cache?pubkey=${pubkey}`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -271,12 +271,12 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'timestamp': _timestamp, 'function': 'getKMDAddressesNative+Balance', 'type': 'post', - 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), + '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), { + fetch(`http://127.0.0.1:${(Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort)}`, { method: 'POST', body: JSON.stringify(payload), }) @@ -312,12 +312,12 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'timestamp': _timestamp, 'function': 'getKMDAddressesNative+Balance', 'type': 'post', - 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), + '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), { + fetch(`http://127.0.0.1:${(Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort)}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/atomic.js b/react/src/actions/atomic.js index 7f10461..6faf20f 100644 --- a/react/src/actions/atomic.js +++ b/react/src/actions/atomic.js @@ -15,12 +15,12 @@ export function atomic(payload) { 'timestamp': _timestamp, 'function': 'atomic', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/basiliskCache.js b/react/src/actions/basiliskCache.js index 588df6c..f225e08 100644 --- a/react/src/actions/basiliskCache.js +++ b/react/src/actions/basiliskCache.js @@ -10,7 +10,7 @@ import { export function deleteCacheFile(_payload) { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom?', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/groom`, { method: 'DELETE', headers: { 'Content-Type': 'application/json', @@ -30,7 +30,7 @@ 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, { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/groom?filename=${_pubkey}`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -46,16 +46,16 @@ export function getCacheFile(pubkey) { } export function fetchNewCacheData(_payload) { - const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), - _pubkey = '&pubkey=' + _payload.pubkey, + 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) : ''; + _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, { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/${_route}${_userpass}${_pubkey}${_coin}${_calls}${_address}${_iguanaInstancePort}`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -72,7 +72,7 @@ export function fetchNewCacheData(_payload) { export function getShepherdCache(pubkey, coin) { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/cache?pubkey=${pubkey}`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -108,16 +108,16 @@ function getShepherdCacheState(json, pubkey, coin) { } export function fetchUtxoCache(_payload) { - const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), - _pubkey = '&pubkey=' + _payload.pubkey, + 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) : ''; + _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, { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/${_route}${_userpass}${_pubkey}${_coin}${_calls}${_address}${_iguanaInstancePort}`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -134,7 +134,7 @@ export function fetchUtxoCache(_payload) { export function shepherdGroomPost(_filename, _payload) { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/groom/`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -155,7 +155,7 @@ export function shepherdGroomPost(_filename, _payload) { export function shepherdGroomPostPromise(_filename, _payload) { return new Promise((resolve, reject) => { - fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/groom/`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/react/src/actions/basiliskProcessAddress.js b/react/src/actions/basiliskProcessAddress.js index fe1582f..7ca0707 100644 --- a/react/src/actions/basiliskProcessAddress.js +++ b/react/src/actions/basiliskProcessAddress.js @@ -11,7 +11,7 @@ import { export function checkAddressBasilisk(coin, address) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'dex', 'method': 'checkaddress', 'address': address, @@ -24,12 +24,12 @@ export function checkAddressBasilisk(coin, address) { 'timestamp': _timestamp, 'function': 'checkAddressBasilisk', 'type': 'post', - 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), + '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), { + return fetch(`http://127.0.0.1:${Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) @@ -73,7 +73,7 @@ function checkAddressBasiliskHandle(json) { export function validateAddressBasilisk(coin, address) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'dex', 'method': 'validateaddress', 'address': address, @@ -86,12 +86,12 @@ export function validateAddressBasilisk(coin, address) { 'timestamp': _timestamp, 'function': 'validateAddressBasilisk', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + '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), { + return fetch(`http://127.0.0.1:${Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/basiliskTxHistory.js b/react/src/actions/basiliskTxHistory.js index 50d38f4..cb12126 100644 --- a/react/src/actions/basiliskTxHistory.js +++ b/react/src/actions/basiliskTxHistory.js @@ -13,7 +13,7 @@ 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, { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/cache?pubkey=${pubkey}`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/react/src/actions/coinList.js b/react/src/actions/coinList.js index 0e4f31b..cf1f4d4 100644 --- a/react/src/actions/coinList.js +++ b/react/src/actions/coinList.js @@ -10,7 +10,7 @@ import { export function shepherdGetCoinList() { return new Promise((resolve, reject) => { - fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/coinslist', { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/coinslist`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -27,7 +27,7 @@ export function shepherdGetCoinList() { export function shepherdPostCoinList(data) { return new Promise((resolve, reject) => { - fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/coinslist', { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/coinslist`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/react/src/actions/createWallet.js b/react/src/actions/createWallet.js index 425a2b6..9c16144 100644 --- a/react/src/actions/createWallet.js +++ b/react/src/actions/createWallet.js @@ -25,7 +25,7 @@ function createNewWalletState(json) { export function createNewWallet(_passphrase) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'bitcoinrpc', 'method': 'encryptwallet', 'passphrase': _passphrase, @@ -37,12 +37,12 @@ export function createNewWallet(_passphrase) { 'timestamp': _timestamp, 'function': 'createNewWallet', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/dexCoins.js b/react/src/actions/dexCoins.js index 7f10dd2..e69dc7d 100644 --- a/react/src/actions/dexCoins.js +++ b/react/src/actions/dexCoins.js @@ -11,7 +11,7 @@ import { export function getDexCoins() { const _payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'InstantDEX', 'method': 'allcoins', }; @@ -22,12 +22,12 @@ export function getDexCoins() { 'timestamp': _timestamp, 'function': 'getDexCoins', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': _payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(_payload) }) diff --git a/react/src/actions/edexBalance.js b/react/src/actions/edexBalance.js index b760791..ecc96e2 100644 --- a/react/src/actions/edexBalance.js +++ b/react/src/actions/edexBalance.js @@ -10,7 +10,7 @@ import { export function iguanaEdexBalance(coin) { const _payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'bitcoinrpc', 'method': 'getbalance', 'coin': coin, @@ -23,12 +23,12 @@ export function iguanaEdexBalance(coin) { 'timestamp': _timestamp, 'function': 'iguanaEdexBalance', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': _payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(_payload), }) @@ -57,7 +57,7 @@ function iguanaEdexBalanceState(json) { export function getDexBalance(coin, mode, addr) { Promise.all(addr.map((_addr, index) => { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'dex', 'method': 'listunspent', 'address': _addr, @@ -70,12 +70,12 @@ export function getDexBalance(coin, mode, addr) { 'timestamp': _timestamp, 'function': 'getDexBalance', 'type': 'post', - 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), + '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), { + fetch(`http://127.0.0.1:${Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/edexGetTx.js b/react/src/actions/edexGetTx.js index 8cd1139..eb5d3b7 100644 --- a/react/src/actions/edexGetTx.js +++ b/react/src/actions/edexGetTx.js @@ -8,9 +8,9 @@ import { guiLogState } from './log'; -export function edexGetTransaction(data) { +export function edexGetTransaction(data, dispatch) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'symbol': data.coin, 'agent': 'dex', 'method': 'gettransaction', @@ -24,12 +24,12 @@ export function edexGetTransaction(data) { 'timestamp': _timestamp, 'function': 'edexGetTransaction', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/fullTxHistory.js b/react/src/actions/fullTxHistory.js index f73492e..19120ee 100644 --- a/react/src/actions/fullTxHistory.js +++ b/react/src/actions/fullTxHistory.js @@ -11,7 +11,7 @@ import { export function getFullTransactionsList(coin) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'coin': coin, 'method': 'listtransactions', 'params': [ @@ -27,12 +27,12 @@ export function getFullTransactionsList(coin) { 'timestamp': _timestamp, 'function': 'getFullTransactionsList', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/getAddrByAccount.js b/react/src/actions/getAddrByAccount.js index f1238d0..653d038 100644 --- a/react/src/actions/getAddrByAccount.js +++ b/react/src/actions/getAddrByAccount.js @@ -31,7 +31,7 @@ export function getAddressesByAccountState(json, coin, mode) { export function getAddressesByAccount(coin, mode) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'coin': coin, 'agent': 'bitcoinrpc', 'method': 'getaddressesbyaccount', @@ -44,12 +44,12 @@ export function getAddressesByAccount(coin, mode) { 'timestamp': _timestamp, 'function': 'getAddressesByAccount', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/iguanaHelpers.js b/react/src/actions/iguanaHelpers.js index 97b8371..e2f6704 100644 --- a/react/src/actions/iguanaHelpers.js +++ b/react/src/actions/iguanaHelpers.js @@ -22,7 +22,7 @@ export function getPassthruAgent(coin) { export function iguanaHashHex(data, dispatch) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'hash', 'method': 'hex', 'message': data, @@ -34,12 +34,12 @@ export function iguanaHashHex(data, dispatch) { 'timestamp': _timestamp, 'function': 'iguanaHashHex', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/iguanaInstance.js b/react/src/actions/iguanaInstance.js index 4a6adfd..cd5be58 100644 --- a/react/src/actions/iguanaInstance.js +++ b/react/src/actions/iguanaInstance.js @@ -10,7 +10,7 @@ import { export function restartIguanaInstance(pmid) { return new Promise((resolve, reject) => { - fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/restart?pmid=' + pmid, { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/forks/restart?pmid=${pmid}`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -43,7 +43,7 @@ export function restartBasiliskInstance() { export function startIguanaInstance(mode, coin) { return new Promise((resolve, reject) => { - fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks', { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/forks`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -64,7 +64,7 @@ export function startIguanaInstance(mode, coin) { export function getIguanaInstancesList() { return new Promise((resolve, reject) => { - fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks', { + fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/forks`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/react/src/actions/log.js b/react/src/actions/log.js index 51e17ba..8fad44c 100644 --- a/react/src/actions/log.js +++ b/react/src/actions/log.js @@ -9,7 +9,7 @@ export function logGuiHttp(payload) { dispatch(guiLogState(payload)); // disabled for now - /*return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/guilog', { + /*return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/guilog`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -26,7 +26,7 @@ export function logGuiHttp(payload) { export function getAgamaLog(type) { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getlog?type=' + type, { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/getlog?type=${type}`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/react/src/actions/logout.js b/react/src/actions/logout.js index bfeb1e2..5c8affa 100644 --- a/react/src/actions/logout.js +++ b/react/src/actions/logout.js @@ -25,7 +25,7 @@ export function logout() { function walletLock() { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'bitcoinrpc', 'method': 'walletlock', }; @@ -36,12 +36,12 @@ function walletLock() { 'timestamp': _timestamp, 'function': 'walletLock', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/nativeBalance.js b/react/src/actions/nativeBalance.js index f8931b2..cd13543 100644 --- a/react/src/actions/nativeBalance.js +++ b/react/src/actions/nativeBalance.js @@ -15,7 +15,7 @@ export function getKMDBalanceTotal(coin) { if (coin !== 'KMD' && coin !== 'ZEC') { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'iguana', 'method': 'passthru', 'asset': coin, @@ -24,7 +24,7 @@ export function getKMDBalanceTotal(coin) { }; } else { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': getPassthruAgent(coin), 'method': 'passthru', 'function': 'z_gettotalbalance', @@ -38,12 +38,12 @@ export function getKMDBalanceTotal(coin) { 'timestamp': _timestamp, 'function': 'getKMDBalanceTotal', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/nativeNewAddress.js b/react/src/actions/nativeNewAddress.js index 93f3425..f47a058 100644 --- a/react/src/actions/nativeNewAddress.js +++ b/react/src/actions/nativeNewAddress.js @@ -19,22 +19,22 @@ function handleGetNewKMDAddresses(pubpriv, coin, dispatch) { export function getNewKMDAddresses(coin, pubpriv) { let payload, - ajax_function_input = ''; + ajaxFunctionInput = ''; if (pubpriv === 'public') { - ajax_function_input = 'getnewaddress'; + ajaxFunctionInput = 'getnewaddress'; } if (pubpriv === 'private') { - ajax_function_input = 'z_getnewaddress'; + ajaxFunctionInput = 'z_getnewaddress'; } if (getPassthruAgent(coin) === 'iguana') { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': getPassthruAgent(coin), 'method': 'passthru', 'asset': coin, - 'function': ajax_function_input, + 'function': ajaxFunctionInput, 'hex': '', }; } else { @@ -42,7 +42,7 @@ export function getNewKMDAddresses(coin, pubpriv) { 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), 'agent': coin, 'method': 'passthru', - 'function': ajax_function_input, + 'function': ajaxFunctionInput, 'hex': '', }; } @@ -53,12 +53,12 @@ export function getNewKMDAddresses(coin, pubpriv) { 'timestamp': _timestamp, 'function': 'getNewKMDAddresses', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/nativeSend.js b/react/src/actions/nativeSend.js index 4d005d4..3bd6a95 100644 --- a/react/src/actions/nativeSend.js +++ b/react/src/actions/nativeSend.js @@ -12,23 +12,23 @@ import { } from './log'; export function sendNativeTx(coin, _payload) { - let ajax_data_to_hex; + let ajaxDataToHex; let payload; let _apiMethod; if (_payload.addressType === 'public') { _apiMethod = 'sendtoaddress'; - ajax_data_to_hex = '["' + _payload.sendTo + '", ' + (Number(_payload.amount) - Number(_payload.fee)) + ']'; + ajaxDataToHex = `["${_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)) + '}]]'; + ajaxDataToHex = `["${_payload.sendFrom}", [{"address": "${_payload.sendTo}", "amount": ${Number(_payload.amount) - Number(_payload.fee)}}]]`; } return dispatch => { - return iguanaHashHex(ajax_data_to_hex, dispatch).then((hashHexJson) => { + return iguanaHashHex(ajaxDataToHex, dispatch).then((hashHexJson) => { if (getPassthruAgent(coin) === 'iguana') { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': getPassthruAgent(coin), 'method': 'passthru', 'asset': coin, @@ -37,7 +37,7 @@ export function sendNativeTx(coin, _payload) { }; } else { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': getPassthruAgent(coin), 'method': 'passthru', 'function': _apiMethod, @@ -50,12 +50,12 @@ export function sendNativeTx(coin, _payload) { 'timestamp': _timestamp, 'function': 'sendNativeTx', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) @@ -68,7 +68,16 @@ export function sendNativeTx(coin, _payload) { })); dispatch(triggerToaster(true, 'sendNativeTx', 'Error', 'error')); }) - .then(response => response.json()) + .then(function(response) { + if (_apiMethod === 'sendtoaddress') { + const _response = response.text().then(function(text) { return text; }); + + console.log('native sendtoaddress', _response); + return _response; + } else { + return response.json(); + } + }) .then(function(json) { dispatch(logGuiHttp({ 'timestamp': _timestamp, @@ -83,10 +92,6 @@ export function sendNativeTx(coin, _payload) { 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); - }) }); } } @@ -99,29 +104,29 @@ export function getKMDOPIDState(json) { } export function getKMDOPID(opid, coin) { - let tmpopid_output = '', - ajax_data_to_hex; + let tmpopidOutput = '', + ajaxDataToHex; if (opid === undefined) { - ajax_data_to_hex = null; + ajaxDataToHex = null; } else { - ajax_data_to_hex = '["' + opid + '"]'; + ajaxDataToHex = `["${opid}"]`; } return dispatch => { - return iguanaHashHex(ajax_data_to_hex, dispatch).then((hashHexJson) => { + return iguanaHashHex(ajaxDataToHex, dispatch).then((hashHexJson) => { if (hashHexJson === '5b226e756c6c225d00') { hashHexJson = ''; } let payload, - passthru_agent = getPassthruAgent(coin), - tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'); + passthruAgent = getPassthruAgent(coin), + tmpIguanaRPCAuth = `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`; - if (passthru_agent == 'iguana') { + if (passthruAgent == 'iguana') { payload = { 'userpass': tmpIguanaRPCAuth, - 'agent': passthru_agent, + 'agent': passthruAgent, 'method': 'passthru', 'asset': coin, 'function': 'z_getoperationstatus', @@ -130,7 +135,7 @@ export function getKMDOPID(opid, coin) { } else { payload = { 'userpass': tmpIguanaRPCAuth, - 'agent': passthru_agent, + 'agent': passthruAgent, 'method': 'passthru', 'function': 'z_getoperationstatus', 'hex': hashHexJson, @@ -142,12 +147,12 @@ export function getKMDOPID(opid, coin) { 'timestamp': _timestamp, 'function': 'getKMDOPID', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/nativeSyncInfo.js b/react/src/actions/nativeSyncInfo.js index 5c0aa85..d73e4d1 100644 --- a/react/src/actions/nativeSyncInfo.js +++ b/react/src/actions/nativeSyncInfo.js @@ -19,12 +19,12 @@ export function getSyncInfoNativeKMD(skipDebug) { 'timestamp': _timestamp, 'function': 'getSyncInfoNativeKMD', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort + '/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=' + coin, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}/api/dex/getinfo?userpass=tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}&symbol=${coin}`, 'payload': '', 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort + '/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=' + coin, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}/api/dex/getinfo?userpass=tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}&symbol=${coin}`, { method: 'GET', }) .catch(function(error) { @@ -68,7 +68,7 @@ function getSyncInfoNativeState(json, coin, skipDebug) { export function getSyncInfoNative(coin, skipDebug) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': getPassthruAgent(coin), 'method': 'passthru', 'asset': coin, @@ -82,12 +82,12 @@ export function getSyncInfoNative(coin, skipDebug) { 'timestamp': _timestamp, 'function': 'getSyncInfo', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/nativeTxHistory.js b/react/src/actions/nativeTxHistory.js index 2b45e07..e38ea18 100644 --- a/react/src/actions/nativeTxHistory.js +++ b/react/src/actions/nativeTxHistory.js @@ -15,7 +15,7 @@ export function getNativeTxHistory(coin) { if (getPassthruAgent(coin) === 'iguana') { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'iguana', 'method': 'passthru', 'asset': coin, @@ -24,7 +24,7 @@ export function getNativeTxHistory(coin) { }; } else { payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': getPassthruAgent(coin), 'method': 'passthru', 'function': 'listtransactions', @@ -38,12 +38,12 @@ export function getNativeTxHistory(coin) { 'timestamp': _timestamp, 'function': 'getNativeTxHistory', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/notary.js b/react/src/actions/notary.js index 2582b70..72874fa 100644 --- a/react/src/actions/notary.js +++ b/react/src/actions/notary.js @@ -13,7 +13,7 @@ function initNotaryNodesConSequence(nodes) { return dispatch => { Promise.all(nodes.map((node, index) => { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'dex', 'method': 'getinfo', 'symbol': node, @@ -24,14 +24,14 @@ function initNotaryNodesConSequence(nodes) { const _timestamp = Date.now(); dispatch(logGuiHttp({ 'timestamp': _timestamp, - 'function': 'initNotaryNodesConSequence+' + node, + 'function': `initNotaryNodesConSequence+${node}`, 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + '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, { + 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) { @@ -41,7 +41,7 @@ function initNotaryNodesConSequence(nodes) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getInfoDexNode+' + node, 'Error', 'error')); + dispatch(triggerToaster(true, `getInfoDexNode+${node}`, 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -99,13 +99,13 @@ function connectAllNotaryNodes(json, dispatch) { export function connectNotaries() { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'dpow', 'method': 'notarychains', }; return dispatch => { - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) @@ -133,7 +133,7 @@ function getDexNotariesState(json) { export function getDexNotaries(coin) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'dex', 'method': 'getnotaries', 'symbol': coin, @@ -145,11 +145,11 @@ export function getDexNotaries(coin) { 'timestamp': _timestamp, 'function': 'getDexNotaries', 'type': 'post', - 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), + '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), { + return fetch(`http://127.0.0.1:${Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/sendFullBasilisk.js b/react/src/actions/sendFullBasilisk.js index 2ce0ce5..3ade2ef 100644 --- a/react/src/actions/sendFullBasilisk.js +++ b/react/src/actions/sendFullBasilisk.js @@ -2,7 +2,8 @@ import * as storeType from './storeType'; import { translate } from '../translate/translate'; import { triggerToaster, - Config + Config, + getDispatch } from './actionCreators'; import { logGuiHttp, @@ -11,7 +12,7 @@ import { export function sendToAddress(coin, _payload) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'coin': coin, 'method': 'sendtoaddress', 'params': [ @@ -28,12 +29,12 @@ export function sendToAddress(coin, _payload) { 'timestamp': _timestamp, 'function': 'sendToAddress', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) @@ -60,7 +61,7 @@ export function sendToAddress(coin, _payload) { export function sendFromAddress(coin, _payload) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'coin': coin, 'method': 'sendfrom', 'params': [ @@ -78,12 +79,12 @@ export function sendFromAddress(coin, _payload) { 'timestamp': _timestamp, 'function': 'sendFromAddress', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) @@ -108,9 +109,9 @@ export function sendFromAddress(coin, _payload) { } } -export function iguanaUTXORawTX(data) { +export function iguanaUTXORawTX(data, dispatch) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'symbol': data.coin, 'agent': 'basilisk', 'method': 'utxorawtx', @@ -132,18 +133,18 @@ export function iguanaUTXORawTX(data) { 'timestamp': _timestamp, 'function': 'iguanaUTXORawTX', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - dispatch(logGuiHttp({ + dispatch => dispatch(logGuiHttp({ 'timestamp': _timestamp, 'status': 'error', 'response': error, @@ -162,9 +163,9 @@ export function iguanaUTXORawTX(data) { }); } -export function dexSendRawTX(data) { +export function dexSendRawTX(data, dispatch) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'dex', 'method': 'sendrawtransaction', 'signedtx': data.signedtx, @@ -177,7 +178,7 @@ export function dexSendRawTX(data) { 'timestamp': _timestamp, 'function': 'dexSendRawTX', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); diff --git a/react/src/actions/settings.js b/react/src/actions/settings.js index 25d7832..0204912 100644 --- a/react/src/actions/settings.js +++ b/react/src/actions/settings.js @@ -18,7 +18,7 @@ function getAppInfoState(json) { export function getAppInfo() { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appinfo', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/appinfo`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -36,7 +36,7 @@ export function getAppInfo() { export function settingsWifkeyState(json, coin) { return { type: storeType.GET_WIF_KEY, - wifkey: json[coin + 'wif'], + wifkey: json[`{$coin}wif`], address: json[coin], } } @@ -63,7 +63,7 @@ function parseImportPrivKeyResponse(json, dispatch) { export function importPrivKey(wifKey) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'method': 'importprivkey', 'params': [ wifKey, @@ -77,12 +77,12 @@ export function importPrivKey(wifKey) { 'timestamp': _timestamp, 'function': 'importPrivKey', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) @@ -129,7 +129,7 @@ export function getDebugLog(target, linesCount) { }; return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/debuglog', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/debuglog`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -147,7 +147,7 @@ export function getDebugLog(target, linesCount) { export function getPeersList(coin) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'SuperNET', 'method': 'getpeers', 'activecoin': coin, @@ -159,12 +159,12 @@ export function getPeersList(coin) { 'timestamp': _timestamp, 'function': 'getPeersList', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) @@ -232,7 +232,7 @@ function addPeerNodeState(json, dispatch) { export function addPeerNode(coin, ip) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'iguana', 'method': 'addnode', 'activecoin': coin, @@ -245,12 +245,12 @@ export function addPeerNode(coin, ip) { 'timestamp': _timestamp, 'function': 'addPeerNode', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) @@ -277,7 +277,7 @@ export function addPeerNode(coin, ip) { export function saveAppConfig(_payload) { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appconf', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/appconf`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -302,7 +302,7 @@ function getAppConfigState(json) { export function getAppConfig() { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appconf', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/appconf`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/react/src/actions/syncInfo.js b/react/src/actions/syncInfo.js index 7a07627..edf78ef 100644 --- a/react/src/actions/syncInfo.js +++ b/react/src/actions/syncInfo.js @@ -25,7 +25,7 @@ function getSyncInfoState(json) { export function getSyncInfo(coin) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'coin': coin, 'agent': 'bitcoinrpc', 'method': 'getinfo', @@ -37,12 +37,12 @@ export function getSyncInfo(coin) { 'timestamp': _timestamp, 'function': 'getSyncInfo', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) diff --git a/react/src/actions/syncOnly.js b/react/src/actions/syncOnly.js index 0415818..cb43f78 100644 --- a/react/src/actions/syncOnly.js +++ b/react/src/actions/syncOnly.js @@ -25,7 +25,7 @@ function getSyncOnlyForksState(json) { export function getSyncOnlyForks() { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/info/show', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/forks/info/show`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -42,7 +42,7 @@ export function getSyncOnlyForks() { export function stopIguanaFork(pmid) { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/stop?pmid=' + pmid, { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/forks/stop?pmid=${pmid}`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/react/src/actions/sysInfo.js b/react/src/actions/sysInfo.js index b652a27..909d8f5 100644 --- a/react/src/actions/sysInfo.js +++ b/react/src/actions/sysInfo.js @@ -10,7 +10,7 @@ import { export function shepherdGetSysInfo() { return dispatch => { - return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/sysinfo', { + return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/sysinfo`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/react/src/actions/walletAuth.js b/react/src/actions/walletAuth.js index 19dfe6a..ccf491c 100644 --- a/react/src/actions/walletAuth.js +++ b/react/src/actions/walletAuth.js @@ -13,7 +13,7 @@ import { export function encryptWallet(_passphrase, cb, coin) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'bitcoinrpc', 'method': 'encryptwallet', 'passphrase': _passphrase, @@ -25,12 +25,12 @@ export function encryptWallet(_passphrase, cb, coin) { 'timestamp': _timestamp, 'function': 'encryptWallet', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) @@ -58,7 +58,7 @@ export function encryptWallet(_passphrase, cb, coin) { export function walletPassphrase(_passphrase) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'bitcoinrpc', 'method': 'walletpassphrase', 'password': _passphrase, @@ -71,12 +71,12 @@ export function walletPassphrase(_passphrase) { 'timestamp': _timestamp, 'function': 'walletpassphrase', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(payload), }) @@ -101,7 +101,7 @@ export function walletPassphrase(_passphrase) { export function iguanaWalletPassphrase(_passphrase) { const _payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'handle': '', 'password': _passphrase, 'timeout': '2592000', @@ -115,12 +115,12 @@ export function iguanaWalletPassphrase(_passphrase) { 'timestamp': _timestamp, 'function': 'iguanaWalletPassphrase', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': _payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(_payload), }) @@ -147,7 +147,7 @@ export function iguanaWalletPassphrase(_passphrase) { export function iguanaActiveHandle(getMainAddress) { const _payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'userpass': `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, 'agent': 'SuperNET', 'method': 'activehandle', }; @@ -158,12 +158,12 @@ export function iguanaActiveHandle(getMainAddress) { 'timestamp': _timestamp, 'function': 'iguanaActiveHandle', 'type': 'post', - 'url': 'http://127.0.0.1:' + Config.iguanaCorePort, + 'url': `http://127.0.0.1:${Config.iguanaCorePort}`, 'payload': _payload, 'status': 'pending', })); - return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { method: 'POST', body: JSON.stringify(_payload), }) diff --git a/react/src/components/addcoin/addcoin.js b/react/src/components/addcoin/addcoin.js index e2816e6..4309a62 100644 --- a/react/src/components/addcoin/addcoin.js +++ b/react/src/components/addcoin/addcoin.js @@ -97,12 +97,12 @@ class AddCoin extends React.Component { modalClassName: props.display ? 'show fade' : 'show fade', })); - setTimeout(function() { + setTimeout(() => { this.setState(Object.assign({}, this.state, { display: props.display, modalClassName: props.display ? 'show in' : 'hide', })); - }.bind(this), 100); + }, 100); } } @@ -216,7 +216,7 @@ class AddCoin extends React.Component { for (let i = 1; i < this.state.coins.length; i++) { const _item = this.state.coins[i]; - setTimeout(function() { + setTimeout(() => { Store.dispatch(addCoin( _item.selectedCoin.split('|')[0], _item.mode, @@ -233,7 +233,7 @@ class AddCoin extends React.Component { Store.dispatch(toggleAddcoinModal(false, false)); } - }.bind(this), 2000 * i); + }, 2000 * i); } } @@ -245,7 +245,7 @@ class AddCoin extends React.Component { const _coin = _item.selectedCoin || ''; items.push( -
1 ? 'multi' : 'single' } key={ 'add-coin-' + i }> +
1 ? 'multi' : 'single' } key={ `add-coin-${i}` }>
+ onChange={ this.updateSelectedAPI }> { this.renderAtomicOptions() } diff --git a/react/src/components/dashboard/coinTile.js b/react/src/components/dashboard/coinTile.js index 4ca8c9f..bb44c56 100755 --- a/react/src/components/dashboard/coinTile.js +++ b/react/src/components/dashboard/coinTile.js @@ -1,5 +1,9 @@ import React from 'react'; import { translate } from '../../translate/translate'; +import { + getCoinTitle, + getModeInfo +} from '../../util/coinHelper'; import CoinTileItem from './coinTileItem'; class CoinTile extends React.Component { @@ -17,311 +21,20 @@ class CoinTile extends React.Component { 'full' ]; const allCoins = this.props.Main.coins; - var items = []; + let items = []; - if (this.props.Main && this.props.Main.coins) { + if (this.props.Main && + allCoins) { modes.map(function(mode) { allCoins[mode].map(function(coin) { - var coinlogo = '', - coinname = '', - modecode = '', - modetip = '', - modecolor = ''; + const _coinMode = getModeInfo(mode), + modecode = _coinMode.code, + modetip = _coinMode.tip, + modecolor = _coinMode.color; - switch (mode) { - case 'native': - modecode = 'Native'; - modetip = 'Native'; - modecolor = 'primary'; - break; - case 'basilisk': - modecode = 'Basilisk'; - modetip = 'Basilisk'; - modecolor = 'info'; - break; - case 'full': - modecode = 'Full'; - modetip = 'Full'; - modecolor = 'success'; - break; - case 'virtual': - modecode = 'Virtual'; - modetip = 'Virtual'; - modecolor = 'danger'; - break; - case 'notarychains': - modecode = 'Notarychains'; - modetip = 'Notarychains'; - modecolor = 'dark'; - break; - } - - switch (coin) { - case 'BTC': - coinlogo = 'bitcoin'; - coinname = 'Bitcoin'; - break; - case 'BTCD': - coinlogo = 'bitcoindark'; - coinname = 'BitcoinDark'; - break; - case 'LTC': - coinlogo = 'litecoin'; - coinname = 'Litecoin'; - break; - case 'VPN': - coinlogo = 'vpncoin'; - coinname = 'VPNcoin'; - break; - case 'SYS': - coinlogo = 'syscoin'; - coinname = 'Syscoin'; - break; - case 'ZEC': - coinlogo = 'zcash'; - coinname = 'Zcash'; - break; - case 'NMC': - coinlogo = 'namecoin'; - coinname = 'Namecoin'; - break; - case 'DEX': - coinlogo = 'dex'; - coinname = 'InstantDEX'; - break; - case 'DOGE': - coinlogo = 'dogecoin'; - coinname = 'Dogecoin'; - break; - case 'DGB': - coinlogo = 'digibyte'; - coinname = 'Digibyte'; - break; - case 'MZC': - coinlogo = 'mazacoin'; - coinname = 'Mazacoin'; - break; - case 'UNO': - coinlogo = 'unobtanium'; - coinname = 'Unobtanium'; - break; - case 'ZET': - coinlogo = 'zetacoin'; - coinname = 'Zetacoin'; - break; - case 'KMD': - coinlogo = 'komodo'; - coinname = 'Komodo'; - break; - case 'BTM': - coinlogo = 'bitmark'; - coinname = 'Bitmark'; - break; - case 'CARB': - coinlogo = 'carboncoin'; - coinname = 'Carboncoin'; - break; - case 'ANC': - coinlogo = 'anoncoin'; - coinname = 'AnonCoin'; - break; - case 'FRK': - coinlogo = 'franko'; - coinname = 'Franko'; - break; - case 'GAME': - coinlogo = 'GAME'; - coinname = 'GameCredits'; - break; - case 'SUPERNET': - coinlogo = 'SUPERNET'; - coinname = 'SUPERNET'; - break; - case 'REVS': - coinlogo = 'REVS'; - coinname = 'REVS'; - break; - case 'WLC': - coinlogo = 'WLC'; - coinname = 'WIRELESS'; - break; - case 'PANGEA': - coinlogo = 'PANGEA'; - coinname = 'PANGEA'; - break; - case 'JUMBLR': - coinlogo = 'JUMBLR'; - coinname = 'JUMBLR'; - break; - case 'BET': - coinlogo = 'BET'; - coinname = 'BET'; - break; - case 'CRYPTO': - coinlogo = 'CRYPTO'; - coinname = 'CRYPTO'; - break; - case 'HODL': - coinlogo = 'HODL'; - coinname = 'HODL'; - break; - case 'SHARK': - coinlogo = 'SHARK'; - coinname = 'SHARK'; - break; - case 'BOTS': - coinlogo = 'BOTS'; - coinname = 'BOTS'; - break; - case 'MGW': - coinlogo = 'MGW'; - coinname = 'MultiGateway'; - break; - case 'MVP': - coinlogo = 'MVP'; - coinname = 'MVP Lineup'; - break; - case 'KV': - coinlogo = 'KV'; - coinname = 'KV'; - break; - case 'CEAL': - coinlogo = 'CEAL'; - coinname = 'CEAL NET'; - break; - case 'MESH': - coinlogo = 'MESH'; - coinname = 'SpaceMesh'; - break; - case 'USD': - coinlogo = 'usd'; - coinname = 'US Dollar'; - break; - case 'RON': - coinlogo = 'RON'; - coinname = 'Romanian Leu'; - break; - case 'EUR': - coinlogo = 'EUR'; - coinname = 'Euro'; - break; - case 'JPY': - coinlogo = 'JPY'; - coinname = 'Japanese Yen'; - break; - case 'GBP': - coinlogo = 'GBP'; - coinname = 'British Pound'; - break; - case 'AUD': - coinlogo = 'AUD'; - coinname = 'Australian Dollar'; - break; - case 'CAD': - coinlogo = 'CAD'; - coinname = 'Canadian Dollar'; - break; - case 'CHF': - coinlogo = 'CHF'; - coinname = 'Swiss Franc'; - break; - case 'NZD': - coinlogo = 'NZD'; - coinname = 'New Zealand Dollar'; - break; - case 'CNY': - coinlogo = 'CNY'; - coinname = 'Chinese Yuan'; - break; - case 'RUB': - coinlogo = 'RUB'; - coinname = 'Russian Ruble'; - break; - case 'MXN': - coinlogo = 'MXN'; - coinname = 'Mexican peso'; - break; - case 'BRL': - coinlogo = 'BRL'; - coinname = 'Brazilian Real'; - break; - case 'INR': - coinlogo = 'INR'; - coinname = 'Indian Rupee'; - break; - case 'HKD': - coinlogo = 'HKD'; - coinname = 'Hong Kong Dollar'; - break; - case 'TRY': - coinlogo = 'TRY'; - coinname = 'Turkish Lira'; - break; - case 'ZAR': - coinlogo = 'ZAR'; - coinname = 'South African Rand'; - break; - case 'PLN': - coinlogo = 'PLN'; - coinname = 'Polish Zloty'; - break; - case 'NOK': - coinlogo = 'NOK'; - coinname = 'Norwegian Krone'; - break; - case 'SEK': - coinlogo = 'SEK'; - coinname = 'Swedish Krona'; - break; - case 'DKK': - coinlogo = 'DKK'; - coinname = 'Danish Krone'; - break; - case 'CZK': - coinlogo = 'CZK'; - coinname = 'Czech Koruna'; - break; - case 'HUF': - coinlogo = 'HUF'; - coinname = 'Hungarian Forint'; - break; - case 'ILS': - coinlogo = 'ILS'; - coinname = 'Israeli Shekel'; - break; - case 'KRW': - coinlogo = 'KRW'; - coinname = 'Korean Won'; - break; - case 'MYR': - coinlogo = 'MYR'; - coinname = 'Malaysian Ringgit'; - break; - case 'PHP': - coinlogo = 'PHP'; - coinname = 'Philippine Peso'; - break; - case 'SGD': - coinlogo = 'SGD'; - coinname = 'Singapore Dollar'; - break; - case 'THB': - coinlogo = 'THB'; - coinname = 'Thai Baht'; - break; - case 'BGN': - coinlogo = 'BGN'; - coinname = 'Bulgarian Lev'; - break; - case 'IDR': - coinlogo = 'IDR'; - coinname = 'Indonesian Rupiah'; - break; - case 'HRK': - coinlogo = 'HRK'; - coinname = 'Croatian Kuna'; - break; - } + const _coinTitle = getCoinTitle(coin), + coinlogo = _coinTitle.logo, + coinname = _coinTitle.name; items.push({ coinlogo, diff --git a/react/src/components/dashboard/coinTileItem.js b/react/src/components/dashboard/coinTileItem.js index 89049b7..5b5a40e 100644 --- a/react/src/components/dashboard/coinTileItem.js +++ b/react/src/components/dashboard/coinTileItem.js @@ -21,6 +21,11 @@ import { } from '../../actions/actionCreators'; import Store from '../../store'; +const BASILISK_CACHE_UPDATE_TIMEOUT = 240000; +const IGUNA_ACTIVE_HANDLE_TIMEOUT = 3000; +const IGUNA_ACTIVE_HANDLE_TIMEOUT_KMD_NATIVE = 15000; +const NATIVE_MIN_SYNC_PERCENTAGE_THRESHOLD = 90; + class CoinTileItem extends React.Component { constructor(props) { super(props); @@ -39,10 +44,13 @@ class CoinTileItem extends React.Component { dispatchCoinActions(coin, mode) { if (mode === 'native') { Store.dispatch(iguanaActiveHandle(true)); + const syncPercentage = this.props.Dashboard && this.props.Dashboard.progress && (parseFloat(parseInt(this.props.Dashboard.progress.blocks, 10) * 100 / parseInt(this.props.Dashboard.progress.longestchain, 10)).toFixed(2)).replace('NaN', 0); + if (this.props.Dashboard.progress && this.props.Dashboard.progress.blocks && this.props.Dashboard.progress.longestchain && - this.props.Dashboard.progress.blocks === this.props.Dashboard.progress.longestchain) { + syncPercentage && + syncPercentage >= NATIVE_MIN_SYNC_PERCENTAGE_THRESHOLD) { Store.dispatch(getSyncInfoNative(coin, true)); Store.dispatch(getKMDBalanceTotal(coin)); Store.dispatch(getNativeTxHistory(coin)); @@ -61,6 +69,7 @@ class CoinTileItem extends React.Component { } if (mode === 'basilisk') { const useAddress = this.props.ActiveCoin.mainBasiliskAddress ? this.props.ActiveCoin.mainBasiliskAddress : this.props.Dashboard.activeHandle[coin]; + Store.dispatch(iguanaActiveHandle(true)); Store.dispatch(getKMDAddressesNative(coin, mode, useAddress)); Store.dispatch(getShepherdCache(JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey, coin)); @@ -72,8 +81,8 @@ class CoinTileItem extends React.Component { if (!this.props.ActiveCoin.addresses) { Store.dispatch(getAddressesByAccount(coin, mode)); } + Store.dispatch(getBasiliskTransactionsList(coin, useAddress)); - //Store.dispatch(iguanaEdexBalance(coin, mode)); } } } @@ -87,16 +96,15 @@ class CoinTileItem extends React.Component { this.dispatchCoinActions(coin, mode); if (mode === 'full') { - var _iguanaActiveHandle = setInterval(function() { + const _iguanaActiveHandle = setInterval(() => { this.dispatchCoinActions(coin, mode); - }.bind(this), 3000); + }, IGUNA_ACTIVE_HANDLE_TIMEOUT); Store.dispatch(startInterval('sync', _iguanaActiveHandle)); } if (mode === 'native') { - // TODO: add conditions to skip txhistory, balances, addresses while "activating best chain" - var _iguanaActiveHandle = setInterval(function() { + const _iguanaActiveHandle = setInterval(() => { this.dispatchCoinActions(coin, mode); - }.bind(this), coin === 'KMD' ? 15000 : 3000); + }, coin === 'KMD' ? IGUNA_ACTIVE_HANDLE_TIMEOUT_KMD_NATIVE : IGUNA_ACTIVE_HANDLE_TIMEOUT); Store.dispatch(startInterval('sync', _iguanaActiveHandle)); } if (mode === 'basilisk') { @@ -112,11 +120,11 @@ class CoinTileItem extends React.Component { 'address': _basiliskMainAddress, })); - var _iguanaActiveHandle = setInterval(function() { + const _iguanaActiveHandle = setInterval(() => { this.dispatchCoinActions(coin, mode); - }.bind(this), 3000); + }, IGUNA_ACTIVE_HANDLE_TIMEOUT); - var _basiliskCache = setInterval(function() { + const _basiliskCache = setInterval(() => { Store.dispatch(fetchNewCacheData({ 'pubkey': this.props.Dashboard.activeHandle.pubkey, 'allcoins': false, @@ -124,10 +132,9 @@ class CoinTileItem extends React.Component { 'calls': 'listtransactions:getbalance', 'address': _basiliskMainAddress, })); - }.bind(this), 240000); + }, BASILISK_CACHE_UPDATE_TIMEOUT); Store.dispatch(startInterval('sync', _iguanaActiveHandle)); Store.dispatch(startInterval('basilisk', _basiliskCache)); - // basilisk } } } @@ -145,9 +152,9 @@ class CoinTileItem extends React.Component {
{ item.coinname } ({ item.coinlogo.toUpperCase() })
diff --git a/react/src/components/dashboard/sendCoin.js b/react/src/components/dashboard/sendCoin.js index 706b3df..6f1ff91 100644 --- a/react/src/components/dashboard/sendCoin.js +++ b/react/src/components/dashboard/sendCoin.js @@ -291,7 +291,7 @@ class SendCoin extends React.Component { renderAddressList() { return ( -
+
+
diff --git a/react/src/components/dashboard/walletsBalance.js b/react/src/components/dashboard/walletsBalance.js index 5110aff..d0f7435 100755 --- a/react/src/components/dashboard/walletsBalance.js +++ b/react/src/components/dashboard/walletsBalance.js @@ -30,7 +30,7 @@ class WalletsBalance extends React.Component { this.props.ActiveCoin.mode === 'basilisk' && this.props.ActiveCoin.activeAddress && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin] && - this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.props.ActiveCoin.activeAddress]&& + this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.props.ActiveCoin.activeAddress] && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.props.ActiveCoin.activeAddress].getbalance && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.props.ActiveCoin.activeAddress].getbalance.data && this.props.ActiveCoin.cache[this.props.ActiveCoin.coin][this.props.ActiveCoin.activeAddress].getbalance.data.balance) { diff --git a/react/src/components/dashboard/walletsBasiliskConnection.js b/react/src/components/dashboard/walletsBasiliskConnection.js index 195340a..0b904cc 100755 --- a/react/src/components/dashboard/walletsBasiliskConnection.js +++ b/react/src/components/dashboard/walletsBasiliskConnection.js @@ -76,13 +76,13 @@ class WalletsBasiliskConnection extends React.Component {
- { translate('IAPI.CON_STATUS') + '... ' + this.props.Dashboard.connectedNotaries.current + '/' + this.props.Dashboard.connectedNotaries.total + ': ' + this.props.Dashboard.connectedNotaries.currentNodeName} { Math.floor(this.props.Dashboard.connectedNotaries.current * 100 / this.props.Dashboard.connectedNotaries.total) }% + { `${translate('IAPI.CON_STATUS')}... ${this.props.Dashboard.connectedNotaries.current}/${this.props.Dashboard.connectedNotaries.total}:${this.props.Dashboard.connectedNotaries.currentNodeName}` } { Math.floor(this.props.Dashboard.connectedNotaries.current * 100 / this.props.Dashboard.connectedNotaries.total) }%
-                  { this.props.Dashboard.connectedNotaries.failedToConnectNodes ? 'Failed: ' + this.props.Dashboard.connectedNotaries.failedToConnectNodes : null }
+                  { this.props.Dashboard.connectedNotaries.failedToConnectNodes ? `Failed: ${this.props.Dashboard.connectedNotaries.failedToConnectNodes}` : null }
                   
diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index 5556491..362ee8a 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -82,6 +82,7 @@ class WalletsData extends React.Component { } } + // deprecated toggleCacheApi() { const _useCache = !this.state.useCache; @@ -463,6 +464,7 @@ class WalletsData extends React.Component { } }*/ + // deprecated renderUseCacheToggle() { if (this.props.ActiveCoin.mode === 'basilisk') { return ( @@ -548,11 +550,11 @@ class WalletsData extends React.Component { this.props.Dashboard.activeHandle[this.props.ActiveCoin.coin] && this.props.ActiveCoin.mode === 'basilisk') { return ( -
+
-
+
+ style={{ backgroundImage: `url("assets/images/bg/${this.props.activeSection}_transparent_header_bg.png")`, backgroundRepeat: 'no-repeat', backgroundPosition: '0%' }}>

EasyDEX

  1. { translate('INDEX.DASHBOARD') }
  2. diff --git a/react/src/components/dashboard/walletsNative.js b/react/src/components/dashboard/walletsNative.js index 1d9b4a3..d0b79fc 100644 --- a/react/src/components/dashboard/walletsNative.js +++ b/react/src/components/dashboard/walletsNative.js @@ -29,10 +29,10 @@ class WalletsNative extends React.Component { return (
    -
    +
    1. - { this.props.ActiveCoin.coin } + { this.props.ActiveCoin.coin }
    diff --git a/react/src/components/dashboard/walletsNativeSend.js b/react/src/components/dashboard/walletsNativeSend.js index 69884ef..52e3e00 100644 --- a/react/src/components/dashboard/walletsNativeSend.js +++ b/react/src/components/dashboard/walletsNativeSend.js @@ -80,7 +80,7 @@ class WalletsNativeSend extends React.Component { renderAddressList() { return ( -
    +
    - + +
    ); diff --git a/react/src/components/main/main.js b/react/src/components/main/main.js index 9eebbd9..461ae17 100644 --- a/react/src/components/main/main.js +++ b/react/src/components/main/main.js @@ -8,6 +8,8 @@ import { iguanaActiveHandle } from '../../actions/actionCreators'; +const IGUANA_ACTIVE_HANDLE_TIMEOUT = 30000; + class Main extends React.Component { constructor(props) { super(props); @@ -24,7 +26,7 @@ class Main extends React.Component { Store.dispatch(iguanaActiveHandle()); const _iguanaActiveHandle = setInterval(function() { Store.dispatch(iguanaActiveHandle()); - }, 30000); + }, IGUANA_ACTIVE_HANDLE_TIMEOUT); this.setState(Object.assign({}, this.state, { activeHandleInterval: _iguanaActiveHandle, diff --git a/react/src/components/toaster/toaster-item.js b/react/src/components/toaster/toaster-item.js index 94904d7..b422710 100644 --- a/react/src/components/toaster/toaster-item.js +++ b/react/src/components/toaster/toaster-item.js @@ -1,6 +1,6 @@ -import React from "react"; -import {dismissToasterMessage} from "../../actions/actionCreators"; -import Store from "../../store"; +import React from 'react'; +import { dismissToasterMessage } from '../../actions/actionCreators'; +import Store from '../../store'; // each toast will be displayed for 5 seconds const DISPLAY_LENGTH_MILLIS = 5000; @@ -10,7 +10,6 @@ const DISPLAY_LENGTH_MILLIS = 5000; * each messages has a type, title and a content message */ class ToasterItem extends React.Component { - constructor(props) { super(props); this.state = { @@ -60,9 +59,10 @@ class ToasterItem extends React.Component { } return ( -
    -
    { this.state.title }
    { this.state.message }
    diff --git a/react/src/components/toaster/toaster.js b/react/src/components/toaster/toaster.js index d8fdf6d..019ccb3 100644 --- a/react/src/components/toaster/toaster.js +++ b/react/src/components/toaster/toaster.js @@ -1,11 +1,8 @@ -import React from "react"; -import {dismissToasterMessage} from "../../actions/actionCreators"; -import Store from "../../store"; -import ToasterItem from "./toaster-item"; +import React from 'react'; +import { dismissToasterMessage } from '../../actions/actionCreators'; +import Store from '../../store'; +import ToasterItem from './toaster-item'; -/** - * Container component used for creating multiple toasts - */ class Toaster extends React.Component { constructor(props) { super(props); @@ -17,7 +14,7 @@ class Toaster extends React.Component { componentWillReceiveProps(props) { if (props && - props.toasts) { + props.toasts) { this.setState({ toasts: props.toasts, toastId: props.toasts.length @@ -34,24 +31,33 @@ class Toaster extends React.Component { Store.dispatch(dismissToasterMessage(toastId)); } + renderToasts() { + if (this.state.toasts && + this.state.toasts.length) { + return this.state.toasts.map((toast) => { + // sets the toastId for all new toasts + if (!toast.toastId) { + toast.toastId = this.toastId++; + } + + return ( + + ); + }); + } else { + return null; + } + } + // render all current toasts render() { return ( -