Skip to content

Commit 5a27c7b

Browse files
committed
feat(neuron-ui): call generate mnemonic method from neuron-wallet in neuron-ui with remote module
1 parent 7e74cc9 commit 5a27c7b

File tree

4 files changed

+17
-47
lines changed

4 files changed

+17
-47
lines changed

packages/neuron-ui/src/components/WalletWizard/index.tsx

+7-14
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import withWizard, { WizardElementProps, WithWizardState } from 'components/with
77

88
import { MnemonicAction, BUTTON_GAP } from 'utils/const'
99
import { verifyWalletSubmission } from 'utils/validators'
10-
import { helpersCall, walletsCall } from 'services/UILayer'
11-
import { validateMnemonic, showErrorMessage } from 'services/remote'
10+
import { walletsCall } from 'services/UILayer'
11+
import { generateMnemonic, validateMnemonic, showErrorMessage } from 'services/remote'
1212
import { registerIcons, buttonGrommetIconStyles } from 'utils/icons'
1313

1414
export enum WalletWizardPath {
@@ -104,18 +104,11 @@ const Mnemonic = ({
104104

105105
useEffect(() => {
106106
if (type === MnemonicAction.Create) {
107-
helpersCall
108-
.generateMnemonic()
109-
.then((res: string) => {
110-
dispatch({
111-
type: 'generated',
112-
payload: res,
113-
})
114-
})
115-
.catch(err => {
116-
console.error(err)
117-
history.goBack()
118-
})
107+
const mnemonic = generateMnemonic()
108+
dispatch({
109+
type: 'generated',
110+
payload: mnemonic,
111+
})
119112
} else {
120113
dispatch({
121114
type: 'imported',

packages/neuron-ui/src/services/remote/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ export const validateMnemonic = (mnemonic: string): boolean => {
1818
return remoteValidateMnemonic(mnemonic)
1919
}
2020

21+
export const generateMnemonic = (): string => {
22+
if (!window.remote) {
23+
console.warn('remote is not supported')
24+
return ''
25+
}
26+
const { generateMnemonic: remoteGenerateMnemonic } = window.remote.require('./models/keys/key')
27+
return remoteGenerateMnemonic()
28+
}
29+
2130
export const showMessage = (options: any, callback: Function) => {
2231
if (!window.remote) {
2332
console.warn('remote is not supported')
@@ -39,6 +48,7 @@ export const showErrorMessage = (title: string, content: string) => {
3948
export default {
4049
initWindow,
4150
validateMnemonic,
51+
generateMnemonic,
4252
showMessage,
4353
showErrorMessage,
4454
}

packages/neuron-wallet/src/controllers/helpers.ts

-31
This file was deleted.

packages/neuron-wallet/src/controllers/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import AppController from './app'
22
import NetworksController from './networks'
33
import WalletsController from './wallets'
44
import TransactionsController from './transactions'
5-
import HelpersController from './helpers'
65
import SyncInfoController from './sync-info'
76

87
export default {
98
AppController,
109
NetworksController,
1110
WalletsController,
1211
TransactionsController,
13-
HelpersController,
1412
SyncInfoController,
1513
}

0 commit comments

Comments
 (0)