Browse Source

zcash params fetch modal

v0.25
pbca26 7 years ago
parent
commit
3a0af8a7ee
  1. 8
      react/src/actions/actionCreators.js
  2. 25
      react/src/actions/actions/update.js
  3. 3
      react/src/actions/storeType.js
  4. 4
      react/src/components/dashboard/main/dashboard.render.js
  5. 12
      react/src/components/main/main.js
  6. 12
      react/src/components/toaster/toaster-item.js
  7. 8
      react/src/reducers/dashboard.js
  8. 1
      react/src/styles/index.scss

8
react/src/actions/actionCreators.js

@ -28,6 +28,7 @@ import {
DASHBOARD_SYNC_ONLY_UPDATE,
DISPLAY_IMPORT_KEY_MODAL,
ELECTRUM_SERVER_CHANGED,
DISPLAY_ZCASH_PARAMS_FETCH,
} from './storeType';
export * from './actions/nativeSyncInfo';
@ -287,4 +288,11 @@ export function electrumServerChanged(isChanged) {
type: ELECTRUM_SERVER_CHANGED,
eletrumServerChanged: isChanged,
}
}
export function toggleZcparamsFetchModal(display) {
return {
type: DISPLAY_ZCASH_PARAMS_FETCH,
displayZcparamsModal: display,
}
}

25
react/src/actions/actions/update.js

@ -45,4 +45,27 @@ export function updateUIPromise() {
.then(response => response.json())
.then(json => resolve(json))
});
}
}
export function downloadZCashParamsPromise(dloption) {
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/zcparamsdl?dloption=${dloption}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(
triggerToaster(
'downloadZCashParamsPromise',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => resolve(json))
});
}

3
react/src/actions/storeType.js

@ -45,4 +45,5 @@ export const LOGIN = 'LOGIN';
export const DASHBOARD_ELECTRUM_BALANCE = 'DASHBOARD_ELECTRUM_BALANCE';
export const DASHBOARD_ELECTRUM_TRANSACTIONS = 'DASHBOARD_ELECTRUM_TRANSACTIONS';
export const DASHBOARD_ELECTRUM_COINS = 'DASHBOARD_ELECTRUM_COINS';
export const ELECTRUM_SERVER_CHANGED = 'ELECTRUM_SERVER_CHANGED';
export const ELECTRUM_SERVER_CHANGED = 'ELECTRUM_SERVER_CHANGED';
export const DISPLAY_ZCASH_PARAMS_FETCH = 'DISPLAY_ZCASH_PARAMS_FETCH';

4
react/src/components/dashboard/main/dashboard.render.js

@ -16,6 +16,7 @@ import WalletsNative from '../walletsNative/walletsNative';
import WalletsTxInfo from '../walletsTxInfo/walletsTxInfo';
import CoindDownModal from '../coindDownModal/coindDownModal';
import ImportKeyModal from '../importKeyModal/importKeyModal';
import ZcparamsFetchModal from '../zcparamsFetchModal/zcparamsFetchModal';
const DashboardRender = function() {
return (
@ -28,6 +29,9 @@ const DashboardRender = function() {
{ this.props.Dashboard.displayImportKeyModal &&
<ImportKeyModal />
}
{ this.props.Dashboard.displayZcparamsModal &&
<ZcparamsFetchModal />
}
<div className={ this.isSectionActive('wallets') ? 'show' : 'hide' }>
<CoinTile />
<WalletsNav />

12
react/src/components/main/main.js

@ -7,6 +7,7 @@ import {
activeHandle,
triggerToaster,
shepherdElectrumCoins,
toggleZcparamsFetchModal,
} from '../../actions/actionCreators';
class Main extends React.Component {
@ -32,6 +33,8 @@ class Main extends React.Component {
document.title = `${appVersion.name} (v${appVersion.version.replace('version=', '')}-beta)`;
}
console.warn(zcashParamsExist);
// TODO: isolate check only when komodod is detected
if (zcashParamsExist.errors) {
let _errors = [translate('KMD_NATIVE.ZCASH_PARAMS_MISSING'), ''];
@ -41,13 +44,15 @@ class Main extends React.Component {
if (!zcashParamsExist.provingKey) {
_errors.push(translate('KMD_NATIVE.ZCASH_PARAMS_MISSING_PROVING_KEY'));
}
if (!zcashParamsExist.provingKey) {
if (!zcashParamsExist.verifyingKey) {
_errors.push(translate('KMD_NATIVE.ZCASH_PARAMS_MISSING_VERIFYING_KEY'));
}
if (!zcashParamsExist.provingKeySize) {
if (!zcashParamsExist.provingKeySize &&
zcashParamsExist.provingKey) {
_errors.push(translate('KMD_NATIVE.ZCASH_PARAMS_MISSING_PROVING_KEY_SIZE'));
}
if (!zcashParamsExist.verifyingKeySize) {
if (!zcashParamsExist.verifyingKeySize &&
zcashParamsExist.verifyingKey) {
_errors.push(translate('KMD_NATIVE.ZCASH_PARAMS_MISSING_VERIFYING_KEY_SIZE'));
}
@ -59,6 +64,7 @@ class Main extends React.Component {
false
)
);
Store.dispatch(toggleZcparamsFetchModal(true));
}
}

12
react/src/components/toaster/toaster-item.js

@ -53,13 +53,15 @@ class ToasterItem extends React.Component {
renderLB() {
if (typeof this.state.message === 'object') {
let _items = [];
const _msg = this.state.message;
let _items = [];
for (let i = 0; i < _msg.length; i++) {
if (_msg[i] === '') {
_items.push(
<div className="margin-top-5"></div>
<div
key={ `toaster-msg-${i}` }
className="margin-top-5"></div>
);
} else {
_items.push(
@ -96,7 +98,11 @@ class ToasterItem extends React.Component {
}
render() {
return this.state.message ? this.renderToast() : null;
if (this.state.message) {
return this.renderToast();
} else {
return null;
}
}
}

8
react/src/reducers/dashboard.js

@ -7,6 +7,7 @@ import {
DISPLAY_IMPORT_KEY_MODAL,
DASHBOARD_ELECTRUM_COINS,
ELECTRUM_SERVER_CHANGED,
DISPLAY_ZCASH_PARAMS_FETCH,
} from '../actions/storeType';
export function Dashboard(state = {
@ -18,6 +19,7 @@ export function Dashboard(state = {
displayImportKeyModal: false,
electrumCoins: {},
eletrumServerChanged: false,
displayZcparamsModal: false,
}, action) {
switch (action.type) {
case DASHBOARD_ELECTRUM_COINS:
@ -35,6 +37,12 @@ export function Dashboard(state = {
...state,
activeHandle: action.activeHandle,
};
case DISPLAY_ZCASH_PARAMS_FETCH:
return {
...state,
displayZcparamsModal: action.displayZcparamsModal,
};
break;
case DISPLAY_COIND_DOWN_MODAL:
return {
...state,

1
react/src/styles/index.scss

@ -42,5 +42,6 @@
@import '../components/dashboard/qrModal/qrModal.scss';
@import '../components/dashboard/coindDownModal/coindDownModal.scss';
@import '../components/dashboard/loginSettingsModal/loginSettingsModal.scss';
@import '../components/dashboard/zcparamsFetchModal/zcparamsFetchModal.scss';
@import '../components/toaster/toaster.scss';
@import '~react-table/react-table.css';

Loading…
Cancel
Save