diff --git a/react/package.json b/react/package.json index 7ff5bdc..7eba962 100644 --- a/react/package.json +++ b/react/package.json @@ -33,6 +33,7 @@ "babel-loader": "^6.2.5", "babel-preset-es2015": "^6.14.0", "babel-preset-react": "^6.11.1", + "bluebird": "^3.5.0", "express": "^4.14.0", "file-loader": "^0.10.0", "react": "^15.3.1", diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index b9612e2..be59a17 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -1,4 +1,7 @@ import 'whatwg-fetch'; +import 'bluebird'; + +import Config from '../config'; import { startCurrencyAssetChain, startAssetChain, startCrypto, checkCoinType } from '../components/addcoin/payload'; import { copyToClipboard } from '../util/copyToClipboard'; import { translate } from '../translate/translate'; @@ -17,6 +20,59 @@ export const DASHBOARD_ACTIVE_COIN_RECEIVE_FORM = 'DASHBOARD_ACTIVE_COIN_RECEIVE 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'; + +function basiliskConnectionState(display, json) { + return { + type: BASILISK_CONNECTION, + basiliskConnection: display, + progress: json, + } +} + +function basiliskRefreshState(display, json) { + return { + type: BASILISK_REFRESH, + basiliskRefresh: display, + progress: json, + } +} + +export function basiliskRefresh(display) { + return dispatch => { + dispatch(basiliskRefreshState(display)); + } +} + +export function basiliskConnection(display) { + return dispatch => { + dispatch(basiliskConnectionState(display)); + } +} + +export function syncingNativeModeState(display, json) { + return { + type: SYNCING_FULL_MODE, + syncingNativeMode: display, + progress: json, + } +} + +export function syncingFullModeState(display, json) { + return { + type: SYNCING_NATIVE_MODE, + syncingFullMode: display, + progress: json, + } +} function atomicState(json) { return { @@ -178,11 +234,11 @@ export function copyCoinAddress(address) { if (_result) { return dispatch => { - dispatch(triggerToaster(true, translate('DASHBOARD.ADDR_COPIED'), translate('TOASTR.COIN_NOTIFICATION'), 'success')) + 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')) + dispatch(triggerToaster(true, 'Couldn\'t copy address to clipboard', translate('TOASTR.COIN_NOTIFICATION'), 'error')); } } } @@ -223,13 +279,13 @@ export function addCoin(coin, mode) { export function iguanaAddCoin(coin, mode, acData) { return dispatch => { - return fetch('http://127.0.0.1:7778', { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { method: 'POST', body: JSON.stringify(acData), }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, translate('TOASTR.FAILED_TO_ADDCOIN'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'error')) + dispatch(triggerToaster(true, translate('TOASTR.FAILED_TO_ADDCOIN'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'error')); }) .then(response => response.json()) .then(json => dispatch(addCoinResult(coin, mode, acData))); @@ -272,7 +328,7 @@ export function shepherdHerd(coin, mode, path) { console.log('herdData', herdData); return dispatch => { - return fetch('http://127.0.0.1:17777/shepherd/herd', { + return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/herd', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -284,7 +340,7 @@ export function shepherdHerd(coin, mode, path) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, translate('FAILED_SHEPHERD_HERD'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error')) + dispatch(triggerToaster(true, translate('FAILED_SHEPHERD_HERD'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error')); }) .then(response => response.json()) .then(json => dispatch(iguanaAddCoin(coin, mode, acData))); @@ -307,7 +363,7 @@ export function addCoinResult(coin, mode) { export function shepherdGetConfig(coin, mode) { return dispatch => { - return fetch('http://127.0.0.1:17777/shepherd/getconf', { + return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -316,7 +372,7 @@ export function shepherdGetConfig(coin, mode) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'Failed to get mode config', 'Error', 'error')) + dispatch(triggerToaster(true, 'Failed to get mode config', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(shepherdHerd(coin, mode, json))); @@ -325,7 +381,7 @@ export function shepherdGetConfig(coin, mode) { export function getDexCoins() { return dispatch => { - return fetch('http://127.0.0.1:7778', { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { method: 'POST', //mode: 'no-cors' body: JSON.stringify({ @@ -336,7 +392,7 @@ export function getDexCoins() { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'Error getDexCoins', 'Error', 'error')) + dispatch(triggerToaster(true, 'Error getDexCoins', 'Error', 'error')); }) .then(response => response.json()) @@ -355,7 +411,7 @@ function rpcErrorHandler(json, dispatch) { export function iguanaWalletPassphrase(_passphrase) { return dispatch => { - return fetch('http://127.0.0.1:7778', { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { method: 'POST', body: JSON.stringify({ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), @@ -368,7 +424,7 @@ export function iguanaWalletPassphrase(_passphrase) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'Error iguanaWalletPassphrase', 'Error', 'error')) + dispatch(triggerToaster(true, 'Error iguanaWalletPassphrase', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(iguanaWalletPassphraseState(json, dispatch))); @@ -377,7 +433,7 @@ export function iguanaWalletPassphrase(_passphrase) { export function iguanaActiveHandle(getMainAddress) { return dispatch => { - return fetch('http://127.0.0.1:7778', { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { method: 'POST', body: JSON.stringify({ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), @@ -387,7 +443,7 @@ export function iguanaActiveHandle(getMainAddress) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'Error iguanaActiveHandle', 'Error', 'error')) + dispatch(triggerToaster(true, translate('TOASTR.IGUANA_ARE_YOU_SURE'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error')); }) .then(response => response.json()) .then(json => dispatch(getMainAddress ? getMainAddressState(json) : iguanaActiveHandleState(json))); @@ -396,7 +452,7 @@ export function iguanaActiveHandle(getMainAddress) { export function iguanaEdexBalance(coin) { return dispatch => { - return fetch('http://127.0.0.1:7778', { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { method: 'POST', body: JSON.stringify({ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), @@ -407,7 +463,7 @@ export function iguanaEdexBalance(coin) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'Error iguanaEdexBalance', 'Error', 'error')) + dispatch(triggerToaster(true, 'Error iguanaEdexBalance', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(iguanaEdexBalanceState(json))); @@ -416,13 +472,13 @@ export function iguanaEdexBalance(coin) { export function atomic(payload) { return dispatch => { - return fetch('http://127.0.0.1:7778', { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, payload.method, 'Atomic explore error', 'error')) + dispatch(triggerToaster(true, payload.method, 'Atomic explore error', 'error')); }) .then(response => response.json()) .then(json => dispatch(atomicState(json))); @@ -435,25 +491,24 @@ export function settingsWifkeyState(json, coin) { wifkey: json[coin + 'wif'], address: json[coin], } - console.log('test', json); } export function encryptWallet(_passphrase, cb, coin) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), - 'agent': 'bitcoinrpc', - 'method': 'encryptwallet', - 'passphrase': _passphrase + 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'agent': 'bitcoinrpc', + 'method': 'encryptwallet', + 'passphrase': _passphrase }; return dispatch => { - return fetch('http://127.0.0.1:7778', { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'encryptWallet', 'Error', 'error')) + dispatch(triggerToaster(true, 'encryptWallet', 'Error', 'error')); }) .then(dispatch(walletPassphrase(_passphrase))) .then(response => response.json()) @@ -463,39 +518,339 @@ export function encryptWallet(_passphrase, cb, coin) { export function walletPassphrase(_passphrase) { const payload = { - 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), - 'agent': 'bitcoinrpc', - 'method': 'walletpassphrase', - 'password': _passphrase, - 'timeout': '2592000' + 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'agent': 'bitcoinrpc', + 'method': 'walletpassphrase', + 'password': _passphrase, + 'timeout': '2592000' + }; + + 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, 'walletPassphrase', 'Error', 'error')); + }) + } +} + +export function getPeersListState(json) { + var peersList = {}; + if (json && json.rawpeers && json.rawpeers.length) { + for (var i=0; i < json.rawpeers.length; i++) { + peersList[json.rawpeers[i].coin] = json.rawpeers[i].peers; + } + } + return { + type: GET_PEERS_LIST, + supernetPeers: json && json.supernet[0] ? json.supernet : null, + rawPeers: peersList, + } +} + +export function getPeersList(coin) { + const payload = { + 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'agent': 'SuperNET', + 'method': 'getpeers', + 'activecoin': coin, + }; + + 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, 'getPeersList', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => dispatch(getPeersListState(json, dispatch))) + } +} + +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 => { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + method: 'POST', + body: JSON.stringify(payload), + }) + .catch(function(error) { + console.log(error); + dispatch(triggerToaster(true, 'addPeerNode', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => dispatch(addPeerNodeState(json, dispatch))) + } +} + +export function getAddressesByAccountState(json, coin) { + test(['123', '456']); + return { + type: ACTIVE_COIN_GET_ADDRESSES, + addresses: json.result, + } +} + +export function getAddressesByAccount(coin) { + const payload = { + 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'coin': coin, + 'agent': 'bitcoinrpc', + 'method': 'getaddressesbyaccount', + 'account': '*' + }; + + 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, 'getAddressesByAccount', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => dispatch(getAddressesByAccountState(json, dispatch))) + } +} + +function getDexNotariesState(json, dispatch) { + return dispatch => { + dispatch(triggerToaster(true, 'Notaries list received', translate('TOASTR.BASILISK_NOTIFICATION'), 'success')); + } +} + +export function getDexNotaries(coin) { + const payload = { + 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'agent': 'dex', + 'method': 'getnotaries', + 'symbol': coin }; return dispatch => { - return fetch('http://127.0.0.1:7778', { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { method: 'POST', body: JSON.stringify(payload), }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'walletPassphrase', 'Error', 'error')) + dispatch(triggerToaster(true, 'getDexNotaries', 'Error', 'error')); }) + .then(response => response.json()) + .then(json => dispatch(getDexNotariesState(json, dispatch))) + } +} + +export function startInterval(name, handle) { + return { + type: START_INTERVAL, + name, + handle, } } -/*function Shepherd_SysInfo() { - return new Promise((resolve) => { - $.ajax({ - type: 'GET', - url: 'http://127.0.0.1:17777/shepherd/sysinfo', - contentType: 'application/json' // send as JSON +export function stopInterval(name, intervals) { + clearInterval(intervals[name]); + + return { + type: STOP_INTERVAL, + name, + } +} + +function getSyncInfoState(json) { + return { + type: SYNCING_FULL_MODE, + progress: json, + } +} + +export function getSyncInfo(coin) { + const payload = { + 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'coin': coin, + 'agent': 'bitcoinrpc', + 'method': 'getinfo', + 'immediate': 100, + 'timeout': 4000 + }; + + return dispatch => { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + method: 'POST', + body: JSON.stringify(payload), }) - .done(function(data) { - resolve(data); + .catch(function(error) { + console.log(error); + dispatch(triggerToaster(true, 'getSyncInfo', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => dispatch(getSyncInfoState(json, dispatch))) + } +} + +function getDebugLogState(json) { + const _data = json.result.replace('\n', '\r\n'); + + return { + type: 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))) + } +} + +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 => { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + method: 'POST', + body: JSON.stringify(payload), + }) + .catch(function(error) { + console.log(error); + dispatch(triggerToaster(true, 'importPrivKey', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => dispatch(parseImportPrivKeyResponse(json, dispatch))) + .catch(function(ex) { + dispatch(parseImportPrivKeyResponse({ 'error': 'privkey already in wallet' }, dispatch)); + console.log('parsing failed', ex); + }) + } +} + +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 => dispatch(shepherdHerd(coin, mode, json))); + } +} + +/*export function test(coin, addr) { + Promise.all(addr.map((_addr, index) => { + const payload = { + 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'agent': 'dex', + 'method': 'listunspent', + 'address': _addr, + 'symbol': coin + } + console.log('addr', _addr); + return new Promise((resolve, reject) => { + fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + method: 'POST', + body: JSON.stringify(payload), + }) + .catch(function(error) { + console.log(error); + dispatch(triggerToaster(true, 'getSyncInfo', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => dispatch(getSyncInfoState(json, dispatch))) + resolve(index); }); + })) + .then(result => { + console.log(result); }); } -function Shepherd_SendPendValue() { +/*function Shepherd_SendPendValue() { Shepherd_SysInfo().then(function(result){ var ram_data = formatBytes(result.totalmem_bytes) var pend_val = null; diff --git a/react/src/components/app/app.js b/react/src/components/app/app.js index b03538f..9c5c998 100644 --- a/react/src/components/app/app.js +++ b/react/src/components/app/app.js @@ -12,6 +12,7 @@ function mapStateToProps(state) { ActiveCoin: state.ActiveCoin, Atomic: state.Atomic, Settings: state.Settings, + Interval: state.Interval, }; } diff --git a/react/src/components/dashboard/coinTileItem.js b/react/src/components/dashboard/coinTileItem.js index a095a71..da9ed9e 100644 --- a/react/src/components/dashboard/coinTileItem.js +++ b/react/src/components/dashboard/coinTileItem.js @@ -1,6 +1,14 @@ import React from 'react'; import { translate } from '../../translate/translate'; -import { dashboardChangeActiveCoin, iguanaActiveHandle } from '../../actions/actionCreators'; +import { + dashboardChangeActiveCoin, + iguanaActiveHandle, + getAddressesByAccount, + getSyncInfo, + startInterval, + stopInterval, + iguanaEdexBalance +} from '../../actions/actionCreators'; import Store from '../../store'; class CoinTileItem extends React.Component { @@ -11,13 +19,29 @@ class CoinTileItem extends React.Component { } dashboardChangeActiveCoin(coin, mode) { + if (mode === 'full' && coin !== this.props.ActiveCoin.coin) { + Store.dispatch(stopInterval('sync', this.props.Interval.interval)); + var _iguanaActiveHandle = setInterval(function() { + Store.dispatch(getSyncInfo(coin)); + }, 3000); + Store.dispatch(startInterval('sync', _iguanaActiveHandle)); + } else { + Store.dispatch(stopInterval('sync', this.props.Interval.interval)); + } + Store.dispatch(dashboardChangeActiveCoin(coin, mode)); Store.dispatch(iguanaActiveHandle(true)); + Store.dispatch(getAddressesByAccount(coin)); + Store.dispatch(iguanaEdexBalance(coin)); + + /*this.setState(Object.assign({}, this.state, { + activeHandleInterval: _iguanaActiveHandle, + }));*/ } render() { const { item } = this.props; - + return (
diff --git a/react/src/components/dashboard/dashboard.js b/react/src/components/dashboard/dashboard.js index 90782db..a129cb7 100644 --- a/react/src/components/dashboard/dashboard.js +++ b/react/src/components/dashboard/dashboard.js @@ -13,6 +13,9 @@ import Jumblr from './jumblr'; import Settings from './settings'; import ReceiveCoin from './receiveCoin'; import About from './about'; +import WalletsBasiliskRefresh from './walletsBasiliskRefresh'; +import WalletsBasiliskConnection from './walletsBasiliskConnection'; +import WalletsNative from './walletsNative'; class Dashboard extends React.Component { constructor(props) { @@ -36,7 +39,10 @@ class Dashboard extends React.Component { - + + + +
diff --git a/react/src/components/dashboard/receiveCoin.js b/react/src/components/dashboard/receiveCoin.js index 973a9f1..efc79ee 100644 --- a/react/src/components/dashboard/receiveCoin.js +++ b/react/src/components/dashboard/receiveCoin.js @@ -2,549 +2,66 @@ import React from 'react'; import { translate } from '../../translate/translate'; class ReceiveCoin extends React.Component { + renderAddressList() { + if (this.props.addresses && this.props.addresses.length) { + return this.props.addresses.map((address) => + + + + {translate('IAPI.PUBLIC_SM')} + + + {address} + + + + ); + } else { + return null; + } + } + render() { - console.log('receiveprops', this.props); if (this.props && this.props.receive) { return ( -
-
- - - - -
-
-
-
- - | - / - | : - -
-
-
-
- -
-
-
-
-
-
-
-
- {translate('INDEX.TRANSPARENT_BALANCE')} -
- - -
-
-
-
-
- -
-
-
-
-
-
- {translate('INDEX.Z_BALANCE')} -
- - -
-
-
-
-
- -
-
-
-
-
-
- {translate('INDEX.INTEREST_EARNED')} -
- - -
-
-
-
-
- -
-
-
-
-
-
- {translate('INDEX.ZT_BALANCE')} -
- - -
-
-
-
-
-
- -
-
-
-
-
-
-
-

{translate('INDEX.TRANSACTION_HISTORY')}

-
-
- - - - - - - - - - - - - - - - - - - - - - - -
{translate('INDEX.TYPE')}{translate('INDEX.DIRECTION')}{translate('INDEX.CONFIRMATIONS')}{translate('INDEX.AMOUNT')}{translate('INDEX.TIME')}{translate('INDEX.DEST_ADDRESS')}{translate('INDEX.TX_DETAIL')}
{translate('INDEX.TYPE')}{translate('INDEX.DIRECTION')}{translate('INDEX.CONFIRMATIONS')}{translate('INDEX.AMOUNT')}{translate('INDEX.TIME')}{translate('INDEX.DEST_ADDRESS')}{translate('INDEX.TX_DETAIL')}
-
-
+
+
+
+
+
+
+
+
-
-
-
-
- -
-
-
-
-
-
-
- -

{translate('INDEX.RECEIVING_ADDRESS')}

-
-
- - - - - - - - - - - - - -
{translate('INDEX.TYPE')}{translate('INDEX.ADDRESS')}
{translate('INDEX.TYPE')}{translate('INDEX.ADDRESS')}
-
-
-
-
-
-
-
- -
-
-
-
-

- {translate('INDEX.SEND')} -

-
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - {translate('INDEX.TOTAL')} ( - txfee): 0.000 - -
-
- -
-
-
-
-
-
- -
-
-
-
-
-
-
-
- -
-

{translate('INDEX.OPERATIONS_STATUSES')}

-
-
- - - - - - - - - - - - - - - - - -
{translate('INDEX.STATUS')}ID{translate('INDEX.TIME')}{translate('INDEX.RESULT')}
{translate('INDEX.STATUS')}ID{translate('INDEX.TIME')}{translate('INDEX.RESULT')}
-
-
-
-
-
-
-
-
- -
-
-
-
-

{translate('INDEX.WALLET_INFO')}

-
-
- +

{translate('INDEX.RECEIVING_ADDRESS')}

+ +
+
+ + + + + + + + - - - - - - - - - - - - - - - - - - - - + {this.renderAddressList()} -
{translate('INDEX.TYPE')}{translate('INDEX.ADDRESS')}{translate('INDEX.BALANCE')}{translate('INDEX.INTEREST')}
{translate('INDEX.WALLET_VERSION')} - -
{translate('INDEX.BALANCE')} - -
{translate('INDEX.UNCONFIRMED_BALANCE')} - -
{translate('INDEX.IMMATURE_BALANCE')} - -
{translate('INDEX.TOTAL_TX_COUNT')} - -
-
-
-
- -
-
-
-

- Komodo {translate('INDEX.INFO')} -

-
-
- - - - - - + - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
{translate('INDEX.VERSION')} - -
{translate('INDEX.PROTOCOL_VERSION')} - - {translate('INDEX.TYPE')}{translate('INDEX.ADDRESS')}{translate('INDEX.BALANCE')}{translate('INDEX.INTEREST')}
{translate('INDEX.NOTARIZED')} - -
- {translate('INDEX.NOTARIZED')} Hash - - -
- {translate('INDEX.NOTARIZED')} BTC - - -
{translate('INDEX.BLOCKS')} - -
{translate('INDEX.CONNECTIONS')} - -
{translate('INDEX.DIFFICULTY')} - -
Testnet - -
{translate('INDEX.PAY_TX_FEE')} - -
{translate('INDEX.RELAY_FEE')} - -
{translate('INDEX.ERRORS')} - -
- -
); diff --git a/react/src/components/dashboard/settings.js b/react/src/components/dashboard/settings.js index e5aa5ae..20c9bf7 100644 --- a/react/src/components/dashboard/settings.js +++ b/react/src/components/dashboard/settings.js @@ -1,19 +1,42 @@ import React from 'react'; import { translate } from '../../translate/translate'; -import { iguanaActiveHandle, encryptWallet, settingsWifkeyState } from '../../actions/actionCreators'; +import { + iguanaActiveHandle, + encryptWallet, + settingsWifkeyState, + importPrivKey, + getDebugLog, + getPeersList, + addPeerNode +} from '../../actions/actionCreators'; import Store from '../../store'; import AddCoinOptionsCrypto from '../addcoin/addcoinOptionsCrypto'; import AddCoinOptionsAC from '../addcoin/addcoinOptionsAC'; import AddCoinOptionsACFiat from '../addcoin/addcoinOptionsACFiat'; +/* + TODO: + 1) pre-select active coin in add node tab + 2) add agama config section + 3) add fiat section + 4) kickstart section +*/ class Settings extends React.Component { constructor(props) { super(props); this.state = { activeTab: 0, + debugLinesCount: 10, + debugTarget: 'iguana', }; this.exportWifKeys = this.exportWifKeys.bind(this); - this.updatePassphraseInput = this.updatePassphraseInput.bind(this); + this.updateInput = this.updateInput.bind(this); + this.importWifKey = this.importWifKey.bind(this); + this.readDebugLog = this.readDebugLog.bind(this); + this.checkNodes = this.checkNodes.bind(this); + this.addNode = this.addNode.bind(this); + this.renderPeersList = this.renderPeersList.bind(this); + this.renderSNPeersList = this.renderSNPeersList.bind(this); } componentDidMount() { @@ -30,7 +53,59 @@ class Settings extends React.Component { Store.dispatch(encryptWallet(this.state.wifkeysPassphrase, settingsWifkeyState, this.props.ActiveCoin.coin)); } - updatePassphraseInput(e) { + importWifKey() { + Store.dispatch(importPrivKey(this.state.importWifKey)); + } + + readDebugLog() { + Store.dispatch(getDebugLog(this.state.debugTarget, this.state.debugLinesCount)); + } + + checkNodes() { + if (this.state.getPeersCoin) { + Store.dispatch(getPeersList(this.state.getPeersCoin.split('|')[0])); + } + } + + addNode() { + if (this.state.addNodeCoin) { + Store.dispatch(addPeerNode(this.state.addNodeCoin.split('|')[0], this.state.addPeerIP)); + } + } + + renderPeersList() { + if (this.state.getPeersCoin) { + const coin = this.state.getPeersCoin.split('|')[0]; + + if (this.props.Settings.rawPeers && + this.state.getPeersCoin && + this.props.Settings.rawPeers[coin]) { + return this.props.Settings.rawPeers[coin].map((ip) =>
{ip}
); + } else { + return null; + } + } else { + return null; + } + } + + renderSNPeersList() { + if (this.state.getPeersCoin) { + const coin = this.state.getPeersCoin.split('|')[0]; + + if (this.props.Settings.supernetPeers && + this.state.getPeersCoin && + this.props.Settings.supernetPeers[coin]) { + return this.props.Settings.supernetPeers[coin].map((ip) =>
{ip}
); + } else { + return null; + } + } else { + return null; + } + } + + updateInput(e) { this.setState({ [e.target.name]: e.target.value, }); @@ -119,7 +194,7 @@ class Settings extends React.Component {
- @@ -128,17 +203,17 @@ class Settings extends React.Component {
- +
SuperNET Peers:
-

+

{this.renderSNPeersList()}

Raw Peers:
-

+

{this.renderPeersList()}

@@ -148,7 +223,7 @@ class Settings extends React.Component {
- @@ -156,11 +231,11 @@ class Settings extends React.Component {
- +
- +
@@ -207,7 +282,7 @@ class Settings extends React.Component {
- +
@@ -217,7 +292,7 @@ class Settings extends React.Component {
- +
{this.props.ActiveCoin.coin} @@ -256,11 +331,11 @@ class Settings extends React.Component {
- +
- +
@@ -284,26 +359,26 @@ class Settings extends React.Component {
- +
-
- +
-
+

- +
{this.props.Settings.debugLog}
-
+
diff --git a/react/src/components/dashboard/walletsBasiliskConnection.js b/react/src/components/dashboard/walletsBasiliskConnection.js new file mode 100644 index 0000000..823bada --- /dev/null +++ b/react/src/components/dashboard/walletsBasiliskConnection.js @@ -0,0 +1,76 @@ +import React from 'react'; +import { translate } from '../../translate/translate'; + +class WalletsBasiliskConnection extends React.Component { + render() { + if (this.props && this.props.Dashboard.basiliskConnection) { + return ( +
+ +
+
+ ); + } else { + return null; + } + } +} + +export default WalletsBasiliskConnection; diff --git a/react/src/components/dashboard/walletsBasiliskRefresh.js b/react/src/components/dashboard/walletsBasiliskRefresh.js index ce08814..8448ab4 100644 --- a/react/src/components/dashboard/walletsBasiliskRefresh.js +++ b/react/src/components/dashboard/walletsBasiliskRefresh.js @@ -3,36 +3,40 @@ import { translate } from '../../translate/translate'; class WalletsBasiliskRefresh extends React.Component { render() { - return ( -
-
-
-
-
-

{translate('INDEX.FETCHING_BASILISK_DATA')}

-
- + if (this.props && this.props.Dashboard.basiliskRefresh) { + return ( +
+
+
+
+
+

{translate('INDEX.FETCHING_BASILISK_DATA')}

+
+ +
+
+
+ + + + + + + + + + + +
{translate('INDEX.ADDRESS')}{translate('INDEX.LIST_UNSPENT')}{translate('INDEX.LIST_TRANSACTIONS')}{translate('INDEX.GET_BALANCE')}{translate('INDEX.REFRESH')}
-
-
- - - - - - - - - - - -
{translate('INDEX.ADDRESS')}{translate('INDEX.LIST_UNSPENT')}{translate('INDEX.LIST_TRANSACTIONS')}{translate('INDEX.GET_BALANCE')}{translate('INDEX.REFRESH')}
-
- ); + ); + } else { + return null; + } } } diff --git a/react/src/components/dashboard/walletsData.js b/react/src/components/dashboard/walletsData.js index 7fe62fd..b6539c2 100644 --- a/react/src/components/dashboard/walletsData.js +++ b/react/src/components/dashboard/walletsData.js @@ -1,7 +1,7 @@ import React from 'react'; import { translate } from '../../translate/translate'; -/*import { } from '../../actions/actionCreators'; -import Store from '../../store';*/ +import { basiliskRefresh, basiliskConnection, getDexNotaries } from '../../actions/actionCreators'; +import Store from '../../store'; class WalletsData extends React.Component { constructor(props) { @@ -10,6 +10,9 @@ class WalletsData extends React.Component { basiliskActionsMenu: false, }; this.toggleBasiliskActionsMenu = this.toggleBasiliskActionsMenu.bind(this); + this.basiliskRefreshAction = this.basiliskRefreshAction.bind(this); + this.basiliskConnectionAction = this.basiliskConnectionAction.bind(this); + this.getDexNotariesAction = this.getDexNotariesAction.bind(this); } toggleBasiliskActionsMenu() { @@ -18,8 +21,24 @@ class WalletsData extends React.Component { })); } + basiliskRefreshAction() { + if (this.props.Dashboard) { + Store.dispatch(basiliskRefresh(!this.props.Dashboard.basiliskRefresh)); + } + } + + basiliskConnectionAction() { + if (this.props.Dashboard) { + Store.dispatch(basiliskConnection(!this.props.Dashboard.basiliskConnection)); + } + } + + getDexNotariesAction() { + Store.dispatch(getDexNotaries(this.props.ActiveCoin.coin)); + } + render() { - if (this.props && this.props.coin) { + if (this.props && this.props.ActiveCoin && this.props.ActiveCoin.coin) { return (
@@ -28,7 +47,7 @@ class WalletsData extends React.Component {
-
+
@@ -40,22 +59,22 @@ class WalletsData extends React.Component {
  • - + {translate('INDEX.GET_NOTARY_NODES_LIST')}
  • - + {translate('INDEX.REFRESH_BASILISK_CONNECTIONS')}
  • - + {translate('INDEX.FETCH_WALLET_DATA')}
  • - + {translate('INDEX.REFETCH_WALLET_DATA')}
  • diff --git a/react/src/components/dashboard/walletsNative.js b/react/src/components/dashboard/walletsNative.js new file mode 100644 index 0000000..4ead324 --- /dev/null +++ b/react/src/components/dashboard/walletsNative.js @@ -0,0 +1,556 @@ +import React from 'react'; +import { translate } from '../../translate/translate'; + +class WalletsNative extends React.Component { + render() { + if (this.props && this.props.ActiveCoin && this.props.ActiveCoin.mode === 'native') { + return ( +
    +
    + + + + +
    +
    +
    +
    + - | - / - | {translate('INDEX.CONNECTIONS')}: - +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + {translate('INDEX.TRANSPARENT_BALANCE')} +
    + - +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + {translate('INDEX.Z_BALANCE')} +
    + - +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + {translate('INDEX.INTEREST_EARNED')} +
    + - +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + {translate('INDEX.ZT_BALANCE')} +
    + - +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +

    {translate('INDEX.TRANSACTION_HISTORY')}

    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    {translate('INDEX.TYPE')}{translate('INDEX.DIRECTION')}{translate('INDEX.CONFIRMATIONS')}{translate('INDEX.AMOUNT')}{translate('INDEX.TIME')}{translate('INDEX.DEST_ADDRESS')}{translate('INDEX.TX_DETAIL')}
    {translate('INDEX.TYPE')}{translate('INDEX.DIRECTION')}{translate('INDEX.CONFIRMATIONS')}{translate('INDEX.AMOUNT')}{translate('INDEX.TIME')}{translate('INDEX.DEST_ADDRESS')}{translate('INDEX.TX_DETAIL')}
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    + +

    {translate('INDEX.RECEIVING_ADDRESS')}

    +
    +
    + + + + + + + + + + + + + +
    {translate('INDEX.TYPE')}{translate('INDEX.ADDRESS')}
    {translate('INDEX.TYPE')}{translate('INDEX.ADDRESS')}
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +

    + {translate('INDEX.SEND')} +

    +
    +
    +
    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + {translate('INDEX.TOTAL')} ( - txfee): 0.000 + +
    +
    + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +

    {translate('INDEX.OPERATIONS_STATUSES')}

    +
    +
    + + + + + + + + + + + + + + + + + +
    {translate('INDEX.STATUS')}ID{translate('INDEX.TIME')}{translate('INDEX.RESULT')}
    {translate('INDEX.STATUS')}ID{translate('INDEX.TIME')}{translate('INDEX.RESULT')}
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +

    {translate('INDEX.WALLET_INFO')}

    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    {translate('INDEX.WALLET_VERSION')} + +
    {translate('INDEX.BALANCE')} + +
    {translate('INDEX.UNCONFIRMED_BALANCE')} + +
    {translate('INDEX.IMMATURE_BALANCE')} + +
    {translate('INDEX.TOTAL_TX_COUNT')} + +
    +
    +
    +
    + +
    +
    +
    +

    + Komodo {translate('INDEX.INFO')} +

    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {translate('INDEX.VERSION')} + +
    {translate('INDEX.PROTOCOL_VERSION')} + +
    {translate('INDEX.NOTARIZED')} + +
    + {translate('INDEX.NOTARIZED')} Hash + + +
    + {translate('INDEX.NOTARIZED')} BTC + + +
    {translate('INDEX.BLOCKS')} + +
    {translate('INDEX.CONNECTIONS')} + +
    {translate('INDEX.DIFFICULTY')} + +
    Testnet + +
    {translate('INDEX.PAY_TX_FEE')} + +
    {translate('INDEX.RELAY_FEE')} + +
    {translate('INDEX.ERRORS')} + +
    +
    +
    +
    +
    +
    + + +
    +
    + ); + } else { + return null; + } + } +} + +export default WalletsNative; diff --git a/react/src/components/dashboard/walletsProgress.js b/react/src/components/dashboard/walletsProgress.js index 5779c9f..477ae97 100644 --- a/react/src/components/dashboard/walletsProgress.js +++ b/react/src/components/dashboard/walletsProgress.js @@ -3,37 +3,41 @@ import { translate } from '../../translate/translate'; class WalletsProgress extends React.Component { render() { - if (this.props && this.props.ActiveCoin && this.props.ActiveCoin.mode === 'full') { - return ( -