Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
Merged

V0.24 #184

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion react/src/actions/actions/addCoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export function shepherdHerd(coin, mode, path, startupParams) {
console.warn(acData);
dispatch(
triggerToaster(
`Error starting ${coin} daemon. Port ${acData.rpc} is already taken!`, // translate
translate('TOASTR.ERROR_STARTING_DAEMON', coin) + ' ' + translate('TOASTR.PORT_IS_TAKEN', acData.rpc),
translate('TOASTR.SERVICE_NOTIFICATION'),
'error',
false
Expand Down
57 changes: 55 additions & 2 deletions react/src/actions/actions/coinList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
import { triggerToaster } from '../actionCreators';
import Config from '../../config';

export function shepherdElectrumLock() {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/lock`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: '',
})
.catch((error) => {
console.log(error);
dispatch(
triggerToaster(
'shepherdElectrumLock',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => resolve(json))
});
}

export function shepherdElectrumLogout() {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/electrum/logout`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: '',
})
.catch((error) => {
console.log(error);
dispatch(
triggerToaster(
'shepherdElectrumLogout',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => resolve(json))
});
}

export function shepherdStopCoind(coin) {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/coind/stop`, {
Expand All @@ -25,14 +73,19 @@ export function shepherdStopCoind(coin) {
});
}

export function shepherdRemoveCoin(coin) {
export function shepherdRemoveCoin(coin, mode) {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/coins/remove`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: coin === 'KMD' ? '' : JSON.stringify({ chain: coin }),
body: JSON.stringify(coin === 'KMD' && mode === 'native' ? {
mode,
} : {
mode,
chain: coin,
}),
})
.catch((error) => {
console.log(error);
Expand Down
2 changes: 1 addition & 1 deletion react/src/components/addcoin/addcoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class AddCoin extends React.Component {
addCoinProps.display !== this.state.display) {
this.setState(Object.assign({}, this.state, {
display: addCoinProps.display,
modalClassName: addCoinProps.display ? 'show fade' : 'show fade',
modalClassName: 'show fade',
}));

setTimeout(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class ClaimInterestModal extends React.Component {
}

componentWillMount() {
this.loadListUnspent();
if (this.props.ActiveCoin.mode === 'native') {
this.loadListUnspent();
}
}

loadListUnspent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const _ClaimInterestTableRender = function() {
className="btn btn-default btn-xs clipboard-edexaddr copy-string-btn"
title={ translate('INDEX.COPY_TO_CLIPBOARD') }
onClick={ () => this.copyTxId(_transactionsList[i].txid) }>
<i className="icon wb-copy"></i> { translate('INDEX.COPY') }
<i className="icon wb-copy"></i> { translate('INDEX.COPY') + ' TXID' }
</button>
</td>
<td>{ _transactionsList[i].address }</td>
Expand Down
32 changes: 26 additions & 6 deletions react/src/components/dashboard/coinTile/coinTileItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Config from '../../../config';

import CoinTileItemRender from './coinTileItem.render';

const SPV_DASHBOARD_UPDATE_TIMEOUT = 60000;
const SPV_DASHBOARD_UPDATE_TIMEOUT = 10000;
const ACTIVE_HANDLE_TIMEOUT_COIND_NATIVE = 15000;
const COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD = window.require('electron').remote.getCurrentWindow().appConfig.failedRPCAttemptsThreshold || 10;

Expand All @@ -43,6 +43,28 @@ class CoinTileItem extends React.Component {
this.autoSetActiveCoin = this.autoSetActiveCoin.bind(this);
}

renderStopCoinButton() {
if (this.props.Main &&
this.props.Main.coins &&
this.props.Main.coins.native &&
this.props.Main.coins.native.length) {
return true;
}
}

renderRemoveCoinButton() {
if (this.props.Main &&
this.props.Main.coins &&
((this.props.Main.coins.native &&
this.props.Main.coins.native.length &&
this.state.appConfig &&
!this.state.appConfig.stopNativeDaemonsOnQuit) ||
(this.props.Main.coins.spv &&
this.props.Main.coins.spv.length))) {
return true;
}
}

autoSetActiveCoin() {
const modes = [
'native',
Expand Down Expand Up @@ -97,8 +119,8 @@ class CoinTileItem extends React.Component {
});
}

removeCoin(coin) {
shepherdRemoveCoin(coin)
removeCoin(coin, mode) {
shepherdRemoveCoin(coin, mode)
.then((res) => {
Store.dispatch(
triggerToaster(
Expand Down Expand Up @@ -189,9 +211,7 @@ class CoinTileItem extends React.Component {
)
);
}
}

if (mode === 'spv') {
} else if (mode === 'spv') {
Store.dispatch(shepherdElectrumBalance(coin, this.props.Dashboard.electrumCoins[coin].pub));
Store.dispatch(shepherdElectrumTransactions(coin, this.props.Dashboard.electrumCoins[coin].pub));
}
Expand Down
22 changes: 5 additions & 17 deletions react/src/components/dashboard/coinTile/coinTileItem.render.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,17 @@ const CoinTileItemRender = function() {
</div>
</div>
</div>
{ item.mode === 'native' &&
this.props.Main &&
this.props.Main.coins &&
this.props.Main.coins.native &&
this.props.Main.coins.native.length &&
this.props.Main.coins.native.length > 1 &&
{ this.renderStopCoinButton() &&
<i
onClick={ () => this.stopCoind(item.coin) }
onClick={ () => this.stopCoind(item.coin, item.mode) }
title="Stop"
className="icon fa-stop-circle coind-stop-icon"></i>
}
{ item.mode === 'native' &&
this.props.Main &&
this.props.Main.coins &&
this.props.Main.coins.native &&
this.props.Main.coins.native.length &&
this.props.Main.coins.native.length > 1 &&
this.state.appConfig &&
!this.state.appConfig.stopNativeDaemonsOnQuit &&
{ this.renderRemoveCoinButton() &&
<i
onClick={ () => this.removeCoin(item.coin) }
onClick={ () => this.removeCoin(item.coin, item.mode) }
title="Remove"
className="icon fa-plus-circle coind-remove-icon"></i>
className={ 'icon fa-plus-circle ' + (item.mode === 'spv' ? 'coind-remove-icon coind-remove-icon-spv' : 'coind-remove-icon') }></i>
}
{ this.props.Dashboard &&
this.props.Dashboard.electrumCoins &&
Expand Down
19 changes: 16 additions & 3 deletions react/src/components/dashboard/importKeyModal/importKeyModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ class ImportKeyModal extends React.Component {

this.setState({
trimPassphraseTimer: _trimPassphraseTimer,
[e.target.name]: newValue,
[e.target.name === 'wifkeysPassphraseTextarea' ? 'wifkeysPassphrase' : e.target.name]: newValue,
});
} else {
this.setState({
[e.target.name]: e.target.value,
[e.target.name === 'wifkeysPassphraseTextarea' ? 'wifkeysPassphrase' : e.target.name]: e.target.value,
});
}
}
Expand Down Expand Up @@ -174,7 +174,7 @@ class ImportKeyModal extends React.Component {
rescan ? translate('INDEX.WALLET_RESCAN_FINISHED') : translate('INDEX.ADDRESS_IMPORTED'),
translate('TOASTR.WALLET_NOTIFICATION'),
'success',
false
rescan ? false : true,
)
);
} else {
Expand All @@ -187,6 +187,19 @@ class ImportKeyModal extends React.Component {
);
}
});

this.state({
passphraseWif: null,
passphraseAddress: null,
wifkeysPassphrase: null,
wifkeysPassphraseTextarea: null,
importWithRescan: this.state.importWithRescan ? false : this.state.importWithRescan,
});

// reset input vals
this.refs.wif
this.refs.wifkeysPassphrase.value = '';
this.refs.wifkeysPassphraseTextarea.value = '';
}

generateKeysFromPassphrase() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,25 @@ export const ImportKeyModalRender = function() {
<strong>{ translate('IMPORT_KEY.NOTICE') }:</strong> { translate('IMPORT_KEY.NOTICE_DESC') }.&nbsp;
<span className={ this.props.ActiveCoin.coin === 'KMD' ? '' : 'hide' }>{ translate('IMPORT_KEY.KMD_RESCAN_WARNING_TIME') }.</span>
</p>
<form
<div
className="wifkeys-form"
method="post"
action="javascript:"
autoComplete="off">
<div className="form-group form-material floating">
<input
autoComplete="off"
type="password"
className={ !this.state.seedInputVisibility ? 'form-control' : 'hide' }
name="wifkeysPassphrase"
id="wifkeysPassphrase"
ref="wifkeysPassphrase"
onChange={ this.updateInput }
value={ this.state.wifkeysPassphrase } />
<textarea
autoComplete="off"
className={ this.state.seedInputVisibility ? 'form-control' : 'hide' }
id="wifkeysPassphraseTextarea"
name="wifkeysPassphrase"
name="wifkeysPassphraseTextarea"
ref="wifkeysPassphraseTextarea"
onChange={ this.updateInput }
value={ this.state.wifkeysPassphrase }></textarea>
<i
Expand All @@ -62,7 +64,7 @@ export const ImportKeyModalRender = function() {
className="btn btn-primary waves-effect waves-light"
onClick={ this.showPassphraseAddress }>{ translate('IMPORT_KEY.SHOW_ADDRESS_AND_WIF') }</button>
</div>
</form>
</div>
{ this.state.passphraseAddress &&
this.state.passphraseWif &&
<div className="margin-top-60">
Expand Down Expand Up @@ -118,6 +120,7 @@ export const ImportKeyModalRender = function() {
type="text"
className="form-control"
name="wif"
ref="wif"
onChange={ this.updateInput }
value={ this.state.wif } />
</div>
Expand Down
25 changes: 25 additions & 0 deletions react/src/components/dashboard/navbar/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {
stopInterval,
startInterval,
displayImportKeyModal,
shepherdElectrumLock,
shepherdElectrumLogout,
getDexCoins,
activeHandle,
} from '../../../actions/actionCreators';
import Store from '../../../store';
import Config from '../../../config';
Expand All @@ -23,6 +27,24 @@ class Navbar extends React.Component {
this.openDropMenu = this.openDropMenu.bind(this);
this.handleClickOutside = this.handleClickOutside.bind(this);
this._checkAC = this._checkAC.bind(this);
this.spvLock = this.spvLock.bind(this);
this.spvLogout = this.spvLogout.bind(this);
}

spvLock() {
shepherdElectrumLock()
.then((res) => {
Store.dispatch(getDexCoins());
Store.dispatch(activeHandle());
});
}

spvLogout() {
shepherdElectrumLogout()
.then((res) => {
Store.dispatch(getDexCoins());
Store.dispatch(activeHandle());
});
}

componentWillMount() {
Expand Down Expand Up @@ -106,6 +128,9 @@ const mapStateToProps = (state) => {
Interval: {
interval: state.Interval.interval,
},
Main: {
isLoggedIn: state.Main.isLoggedIn,
},
};
};

Expand Down
20 changes: 20 additions & 0 deletions react/src/components/dashboard/navbar/navbar.render.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@ const NavbarRender = function() {
<i className="icon fa-users"></i> { translate('ABOUT.ABOUT_AGAMA') }
</a>
</li>
{ this.props.Main &&
this.props.Main.isLoggedIn &&
this.props.Main.spv &&
this.props.Main.spv.length &&
<li>
<a onClick={ this.spvLock }>
<i className="icon fa-lock"></i> Lock
</a>
</li>
}
{ this.props.Main &&
this.props.Main.isLoggedIn &&
this.props.Main.spv &&
this.props.Main.spv.length &&
<li>
<a onClick={ this.spvLogout }>
<i className="icon fa-power-off"></i> Logout
</a>
</li>
}
</ul>
</li>
</ul>
Expand Down
Loading