Skip to content

Commit

Permalink
feat(neuron-ui): call generate mnemonic method from neuron-wallet in …
Browse files Browse the repository at this point in the history
…neuron-ui with remote module
  • Loading branch information
Keith-CY committed Jul 25, 2019
1 parent 7e74cc9 commit 5a27c7b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 47 deletions.
21 changes: 7 additions & 14 deletions packages/neuron-ui/src/components/WalletWizard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import withWizard, { WizardElementProps, WithWizardState } from 'components/with

import { MnemonicAction, BUTTON_GAP } from 'utils/const'
import { verifyWalletSubmission } from 'utils/validators'
import { helpersCall, walletsCall } from 'services/UILayer'
import { validateMnemonic, showErrorMessage } from 'services/remote'
import { walletsCall } from 'services/UILayer'
import { generateMnemonic, validateMnemonic, showErrorMessage } from 'services/remote'
import { registerIcons, buttonGrommetIconStyles } from 'utils/icons'

export enum WalletWizardPath {
Expand Down Expand Up @@ -104,18 +104,11 @@ const Mnemonic = ({

useEffect(() => {
if (type === MnemonicAction.Create) {
helpersCall
.generateMnemonic()
.then((res: string) => {
dispatch({
type: 'generated',
payload: res,
})
})
.catch(err => {
console.error(err)
history.goBack()
})
const mnemonic = generateMnemonic()
dispatch({
type: 'generated',
payload: mnemonic,
})
} else {
dispatch({
type: 'imported',
Expand Down
10 changes: 10 additions & 0 deletions packages/neuron-ui/src/services/remote/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ export const validateMnemonic = (mnemonic: string): boolean => {
return remoteValidateMnemonic(mnemonic)
}

export const generateMnemonic = (): string => {
if (!window.remote) {
console.warn('remote is not supported')
return ''
}
const { generateMnemonic: remoteGenerateMnemonic } = window.remote.require('./models/keys/key')
return remoteGenerateMnemonic()
}

export const showMessage = (options: any, callback: Function) => {
if (!window.remote) {
console.warn('remote is not supported')
Expand All @@ -39,6 +48,7 @@ export const showErrorMessage = (title: string, content: string) => {
export default {
initWindow,
validateMnemonic,
generateMnemonic,
showMessage,
showErrorMessage,
}
31 changes: 0 additions & 31 deletions packages/neuron-wallet/src/controllers/helpers.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/neuron-wallet/src/controllers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import AppController from './app'
import NetworksController from './networks'
import WalletsController from './wallets'
import TransactionsController from './transactions'
import HelpersController from './helpers'
import SyncInfoController from './sync-info'

export default {
AppController,
NetworksController,
WalletsController,
TransactionsController,
HelpersController,
SyncInfoController,
}

0 comments on commit 5a27c7b

Please sign in to comment.