14 changed files with 0 additions and 605 deletions
@ -1,168 +0,0 @@ |
|||
import { |
|||
DASHBOARD_CONNECT_NOTARIES, |
|||
DASHBOARD_GET_NOTARIES_LIST |
|||
} from '../storeType'; |
|||
import { translate } from '../../translate/translate'; |
|||
import { triggerToaster } from '../actionCreators'; |
|||
import Config from '../../config'; |
|||
|
|||
function initNotaryNodesConSequence(nodes) { |
|||
return dispatch => { |
|||
Promise.all(nodes.map((node, index) => { |
|||
const payload = { |
|||
userpass: `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, |
|||
agent: 'dex', |
|||
method: 'getinfo', |
|||
symbol: node, |
|||
timeout: 10000, |
|||
}; |
|||
|
|||
return new Promise((resolve, reject) => { |
|||
fetch(`http://127.0.0.1:${(Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort)}/api/dex/getinfo?userpass=${('tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'))}&symbol=${node}`, { |
|||
method: 'GET', |
|||
}) |
|||
.catch(function(error) { |
|||
console.log(error); |
|||
dispatch( |
|||
triggerToaster( |
|||
`getInfoDexNode+${node}`, |
|||
'Error', |
|||
'error' |
|||
) |
|||
); |
|||
}) |
|||
.then(response => response.json()) |
|||
.then(json => { |
|||
dispatch( |
|||
updateNotaryNodeConState( |
|||
json, |
|||
nodes.length, |
|||
index, |
|||
node |
|||
) |
|||
); |
|||
}) |
|||
}); |
|||
})); |
|||
} |
|||
} |
|||
|
|||
function updateNotaryNodeConState(json, totalNodes, currentNodeIndex, currentNodeName) { |
|||
if (currentNodeIndex === totalNodes - 1) { |
|||
return dispatch => { |
|||
dispatch(basiliskConnectionState(false)); |
|||
}; |
|||
} else { |
|||
if (json && |
|||
json.error === 'less than required responses') { |
|||
return { |
|||
type: DASHBOARD_CONNECT_NOTARIES, |
|||
total: totalNodes - 1, |
|||
current: currentNodeIndex, |
|||
name: currentNodeName, |
|||
failedNode: currentNodeName, |
|||
} |
|||
} else { |
|||
return { |
|||
type: DASHBOARD_CONNECT_NOTARIES, |
|||
total: totalNodes - 1, |
|||
current: currentNodeIndex, |
|||
name: currentNodeName, |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
function connectAllNotaryNodes(json, dispatch) { |
|||
if (json && |
|||
json.length) { |
|||
dispatch(initNotaryNodesConSequence(json)); |
|||
|
|||
return { |
|||
type: DASHBOARD_CONNECT_NOTARIES, |
|||
total: json.length - 1, |
|||
current: 0, |
|||
name: json[0], |
|||
} |
|||
} |
|||
} |
|||
|
|||
export function connectNotaries() { |
|||
const payload = { |
|||
userpass: `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, |
|||
agent: 'dpow', |
|||
method: 'notarychains', |
|||
}; |
|||
|
|||
return dispatch => { |
|||
return fetch(`http://127.0.0.1:${Config.iguanaCorePort}`, { |
|||
method: 'POST', |
|||
body: JSON.stringify(payload), |
|||
}) |
|||
.catch(function(error) { |
|||
console.log(error); |
|||
dispatch( |
|||
triggerToaster( |
|||
'connectNotaries', |
|||
'Error', |
|||
'error' |
|||
) |
|||
); |
|||
}) |
|||
.then(response => response.json()) |
|||
.then( |
|||
json => dispatch( |
|||
connectAllNotaryNodes(json, dispatch) |
|||
) |
|||
) |
|||
} |
|||
} |
|||
|
|||
function getDexNotariesState(json) { |
|||
if (json.error === 'less than required responses') { |
|||
return dispatch => { |
|||
dispatch( |
|||
triggerToaster( |
|||
translate('TOASTR.LESS_RESPONSES_REQ'), |
|||
translate('TOASTR.BASILISK_NOTIFICATION'), |
|||
'error' |
|||
) |
|||
); |
|||
} |
|||
} else { |
|||
return { |
|||
type: DASHBOARD_GET_NOTARIES_LIST, |
|||
notaries: json, |
|||
} |
|||
} |
|||
} |
|||
|
|||
export function getDexNotaries(coin) { |
|||
const payload = { |
|||
userpass: `tmpIgRPCUser@${sessionStorage.getItem('IguanaRPCAuth')}`, |
|||
agent: 'dex', |
|||
method: 'getnotaries', |
|||
symbol: coin, |
|||
}; |
|||
|
|||
return dispatch => { |
|||
return fetch(`http://127.0.0.1:${Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort}`, { |
|||
method: 'POST', |
|||
body: JSON.stringify(payload), |
|||
}) |
|||
.catch(function(error) { |
|||
console.log(error); |
|||
dispatch( |
|||
triggerToaster( |
|||
'getDexNotaries', |
|||
'Error', |
|||
'error' |
|||
) |
|||
); |
|||
}) |
|||
.then(response => response.json()) |
|||
.then(json => { |
|||
dispatch(getDexNotariesState(json)); |
|||
}) |
|||
} |
|||
} |
@ -1,46 +0,0 @@ |
|||
import React from 'react'; |
|||
import { connect } from 'react-redux'; |
|||
import { basiliskConnection } from '../../../actions/actionCreators'; |
|||
import Store from '../../../store'; |
|||
import WalletsBasiliskConnectionRender from './walletsBasiliskConnection.render'; |
|||
|
|||
class WalletsBasiliskConnection extends React.Component { |
|||
constructor() { |
|||
super(); |
|||
this.basiliskConnectionAction = this.basiliskConnectionAction.bind(this); |
|||
} |
|||
|
|||
basiliskConnectionAction() { |
|||
Store.dispatch(basiliskConnection(false)); |
|||
} |
|||
|
|||
handleKeydown(e) { |
|||
if (e.key === 'Escape') { |
|||
this.basiliskConnectionAction(); |
|||
} |
|||
} |
|||
|
|||
isBasiliskConnection() { |
|||
return this.props && |
|||
this.props.Dashboard.basiliskConnection; |
|||
} |
|||
|
|||
render() { |
|||
if (this.isBasiliskConnection()) { |
|||
return WalletsBasiliskConnectionRender.call(this); |
|||
} else { |
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
|
|||
const mapStateToProps = (state) => { |
|||
return { |
|||
Dashboard: { |
|||
basiliskConnection: state.Dashboard.basiliskConnection, |
|||
connectedNotaries: state.Dashboard.connectedNotaries, |
|||
} |
|||
}; |
|||
}; |
|||
|
|||
export default connect(mapStateToProps)(WalletsBasiliskConnection); |
@ -1,83 +0,0 @@ |
|||
import React from 'react'; |
|||
import { translate } from '../../../translate/translate'; |
|||
|
|||
const WalletsBasiliskConnectionRender = function() { |
|||
return ( |
|||
<div onKeyDown={ (event) => this.handleKeydown(event) }> |
|||
<div |
|||
className="modal show" |
|||
id="RefreshBasiliskConnectionsMdl"> |
|||
<div className="modal-dialog modal-center modal-md"> |
|||
<div className="modal-content"> |
|||
<div className="modal-header bg-orange-a400 wallet-send-header"> |
|||
<h4 className="modal-title white"> |
|||
<span className="icon fa-refresh no-margin"></span> { translate('INDEX.REFRESHING_BASILISK_NET') }... |
|||
</h4> |
|||
<button |
|||
type="button" |
|||
className="close btn-close" |
|||
onClick={ this.basiliskConnectionAction }> |
|||
<span>×</span> |
|||
<span className="sr-only">{ translate('INDEX.CLOSE') }</span> |
|||
</button> |
|||
</div> |
|||
<div className="modal-body text-align-center"> |
|||
<div className="loader-wrapper active"> |
|||
<div className="loader-layer loader-blue"> |
|||
<div className="loader-circle-left"> |
|||
<div className="circle"></div> |
|||
</div> |
|||
<div className="loader-circle-gap"></div> |
|||
<div className="loader-circle-right"> |
|||
<div className="circle"></div> |
|||
</div> |
|||
</div> |
|||
<div className="loader-layer loader-red"> |
|||
<div className="loader-circle-left"> |
|||
<div className="circle"></div> |
|||
</div> |
|||
<div className="loader-circle-gap"></div> |
|||
<div className="loader-circle-right"> |
|||
<div className="circle"></div> |
|||
</div> |
|||
</div> |
|||
<div className="loader-layer loader-green"> |
|||
<div className="loader-circle-left"> |
|||
<div className="circle"></div> |
|||
</div> |
|||
<div className="loader-circle-gap"></div> |
|||
<div className="loader-circle-right"> |
|||
<div className="circle"></div> |
|||
</div> |
|||
</div> |
|||
<div className="loader-layer loader-yellow"> |
|||
<div className="loader-circle-left"> |
|||
<div className="circle"></div> |
|||
</div> |
|||
<div className="loader-circle-gap"></div> |
|||
<div className="loader-circle-right"> |
|||
<div className="circle"></div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<h5 className="text-left"> |
|||
{ `${translate('IAPI.CON_STATUS')}... ${this.props.Dashboard.connectedNotaries.current} / ${this.props.Dashboard.connectedNotaries.total}:${this.props.Dashboard.connectedNotaries.currentNodeName}` } <span className="pull-right" id="basilisk-connections-refresh-percent">{ Math.floor(this.props.Dashboard.connectedNotaries.current * 100 / this.props.Dashboard.connectedNotaries.total) }%</span> |
|||
</h5> |
|||
<div className="progress progress-sm"> |
|||
<div |
|||
className="progress-bar progress-bar-info progress-bar-striped active font-size-80-percent" |
|||
style={{ width: Math.floor(this.props.Dashboard.connectedNotaries.current * 100 / this.props.Dashboard.connectedNotaries.total) + '%' }}></div> |
|||
</div> |
|||
<pre id="no-padding"> |
|||
{ this.props.Dashboard.connectedNotaries.failedToConnectNodes ? `Failed: ${this.props.Dashboard.connectedNotaries.failedToConnectNodes}` : null } |
|||
</pre> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div className="modal-backdrop show in"></div> |
|||
</div> |
|||
); |
|||
}; |
|||
|
|||
export default WalletsBasiliskConnectionRender; |
@ -1,26 +0,0 @@ |
|||
import React from 'react'; |
|||
import { connect } from 'react-redux'; |
|||
import WalletsBasiliskRefreshRender from './walletsBasiliskRefresh.render'; |
|||
|
|||
class WalletsBasiliskRefresh extends React.Component { |
|||
isBasiliskRefresh() { |
|||
return this.props && |
|||
this.props.Dashboard.basiliskRefresh; |
|||
} |
|||
|
|||
render() { |
|||
if (this.isBasiliskRefresh()) { |
|||
return WalletsBasiliskRefreshRender.call(this); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
const mapStateToProps = (state) => { |
|||
return { |
|||
Dashboard: { |
|||
basiliskRefresh: state.Dashboard.basiliskRefresh, |
|||
} |
|||
}; |
|||
}; |
|||
export default connect(mapStateToProps)(WalletsBasiliskRefresh); |
@ -1,36 +0,0 @@ |
|||
import React from 'react'; |
|||
import { translate } from '../../../translate/translate'; |
|||
|
|||
const WalletsBasiliskRefreshRender = function() { |
|||
return ( |
|||
<div id="edexcoin_dashboard_basilisk_refresh_status"> |
|||
<div className="col-xs-12 margin-top-20"> |
|||
<div className="col-xs-12"> |
|||
<div className="panel"> |
|||
<div className="panel-heading"> |
|||
<h3 className="panel-title">{ translate('INDEX.FETCHING_BASILISK_DATA') }</h3> |
|||
<div className="panel-actions"> |
|||
<a className="panel-action icon md-refresh-alt"></a> |
|||
</div> |
|||
</div> |
|||
<div className="table-responsive"> |
|||
<table className="table table-hover table-striped"> |
|||
<thead> |
|||
<tr> |
|||
<th>{ translate('INDEX.ADDRESS') }</th> |
|||
<th>{ translate('INDEX.LIST_UNSPENT') }</th> |
|||
<th>{ translate('INDEX.LIST_TRANSACTIONS') }</th> |
|||
<th>{ translate('INDEX.GET_BALANCE') }</th> |
|||
<th>{ translate('INDEX.REFRESH') }</th> |
|||
</tr> |
|||
</thead> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
); |
|||
}; |
|||
|
|||
export default WalletsBasiliskRefreshRender; |
@ -1,73 +0,0 @@ |
|||
import React from 'react'; |
|||
import { connect } from 'react-redux'; |
|||
import { translate } from '../../../translate/translate'; |
|||
import { displayNotariesModal } from '../../../actions/actionCreators'; |
|||
import Store from '../../../store'; |
|||
import { TreeNode } from 'rc-tree'; |
|||
import { |
|||
NotariesListRender, |
|||
WalletsNotariesListRender |
|||
} from './walletsNotariesList.render'; |
|||
|
|||
class WalletsNotariesList extends React.Component { |
|||
constructor() { |
|||
super(); |
|||
this.closeNotariesModal = this.closeNotariesModal.bind(this); |
|||
} |
|||
|
|||
closeNotariesModal() { |
|||
Store.dispatch(displayNotariesModal(false)); |
|||
} |
|||
|
|||
handleKeydown(e) { |
|||
if (e.key === 'Escape') { |
|||
this.closeNotariesModal(); |
|||
} |
|||
} |
|||
|
|||
renderNotariesFetching() { |
|||
if (!this.props.ActiveCoin.notaries) { |
|||
return ( |
|||
<div>{ translate('INDEX.FETCHING_NOTARIES_LIST') }...</div> |
|||
); |
|||
} else { |
|||
return ( |
|||
<div>{ translate('INDEX.TOTAL_NOTARIES') }: { this.props.ActiveCoin.notaries.numnotaries }</div> |
|||
); |
|||
} |
|||
} |
|||
|
|||
renderNotariesList() { |
|||
if (this.props.ActiveCoin.notaries && |
|||
this.props.ActiveCoin.notaries.notaries && |
|||
this.props.ActiveCoin.notaries.notaries.length) { |
|||
return this.props.ActiveCoin.notaries.notaries.map( |
|||
(node, index) => NotariesListRender.call(this, node, index) |
|||
); |
|||
} else { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
render() { |
|||
if (this.props && |
|||
this.props.ActiveCoin.mode === 'basilisk' && |
|||
this.props.ActiveCoin.displayNotariesModal) { |
|||
return WalletsNotariesListRender.call(this); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
const mapStateToProps = (state) => { |
|||
return { |
|||
ActiveCoin: { |
|||
mode: state.ActiveCoin.mode, |
|||
displayNotariesModal: state.ActiveCoin.displayNotariesModal, |
|||
notaries: state.ActiveCoin.notaries, |
|||
} |
|||
}; |
|||
|
|||
}; |
|||
|
|||
export default connect(mapStateToProps)(WalletsNotariesList); |
@ -1,60 +0,0 @@ |
|||
import React from 'react'; |
|||
import { translate } from '../../../translate/translate'; |
|||
import Tree, { TreeNode } from 'rc-tree'; |
|||
import { animation } from '../../../util/rc-tree-animate'; |
|||
|
|||
export const NotariesListRender = function(node, index) { |
|||
return ( |
|||
<TreeNode |
|||
title={ `Node ${index}` } |
|||
key={ `node-${index}` }> |
|||
<TreeNode |
|||
key={ `node-${index}-btc` } |
|||
title={ `BTC: ${node.BTCaddress}` } /> |
|||
<TreeNode |
|||
key={ `node-${index}-kmd` } |
|||
title={ `KMD: ${node.KMDaddress}` } /> |
|||
<TreeNode |
|||
key={ `node-${index}-pubkey` } |
|||
title={ `Pubkey: ${node.pubkey}` } /> |
|||
</TreeNode> |
|||
); |
|||
}; |
|||
|
|||
export const WalletsNotariesListRender = function() { |
|||
return ( |
|||
<div onKeyDown={ (event) => this.handleKeydown(event) }> |
|||
<div |
|||
className="modal show" |
|||
id="kmd_txid_info_mdl"> |
|||
<div className="modal-dialog modal-center modal-lg"> |
|||
<div className="modal-content"> |
|||
<div className="modal-body modal-body-container"> |
|||
<div className="panel nav-tabs-horizontal"> |
|||
<div className="panel-body"> |
|||
<div className="tab-content"> |
|||
<div className="tab-pane active"> |
|||
{ this.renderNotariesFetching() } |
|||
<Tree |
|||
defaultExpandAll={ false } |
|||
openAnimation={ animation }> |
|||
{ this.renderNotariesList() } |
|||
</Tree> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div className="modal-footer"> |
|||
<button |
|||
type="button" |
|||
className="btn btn-default" |
|||
onClick={ this.closeNotariesModal }>{ translate('INDEX.CLOSE') }</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div className="modal-backdrop show in"></div> |
|||
</div> |
|||
); |
|||
}; |
Loading…
Reference in new issue