From 8e006e18531cdc070bb3b79c136e259ec2a3079e Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 23 Jul 2019 16:32:19 +0900 Subject: [PATCH 01/20] docs: Update readme --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 46a55940c3..c82d279f56 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Neuron -Nervos CKB Wallet +Nervos CKB Desktop Wallet [![Azure Pipelines Build Status](https://dev.azure.com/nervosnetwork/neuron/_apis/build/status/nervosnetwork.neuron?branchName=develop)](https://dev.azure.com/nervosnetwork/neuron/_build/latest?definitionId=8&branchName=develop) [![TravisCI](https://travis-ci.com/nervosnetwork/neuron.svg?branch=develop)](https://travis-ci.com/nervosnetwork/neuron) @@ -14,21 +14,19 @@ Nervos CKB Wallet You will need `node >= 12` and `yarn >= 1.14` to build and run Neuron. -Please be noted that Neuron depends on [node-gyp](https://github.com/nodejs/node-gyp) to build native NPM modules. Follow [this](https://github.com/nodejs/node-gyp#installation) to install node-gyp dependencies. - #### Lerna -Neuron project uses [lerna](https://github.com/lerna/lerna/) for packages management. It can be installed globally, or locally in the project. +This project uses [lerna](https://github.com/lerna/lerna/) for package management. It can be installed either globally or locally within the project: ```sh $ yarn global add lerna # install lerna globally # or -$ yarn add lerna --exact --ignore-workspace-root-check # install lerna locally in the project +$ yarn add lerna --exact --ignore-workspace-root-check # install lerna locally within the project ``` #### Install Dependencies -After lerna installed, the dependencies can be installed by +After lerna has been installed, run this to install and link dependencies: ```sh $ yarn bootstrap @@ -36,33 +34,35 @@ $ yarn bootstrap ### Start Neuron +A local CKB node is required for Neuron wallet to talk to it via RPC APIs and get data. Please follow the [CKB Nervos doc](https://docs.nervos.org/getting-started/introduction) to get CKB node up and running first. + ### Start Neuron in development mode ```sh $ yarn start ``` -This command will start two tasks +This command will start two tasks: -1. start `neuron-ui`, which works for the user interface. -2. start `neuron-wallet`, works for the wallet functionality. +1. start `neuron-ui`, which is the React UI layer. +2. start `neuron-wallet`, which is the core wallet layer. -They are also able to start independently: +You can also start them independently: ```sh # start neuron-ui at `http://localhost:3000` -$ cd packages/neuron-ui && yarn start +$ yarn start:ui ``` ```sh # start neuron-wallet -$ cd packages/neuron-wallet && yarn start:dev +$ yarn start:wallet ``` ### Test ```sh -# launch the test runner in the watch mode. +# launch the test runner. $ yarn test ``` From 9dfd1c9c670a736447af8bd2bf50229279d12dcc Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 23 Jul 2019 16:37:27 +0900 Subject: [PATCH 02/20] docs: Description for downloading binary --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index c82d279f56..f86d4322d8 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,10 @@ $ yarn start:wallet $ yarn test ``` +## Binary + +If you don't want to bother building from source, you can download a binary from [releases](https://github.com/nervosnetwork/neuron/releases). We offer pre-built binaries for Windows, Linux and macOS. + ## License Neuron is released under the terms of the MIT license. See [COPYING](COPYING) for more information or see [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT). From 23560abab101cacaa2f80f1cee5305349677b14c Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 23 Jul 2019 16:39:27 +0900 Subject: [PATCH 03/20] docs: Update readme titles --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f86d4322d8..b6081f2abb 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ $ yarn bootstrap A local CKB node is required for Neuron wallet to talk to it via RPC APIs and get data. Please follow the [CKB Nervos doc](https://docs.nervos.org/getting-started/introduction) to get CKB node up and running first. -### Start Neuron in development mode +### Start Neuron in Development Mode ```sh $ yarn start @@ -66,7 +66,7 @@ $ yarn start:wallet $ yarn test ``` -## Binary +## Download Neuron Binary If you don't want to bother building from source, you can download a binary from [releases](https://github.com/nervosnetwork/neuron/releases). We offer pre-built binaries for Windows, Linux and macOS. From 475f0c101fdd864c981a84da9ad5a28ca73645a6 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 23 Jul 2019 16:40:50 +0900 Subject: [PATCH 04/20] docs: Fix CKB doc link title --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b6081f2abb..be642ea1c2 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ $ yarn bootstrap ### Start Neuron -A local CKB node is required for Neuron wallet to talk to it via RPC APIs and get data. Please follow the [CKB Nervos doc](https://docs.nervos.org/getting-started/introduction) to get CKB node up and running first. +A local CKB node is required for Neuron wallet to talk to it via RPC APIs and get data. Please follow the [Nervos CKB doc](https://docs.nervos.org/getting-started/introduction) to get CKB node up and running first. ### Start Neuron in Development Mode From d8d1d0865f39ce816cfb03bbeae03522b1c38e87 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 23 Jul 2019 18:07:34 +0900 Subject: [PATCH 05/20] feat: Do not even try notarizing app if apple id and password is not provided via ENV variables --- packages/neuron-wallet/scripts/notarize.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/neuron-wallet/scripts/notarize.js b/packages/neuron-wallet/scripts/notarize.js index 0ceebcdd11..a23ca12818 100644 --- a/packages/neuron-wallet/scripts/notarize.js +++ b/packages/neuron-wallet/scripts/notarize.js @@ -6,12 +6,19 @@ exports.default = async function notarizing(context) { return; } + const appleId = process.env.APPLE_ID; + const appleIdPassword = process.env.APPLE_ID_PASSWORD; + + if (!appleId || !appleIdPassword) { + return; + } + const appName = context.packager.appInfo.productFilename; return await notarize({ appBundleId: 'com.nervos.neuron', appPath: `${appOutDir}/${appName}.app`, - appleId: process.env.APPLE_ID, - appleIdPassword: process.env.APPLE_ID_PASSWORD, + appleId: appldId, + appleIdPassword: appleIdPassword, }); -}; \ No newline at end of file +}; From 8fa24722442cf97508bbf650467ffc831240ffd3 Mon Sep 17 00:00:00 2001 From: classicalliu Date: Tue, 23 Jul 2019 17:46:14 +0800 Subject: [PATCH 06/20] fix: wrapper async.queue and rewrite kill --- .../src/services/queue-adapter.ts | 44 +++++++++++++++++++ .../src/services/sync/block-listener.ts | 5 ++- .../src/services/sync/block-number.ts | 2 +- .../neuron-wallet/src/services/sync/queue.ts | 4 +- .../src/startup/sync-block-task/task.ts | 5 +-- 5 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 packages/neuron-wallet/src/services/queue-adapter.ts diff --git a/packages/neuron-wallet/src/services/queue-adapter.ts b/packages/neuron-wallet/src/services/queue-adapter.ts new file mode 100644 index 0000000000..4fc7fb11a0 --- /dev/null +++ b/packages/neuron-wallet/src/services/queue-adapter.ts @@ -0,0 +1,44 @@ +import async from 'async' + +export default class QueueAdapter { + private q: any + + constructor(worker: async.AsyncWorker, concurrency?: number | undefined) { + this.q = async.queue(worker, concurrency) + } + + public push = (value: any) => { + this.innerPush(value) + } + + private innerPush = (value: any) => { + this.q.push(value) + } + + public kill = () => { + this.push = () => {} + this.pause() + this.remove(() => true) + this.q.kill() + } + + public remove = (callback: any) => { + this.q.remove(callback) + } + + public pause = () => { + this.q.pause() + } + + public resume = () => { + this.q.resume() + } + + public length = (): number => { + return this.q.length() + } + + public drain = (callback: any) => { + this.q.drain(callback) + } +} diff --git a/packages/neuron-wallet/src/services/sync/block-listener.ts b/packages/neuron-wallet/src/services/sync/block-listener.ts index c5a9cb971a..2a0ffa1fa9 100644 --- a/packages/neuron-wallet/src/services/sync/block-listener.ts +++ b/packages/neuron-wallet/src/services/sync/block-listener.ts @@ -47,7 +47,10 @@ export default class BlockListener { // start listening /* eslint no-await-in-loop: "off" */ /* eslint no-constant-condition: "off" */ - public start = async () => { + public start = async (restart: boolean = false) => { + if (restart) { + await this.currentBlockNumber.updateCurrent(BigInt(0)) + } while (this.queue !== null) { await this.regenerate() await Utils.sleep(this.interval) diff --git a/packages/neuron-wallet/src/services/sync/block-number.ts b/packages/neuron-wallet/src/services/sync/block-number.ts index 6052e7a272..7d540ee828 100644 --- a/packages/neuron-wallet/src/services/sync/block-number.ts +++ b/packages/neuron-wallet/src/services/sync/block-number.ts @@ -9,7 +9,7 @@ const currentBlockSubject = isRenderer : CurrentBlockSubject.getSubject() export default class BlockNumber { - private current: bigint = BigInt(0) + private current: bigint | undefined = undefined public getCurrent = async (): Promise => { if (this.current) { diff --git a/packages/neuron-wallet/src/services/sync/queue.ts b/packages/neuron-wallet/src/services/sync/queue.ts index 5df04eb712..8960b87034 100644 --- a/packages/neuron-wallet/src/services/sync/queue.ts +++ b/packages/neuron-wallet/src/services/sync/queue.ts @@ -1,10 +1,10 @@ -import async from 'async' import GetBlocks from './get-blocks' import { Block, BlockHeader } from '../../types/cell-types' import RangeForCheck from './range-for-check' import BlockNumber from './block-number' import Utils from './utils' import TransactionsService from '../transactions' +import QueueAdapter from '../queue-adapter' export default class Queue { private q: any @@ -36,7 +36,7 @@ export default class Queue { } private generateQueue = () => { - this.q = async.queue(this.getWorker(), this.concurrent) + this.q = new QueueAdapter(this.getWorker(), this.concurrent) } private regenerateQueue = async () => { diff --git a/packages/neuron-wallet/src/startup/sync-block-task/task.ts b/packages/neuron-wallet/src/startup/sync-block-task/task.ts index f1700d2e6a..7498ded889 100644 --- a/packages/neuron-wallet/src/startup/sync-block-task/task.ts +++ b/packages/neuron-wallet/src/startup/sync-block-task/task.ts @@ -8,7 +8,6 @@ import BlockListener from '../../services/sync/block-listener' import { NetworkWithID } from '../../services/networks' import { initDatabase } from './init-database' import { register as registerTxStatusListener } from '../../listeners/tx-status' -import BlockNumber from '../../services/sync/block-number' import Utils from '../../services/sync/utils' const { onCloseEvent } = remote.require('./startup/sync-block-task/create') @@ -66,11 +65,9 @@ export const switchNetwork = async () => { closeListener(addressDBChangedListener) const regenerateListener = async () => { - const blockNumber = new BlockNumber() - await blockNumber.updateCurrent(BigInt(0)) const hashes: string[] = await loadAddressesAndConvert() blockListener = new BlockListener(hashes, nodeService.tipNumberSubject) - await blockListener.start() + await blockListener.start(true) } const walletCreatedListener = walletCreatedSubject.subscribe(async (type: string) => { From d7d1de887a7ed3fce3ab73349a5039b72507dbf9 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 24 Jul 2019 11:20:19 +0900 Subject: [PATCH 07/20] feat: Polish send view fee panel --- .../src/components/Receive/index.tsx | 2 +- .../neuron-ui/src/components/Send/index.tsx | 60 +++++++++++++------ .../components/TransactionFeePanel/index.tsx | 56 +++++++++++------ 3 files changed, 81 insertions(+), 37 deletions(-) diff --git a/packages/neuron-ui/src/components/Receive/index.tsx b/packages/neuron-ui/src/components/Receive/index.tsx index 0989ca45e6..19a3801b6a 100644 --- a/packages/neuron-ui/src/components/Receive/index.tsx +++ b/packages/neuron-ui/src/components/Receive/index.tsx @@ -32,7 +32,7 @@ const Receive = ({ return ( <> - + diff --git a/packages/neuron-ui/src/components/Send/index.tsx b/packages/neuron-ui/src/components/Send/index.tsx index bcf1f0e421..29e60f5680 100644 --- a/packages/neuron-ui/src/components/Send/index.tsx +++ b/packages/neuron-ui/src/components/Send/index.tsx @@ -3,6 +3,8 @@ import { RouteComponentProps } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { Stack, + Label, + Text, List, TextField, PrimaryButton, @@ -50,9 +52,15 @@ const Send = ({ onDescriptionChange, onClear, } = useInitialize(address, send.outputs, dispatch, history) + const labelWidthStyles = { root: { width: '140px' } } + const actionSpacer = ( + + + + ) return ( - + - + + + + @@ -86,17 +101,24 @@ const Send = ({ {send.outputs.length > 1 ? ( removeTransactionOutput(idx)}> - + ) : null} - + + + + - - - + + + - - + + + {actionSpacer} -
{`${t('send.balance')}: ${shannonToCKBFormatter(balance)} CKB`}
+ + + + + + {`${shannonToCKBFormatter(balance)} CKB`} + + diff --git a/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx b/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx index 2a70c6c842..013a89bcef 100644 --- a/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx +++ b/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react' -import { Stack, Label, TextField, Dropdown } from 'office-ui-fabric-react' +import { Stack, Label, TextField, Dropdown, IconButton } from 'office-ui-fabric-react' import { CaretDown } from 'grommet-icons' import { useTranslation } from 'react-i18next' @@ -18,43 +18,60 @@ const TransactionFee: React.FunctionComponent = ({ }: TransactionFee) => { const [t] = useTranslation() const [showDetail, setShowDetail] = useState(false) + const labelWidthStyles = { root: { width: '140px' } } + const actionSpacer = ( + + + + ) + return ( - - - - - - - + + + + + + + + + {actionSpacer} + + - setShowDetail(!showDetail)} - style={{ - transform: showDetail ? 'rotate(180deg)' : 'none', - }} - /> + setShowDetail(!showDetail)}> + setShowDetail(!showDetail)} + style={{ + transform: showDetail ? 'rotate(180deg)' : 'none', + }} + /> + + - + + {actionSpacer} + - + @@ -69,9 +86,12 @@ const TransactionFee: React.FunctionComponent = ({ /> + - - {t('send.total-cycles')} + + + + {cycles} From 065892a0171c4ea92abe013bcc75f68c487d2135 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 24 Jul 2019 11:36:46 +0900 Subject: [PATCH 08/20] feat: Extract label/stack width variables --- .../neuron-ui/src/components/Send/index.tsx | 17 +++++++++-------- .../components/TransactionFeePanel/index.tsx | 15 ++++++++------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/neuron-ui/src/components/Send/index.tsx b/packages/neuron-ui/src/components/Send/index.tsx index 29e60f5680..32c564fe2a 100644 --- a/packages/neuron-ui/src/components/Send/index.tsx +++ b/packages/neuron-ui/src/components/Send/index.tsx @@ -52,7 +52,8 @@ const Send = ({ onDescriptionChange, onClear, } = useInitialize(address, send.outputs, dispatch, history) - const labelWidthStyles = { root: { width: '140px' } } + const leftStackWidth = '70%' + const labelWidth = '140px' const actionSpacer = ( @@ -74,10 +75,10 @@ const Send = ({ - + @@ -111,10 +112,10 @@ const Send = ({ - + @@ -148,8 +149,8 @@ const Send = ({ - - + + @@ -162,7 +163,7 @@ const Send = ({ - + diff --git a/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx b/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx index 013a89bcef..543a2b0f54 100644 --- a/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx +++ b/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx @@ -18,7 +18,8 @@ const TransactionFee: React.FunctionComponent = ({ }: TransactionFee) => { const [t] = useTranslation() const [showDetail, setShowDetail] = useState(false) - const labelWidthStyles = { root: { width: '140px' } } + const leftStackWidth = '70%' + const labelWidth = '140px' const actionSpacer = ( @@ -28,8 +29,8 @@ const TransactionFee: React.FunctionComponent = ({ return ( - - + + @@ -55,13 +56,13 @@ const TransactionFee: React.FunctionComponent = ({ styles={{ root: { maxHeight: showDetail ? '100vw' : '0', - width: '70%', + width: leftStackWidth, overflow: 'hidden', }, }} > - + @@ -71,7 +72,7 @@ const TransactionFee: React.FunctionComponent = ({ - + @@ -89,7 +90,7 @@ const TransactionFee: React.FunctionComponent = ({ - + {cycles} From e5c2210d2ce29953546ec165ec969d7442935b01 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 24 Jul 2019 11:49:54 +0900 Subject: [PATCH 09/20] feat: Use grommet down arrow icon for fabric dropdown button --- .../src/components/TransactionFeePanel/index.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx b/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx index 543a2b0f54..c8305d75cb 100644 --- a/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx +++ b/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx @@ -1,8 +1,10 @@ import React, { useState } from 'react' -import { Stack, Label, TextField, Dropdown, IconButton } from 'office-ui-fabric-react' -import { CaretDown } from 'grommet-icons' +import { Stack, Label, TextField, Dropdown, IconButton, Icon } from 'office-ui-fabric-react' +import { CaretDown, Down } from 'grommet-icons' import { useTranslation } from 'react-i18next' +import { registerIcons } from 'utils/icons' + interface TransactionFee { fee: string cycles: string @@ -10,6 +12,12 @@ interface TransactionFee { onPriceChange: any } +registerIcons({ + icons: { + ArrowDown: , + }, +}) + const TransactionFee: React.FunctionComponent = ({ cycles, price, @@ -84,6 +92,9 @@ const TransactionFee: React.FunctionComponent = ({ { key: '60', text: '~ 1min' }, { key: '180', text: '~ 3min' }, ]} + onRenderCaretDown={() => { + return + }} /> From 218851de70b0e46418b577faf5afa05d6b9a6ade Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 24 Jul 2019 12:01:25 +0900 Subject: [PATCH 10/20] feat: Fix dropdown button width for selecting expected speed options --- packages/neuron-ui/src/components/TransactionFeePanel/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx b/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx index c8305d75cb..aaa3fa17a9 100644 --- a/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx +++ b/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx @@ -85,6 +85,7 @@ const TransactionFee: React.FunctionComponent = ({ Date: Wed, 24 Jul 2019 12:21:27 +0900 Subject: [PATCH 11/20] feat: Polish fee settings by using toggle control --- .../components/TransactionFeePanel/index.tsx | 19 +++++++++---------- packages/neuron-ui/src/locales/en.json | 1 + packages/neuron-ui/src/locales/zh.json | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx b/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx index aaa3fa17a9..ef4c43d267 100644 --- a/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx +++ b/packages/neuron-ui/src/components/TransactionFeePanel/index.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react' -import { Stack, Label, TextField, Dropdown, IconButton, Icon } from 'office-ui-fabric-react' -import { CaretDown, Down } from 'grommet-icons' +import { Stack, Label, TextField, Dropdown, Toggle, Icon } from 'office-ui-fabric-react' +import { Down } from 'grommet-icons' import { useTranslation } from 'react-i18next' import { registerIcons } from 'utils/icons' @@ -48,14 +48,13 @@ const TransactionFee: React.FunctionComponent = ({ - setShowDetail(!showDetail)}> - setShowDetail(!showDetail)} - style={{ - transform: showDetail ? 'rotate(180deg)' : 'none', - }} - /> - + { + setShowDetail(!showDetail) + }} + label={t('send.advanced-fee-settings')} + inlineLabel + /> diff --git a/packages/neuron-ui/src/locales/en.json b/packages/neuron-ui/src/locales/en.json index 3c92614efe..1239aaf03f 100644 --- a/packages/neuron-ui/src/locales/en.json +++ b/packages/neuron-ui/src/locales/en.json @@ -69,6 +69,7 @@ "add-one": "Add One More", "remove-this": "Remove This", "fee": "Transaction Fee", + "advanced-fee-settings": "Advanced fee settings", "price": "Price", "expected-speed": "Expected speed", "total-cycles": "Total RISC-V Cycles" diff --git a/packages/neuron-ui/src/locales/zh.json b/packages/neuron-ui/src/locales/zh.json index 6c08baed27..f0986b9900 100644 --- a/packages/neuron-ui/src/locales/zh.json +++ b/packages/neuron-ui/src/locales/zh.json @@ -69,6 +69,7 @@ "add-one": "添加", "remove-this": "删除", "fee": "交易费", + "advanced-fee-settings": "交易费高级设置", "price": "单价", "expected-speed": "预期成交速度", "total-cycles": "RISC-V Cycles 总数" From 73ca3ebb9a3b164e7df0ff3f0f94ddfbd151069e Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 24 Jul 2019 11:43:18 +0800 Subject: [PATCH 12/20] feat(neuron-ui): subscribe data update messages in neuron-ui --- .../neuron-ui/src/containers/Main/hooks.ts | 110 ++++++++---------- .../neuron-ui/src/containers/Main/index.tsx | 2 + packages/neuron-ui/src/services/subjects.ts | 31 ++++- .../neuron-ui/src/types/Subject/index.d.ts | 7 ++ packages/neuron-ui/src/utils/const.ts | 1 - .../src/models/subjects/data-update.ts | 7 +- .../src/models/window-manager.ts | 15 --- 7 files changed, 85 insertions(+), 88 deletions(-) create mode 100644 packages/neuron-ui/src/types/Subject/index.d.ts diff --git a/packages/neuron-ui/src/containers/Main/hooks.ts b/packages/neuron-ui/src/containers/Main/hooks.ts index 130ae9a70c..094bb5a8e3 100644 --- a/packages/neuron-ui/src/containers/Main/hooks.ts +++ b/packages/neuron-ui/src/containers/Main/hooks.ts @@ -15,7 +15,7 @@ import UILayer, { networksCall, } from 'services/UILayer' import { initWindow } from 'services/remote' -import { systemScript as systemScriptSubject } from 'services/subjects' +import { SystemScript as SystemScriptSubject, DataUpdate as DataUpdateSubject } from 'services/subjects' import { ckbCore, getTipBlockNumber, getBlockchainInfo } from 'services/chain' import { Routes, Channel, ConnectionStatus } from 'utils/const' import { @@ -46,61 +46,6 @@ export const useChannelListeners = ({ i18n: any }) => useEffect(() => { - UILayer.on( - Channel.DataUpdate, - ( - _e: Event, - _actionType: 'create' | 'update' | 'delete', - dataType: 'address' | 'transaction' | 'wallet' | 'network', - walletIDOfMessage?: string - ) => { - if (walletIDOfMessage && walletIDOfMessage !== walletID) { - return - } - switch (dataType) { - case 'address': { - walletsCall.getAllAddresses(walletID) - break - } - case 'transaction': { - transactionsCall.getAllByKeywords({ - walletID, - keywords: chain.transactions.keywords, - pageNo: chain.transactions.pageNo, - pageSize: chain.transactions.pageSize, - }) - transactionsCall.get(walletID, chain.transaction.hash) - break - } - case 'wallet': { - walletsCall.getAll() - walletsCall.getCurrent() - break - } - case 'network': { - networksCall.getAll() - networksCall.currentID() - break - } - default: { - walletsCall.getCurrent() - walletsCall.getAll() - walletsCall.getAllAddresses(walletID) - networksCall.currentID() - networksCall.getAll() - transactionsCall.getAllByKeywords({ - walletID, - keywords: chain.transactions.keywords, - pageNo: chain.transactions.pageNo, - pageSize: chain.transactions.pageSize, - }) - transactionsCall.get(walletID, chain.transaction.hash) - break - } - } - } - ) - UILayer.on(Channel.App, (_e: Event, method: AppMethod, args: ChannelResponse) => { if (args && args.status) { switch (method) { @@ -457,19 +402,64 @@ export const useOnCurrentWalletChange = ({ }, [walletID, pageNo, pageSize, dispatch, i18n, history]) } -export const useSubscription = ({ dispatch }: { dispatch: StateDispatch }) => { +export const useSubscription = ({ + walletID, + chain, + dispatch, +}: { + walletID: string + chain: State.Chain + dispatch: StateDispatch +}) => { + const { pageNo, pageSize, keywords } = chain.transactions + const { hash: txHash } = chain.transaction useEffect(() => { - systemScriptSubject().subscribe(({ codeHash = '' }: { codeHash: string }) => { + const systemScriptSubscription = SystemScriptSubject.subscribe(({ codeHash = '' }: { codeHash: string }) => { systemScriptCache.save({ codeHash }) dispatch({ type: NeuronWalletActions.UpdateCodeHash, payload: codeHash, }) }) + const dataUpdateSubscription = DataUpdateSubject.subscribe(({ dataType, walletID: walletIDOfMessage }: any) => { + if (walletIDOfMessage && walletIDOfMessage !== walletID) { + return + } + switch (dataType) { + case 'address': { + walletsCall.getAllAddresses(walletID) + break + } + case 'transaction': { + transactionsCall.getAllByKeywords({ + walletID, + keywords, + pageNo, + pageSize, + }) + transactionsCall.get(walletID, txHash) + break + } + case 'wallet': { + walletsCall.getAll() + walletsCall.getCurrent() + break + } + case 'network': { + networksCall.getAll() + networksCall.currentID() + break + } + default: { + break + } + } + }) return () => { - systemScriptSubject().unsubscribe() + systemScriptSubscription.unsubscribe() + dataUpdateSubscription.unsubscribe() } - }, [dispatch]) + }, [walletID, pageNo, pageSize, keywords, txHash, dispatch]) } export default { diff --git a/packages/neuron-ui/src/containers/Main/index.tsx b/packages/neuron-ui/src/containers/Main/index.tsx index 90c334d3a2..55095f47b6 100644 --- a/packages/neuron-ui/src/containers/Main/index.tsx +++ b/packages/neuron-ui/src/containers/Main/index.tsx @@ -123,6 +123,8 @@ const MainContent = ({ }) useSubscription({ + walletID, + chain, dispatch, }) diff --git a/packages/neuron-ui/src/services/subjects.ts b/packages/neuron-ui/src/services/subjects.ts index 151ad47114..6523260f5a 100644 --- a/packages/neuron-ui/src/services/subjects.ts +++ b/packages/neuron-ui/src/services/subjects.ts @@ -1,11 +1,30 @@ -export const systemScript = () => { - if (!window.remote) { +const FallbackSubject = { + subscribe: (args: any) => { console.warn('remote is not supported') - return undefined - } - return window.remote.require('./models/subjects/system-script').default + console.info(JSON.stringify(args)) + return { + unsubscribe: () => { + console.info('unsubscribe') + }, + } + }, + unsubscribe: () => { + console.info('unsubscribe') + }, } +export const SystemScript = window.remote + ? (window.remote.require('./models/subjects/system-script').default as NeuronWalletSubject<{ codeHash: string }>) + : FallbackSubject + +export const DataUpdate = window.remote + ? (window.remote.require('./models/subjects/data-update').default as NeuronWalletSubject<{ + dataType: 'address' | 'transaction' | 'wallet' | 'network' + actionType: 'create' | 'update' | 'delete' + walletID?: string + }>) + : FallbackSubject export default { - systemScript, + SystemScript, + DataUpdate, } diff --git a/packages/neuron-ui/src/types/Subject/index.d.ts b/packages/neuron-ui/src/types/Subject/index.d.ts new file mode 100644 index 0000000000..88eed10de2 --- /dev/null +++ b/packages/neuron-ui/src/types/Subject/index.d.ts @@ -0,0 +1,7 @@ +interface Subscription { + unsubscribe: () => void +} +interface NeuronWalletSubject { + subscribe: (onData?: (data: T) => void, onError?: (error: Error) => void, onComplete?: () => void) => Subscription + unsubscribe: () => void +} diff --git a/packages/neuron-ui/src/utils/const.ts b/packages/neuron-ui/src/utils/const.ts index b8580fe0fe..e6a991e4ca 100644 --- a/packages/neuron-ui/src/utils/const.ts +++ b/packages/neuron-ui/src/utils/const.ts @@ -21,7 +21,6 @@ export enum Channel { Transactions = 'transactions', Wallets = 'wallets', Helpers = 'helpers', - DataUpdate = 'dataUpdate', } export enum Routes { diff --git a/packages/neuron-wallet/src/models/subjects/data-update.ts b/packages/neuron-wallet/src/models/subjects/data-update.ts index 05fd1682d1..17f46ab04f 100644 --- a/packages/neuron-wallet/src/models/subjects/data-update.ts +++ b/packages/neuron-wallet/src/models/subjects/data-update.ts @@ -1,14 +1,9 @@ import { Subject } from 'rxjs' -import windowManager from '../window-manager' -const DataUpdateSubject = new Subject<{ +export const DataUpdateSubject = new Subject<{ dataType: 'address' | 'transaction' | 'wallet' | 'network' actionType: 'create' | 'update' | 'delete' walletID?: string }>() -DataUpdateSubject.subscribe(({ dataType, actionType }) => { - windowManager.broadcastDataUpdateMessage(actionType, dataType) -}) - export default DataUpdateSubject diff --git a/packages/neuron-wallet/src/models/window-manager.ts b/packages/neuron-wallet/src/models/window-manager.ts index 3efe4c079a..8c095f0938 100644 --- a/packages/neuron-wallet/src/models/window-manager.ts +++ b/packages/neuron-wallet/src/models/window-manager.ts @@ -31,21 +31,6 @@ export default class WindowManager { }) } - public static broadcastDataUpdateMessage = ( - actionType: 'create' | 'update' | 'delete', - dataType: 'address' | 'transaction' | 'wallet' | 'network' - ) => { - if (!BrowserWindow) { - logger.log(error) - return - } - BrowserWindow.getAllWindows().forEach(window => { - if (window && window.webContents) { - window.webContents.send(Channel.DataUpdate, actionType, dataType) - } - }) - } - public static sendToFocusedWindow: SendMessage = (channel: Channel, method: string, params: any): void => { if (!BrowserWindow) { logger.log(error) From 4c9f8fc77b22f18068cf790f587daace1dda7603 Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 24 Jul 2019 12:43:28 +0800 Subject: [PATCH 13/20] feat(neuron-ui): use go back instead of go to overview in the settings view --- packages/neuron-ui/src/components/Settings/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/neuron-ui/src/components/Settings/index.tsx b/packages/neuron-ui/src/components/Settings/index.tsx index 7e98fcef76..706086e1b6 100644 --- a/packages/neuron-ui/src/components/Settings/index.tsx +++ b/packages/neuron-ui/src/components/Settings/index.tsx @@ -46,15 +46,15 @@ const Settings = ({ ...neuronWalletState }: React.PropsWithoutRef) => { const [t] = useTranslation() - const goToOverview = useCallback(() => { - history.push(Routes.Overview) + const goBack = useCallback(() => { + history.goBack() }, [history]) return ( - + @@ -69,7 +69,7 @@ const Settings = ({ selectedKey={location.pathname} onLinkClick={(pivotItem?: PivotItem) => { if (pivotItem && pivotItem.props && pivotItem.props.itemKey) { - history.push(pivotItem.props.itemKey) + history.replace(pivotItem.props.itemKey) } }} headersOnly From 49e35c3b2f283e7059af6f27963bb4045f7eab69 Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 24 Jul 2019 13:16:40 +0800 Subject: [PATCH 14/20] feat(neuron-ui): cache language configuration --- packages/neuron-ui/src/utils/i18n.ts | 3 ++- packages/neuron-ui/src/utils/initializeApp.ts | 6 ++++-- packages/neuron-ui/src/utils/localCache.ts | 12 ++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/neuron-ui/src/utils/i18n.ts b/packages/neuron-ui/src/utils/i18n.ts index 194eccc76c..71a69dab9d 100644 --- a/packages/neuron-ui/src/utils/i18n.ts +++ b/packages/neuron-ui/src/utils/i18n.ts @@ -1,5 +1,6 @@ import i18n from 'i18next' import { initReactI18next } from 'react-i18next' +import { language } from 'utils/localCache' import zh from 'locales/zh.json' import en from 'locales/en.json' @@ -8,7 +9,7 @@ i18n.use(initReactI18next).init({ en, zh, }, - fallbackLng: 'en', + fallbackLng: language.load(), interpolation: { escapeValue: false, }, diff --git a/packages/neuron-ui/src/utils/initializeApp.ts b/packages/neuron-ui/src/utils/initializeApp.ts index 9ce9878e82..c0884740ab 100644 --- a/packages/neuron-ui/src/utils/initializeApp.ts +++ b/packages/neuron-ui/src/utils/initializeApp.ts @@ -8,6 +8,7 @@ import { currentNetworkID as currentNetworkIDCache, currentWallet as currentWalletCache, systemScript as systemScriptCache, + language as languageCache, } from 'utils/localCache' import { Routes, ConnectionStatus } from 'utils/const' import { WalletWizardPath } from 'components/WalletWizard' @@ -25,7 +26,7 @@ const intializeApp = ({ dispatch: StateDispatch }) => { const { - locale = 'zh-CN', + locale, networks = [], currentNetworkID: networkID = '', wallets = [], @@ -36,8 +37,9 @@ const intializeApp = ({ connectionStatus = false, codeHash = '', } = initializedState - if (locale !== i18n.language) { + if (locale && locale !== i18n.language) { i18n.changeLanguage(locale) + languageCache.save(locale) } if (wallet && wallet.id) { history.push(Routes.Overview) diff --git a/packages/neuron-ui/src/utils/localCache.ts b/packages/neuron-ui/src/utils/localCache.ts index 2861d7c3aa..7302aa2926 100644 --- a/packages/neuron-ui/src/utils/localCache.ts +++ b/packages/neuron-ui/src/utils/localCache.ts @@ -6,6 +6,7 @@ export enum LocalCacheKey { CurrentWallet = 'currentWallet', CurrentNetworkID = 'currentNetworkID', SystemScript = 'systemScript', + Language = 'lng', } enum AddressBookVisibility { Invisible = '0', @@ -141,6 +142,16 @@ export const systemScript = { }, } +export const language = { + save: (lng: string) => { + window.localStorage.setItem(LocalCacheKey.Language, lng) + return true + }, + load: () => { + return window.localStorage.getItem(LocalCacheKey.Language) || 'en' + }, +} + export default { LocalCacheKey, addressBook, @@ -150,4 +161,5 @@ export default { currentWallet, currentNetworkID, systemScript, + language, } From 033f7521c8c40b8d6e8aefe5a515a9eea2d78596 Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 24 Jul 2019 14:03:48 +0800 Subject: [PATCH 15/20] feat(neuron-ui): only support en and zh languages --- packages/neuron-ui/src/utils/i18n.ts | 8 ++++++++ packages/neuron-ui/src/utils/initializeApp.ts | 9 +++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/neuron-ui/src/utils/i18n.ts b/packages/neuron-ui/src/utils/i18n.ts index 71a69dab9d..ffbc02b29e 100644 --- a/packages/neuron-ui/src/utils/i18n.ts +++ b/packages/neuron-ui/src/utils/i18n.ts @@ -7,7 +7,15 @@ import en from 'locales/en.json' i18n.use(initReactI18next).init({ resources: { en, + 'en-AU': en, + 'en-CA': en, + 'en-GB': en, + 'en-NZ': en, + 'en-US': en, + 'en-ZA': en, zh, + 'zh-CN': zh, + 'zh-TW': zh, }, fallbackLng: language.load(), interpolation: { diff --git a/packages/neuron-ui/src/utils/initializeApp.ts b/packages/neuron-ui/src/utils/initializeApp.ts index c0884740ab..73b85ec803 100644 --- a/packages/neuron-ui/src/utils/initializeApp.ts +++ b/packages/neuron-ui/src/utils/initializeApp.ts @@ -26,7 +26,7 @@ const intializeApp = ({ dispatch: StateDispatch }) => { const { - locale, + locale = '', networks = [], currentNetworkID: networkID = '', wallets = [], @@ -37,9 +37,10 @@ const intializeApp = ({ connectionStatus = false, codeHash = '', } = initializedState - if (locale && locale !== i18n.language) { - i18n.changeLanguage(locale) - languageCache.save(locale) + const lng = (locale as string).startsWith('zh') ? 'zh' : 'en' + if (lng !== i18n.language) { + i18n.changeLanguage(lng) + languageCache.save(lng) } if (wallet && wallet.id) { history.push(Routes.Overview) From d1212feb4d608b5d32d769f76cde41379b322e1b Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 24 Jul 2019 16:20:01 +0800 Subject: [PATCH 16/20] refactor(neuron-ui): remove redundant i18n resources --- packages/neuron-ui/src/utils/i18n.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/neuron-ui/src/utils/i18n.ts b/packages/neuron-ui/src/utils/i18n.ts index ffbc02b29e..71a69dab9d 100644 --- a/packages/neuron-ui/src/utils/i18n.ts +++ b/packages/neuron-ui/src/utils/i18n.ts @@ -7,15 +7,7 @@ import en from 'locales/en.json' i18n.use(initReactI18next).init({ resources: { en, - 'en-AU': en, - 'en-CA': en, - 'en-GB': en, - 'en-NZ': en, - 'en-US': en, - 'en-ZA': en, zh, - 'zh-CN': zh, - 'zh-TW': zh, }, fallbackLng: language.load(), interpolation: { From b33a238f45f8072c63d26503a8f8b3230fef946f Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 24 Jul 2019 17:04:58 +0800 Subject: [PATCH 17/20] feat(neuron-ui): add check on current wallet id on leaving settings view --- packages/neuron-ui/src/components/Settings/index.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/neuron-ui/src/components/Settings/index.tsx b/packages/neuron-ui/src/components/Settings/index.tsx index 706086e1b6..fa6c20346d 100644 --- a/packages/neuron-ui/src/components/Settings/index.tsx +++ b/packages/neuron-ui/src/components/Settings/index.tsx @@ -9,6 +9,7 @@ import { StateWithDispatch } from 'states/stateProvider/reducer' import GeneralSetting from 'components/GeneralSetting' import Wallets from 'components/WalletSetting' import NetworkSetting from 'components/NetworkSetting' +import { WalletWizardPath } from 'components/WalletWizard' import { Routes } from 'utils/const' @@ -46,15 +47,16 @@ const Settings = ({ ...neuronWalletState }: React.PropsWithoutRef) => { const [t] = useTranslation() - const goBack = useCallback(() => { - history.goBack() - }, [history]) + const { id } = neuronWalletState.wallet + const onLeave = useCallback(() => { + return id ? history.push(Routes.Overview) : history.push(`${Routes.WalletWizard}${WalletWizardPath.Welcome}`) + }, [id, history]) return ( - + From db204d1ae80d2101650081928f89b3b056bca3b6 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 24 Jul 2019 22:34:58 +0900 Subject: [PATCH 18/20] Revert "feat: unsubscribe when sync window close and reopen one when closed" To fix the app cannot quit bug. This reverts commit a1221750abeb71d53a3d30142ee8868b625b04b4. --- packages/neuron-wallet/src/env.ts | 4 ---- .../src/services/sync/block-listener.ts | 10 +--------- .../src/services/sync/get-blocks.ts | 7 +------ .../src/startup/sync-block-task/create.ts | 9 +-------- .../src/startup/sync-block-task/task.ts | 20 ++++--------------- 5 files changed, 7 insertions(+), 43 deletions(-) diff --git a/packages/neuron-wallet/src/env.ts b/packages/neuron-wallet/src/env.ts index ee9d20fa0e..15695ddfcf 100644 --- a/packages/neuron-wallet/src/env.ts +++ b/packages/neuron-wallet/src/env.ts @@ -57,8 +57,4 @@ const env: ENV = { isTestMode, } -export const isRenderer = () => { - return process && process.type === 'renderer' -} - export default env diff --git a/packages/neuron-wallet/src/services/sync/block-listener.ts b/packages/neuron-wallet/src/services/sync/block-listener.ts index 2a0ffa1fa9..a770bf34dd 100644 --- a/packages/neuron-wallet/src/services/sync/block-listener.ts +++ b/packages/neuron-wallet/src/services/sync/block-listener.ts @@ -1,11 +1,9 @@ -import { remote } from 'electron' import { BehaviorSubject } from 'rxjs' import NodeService from '../node' import Queue from './queue' import RangeForCheck from './range-for-check' import BlockNumber from './block-number' import Utils from './utils' -import { isRenderer } from '../../env' export default class BlockListener { private lockHashes: string[] @@ -23,17 +21,11 @@ export default class BlockListener { this.currentBlockNumber = new BlockNumber() this.rangeForCheck = new RangeForCheck() - const tipNumberListener = tipNumberSubject.subscribe(async num => { + tipNumberSubject.subscribe(async num => { if (num) { this.tipBlockNumber = parseInt(num, 10) } }) - - // should unsubscribe if renderer window closed - if (isRenderer()) { - const { onCloseEvent } = remote.require('./startup/sync-block-task/create') - onCloseEvent(remote.getCurrentWindow(), tipNumberListener) - } } public setLockHashes = (lockHashes: string[]) => { diff --git a/packages/neuron-wallet/src/services/sync/get-blocks.ts b/packages/neuron-wallet/src/services/sync/get-blocks.ts index d70af2fa3b..a4bbf94883 100644 --- a/packages/neuron-wallet/src/services/sync/get-blocks.ts +++ b/packages/neuron-wallet/src/services/sync/get-blocks.ts @@ -1,4 +1,3 @@ -import { remote } from 'electron' import Core from '@nervosnetwork/ckb-sdk-core' import { Block } from '../../types/cell-types' @@ -9,17 +8,13 @@ import Utils from './utils' import { networkSwitchSubject } from './renderer-params' -const { onCloseEvent } = remote.require('./startup/sync-block-task/create') - let core: Core -const networkSwitchListener = networkSwitchSubject.subscribe((network: NetworkWithID | undefined) => { +networkSwitchSubject.subscribe((network: NetworkWithID | undefined) => { if (network) { core = new Core(network.remote) } }) -onCloseEvent(remote.getCurrentWindow(), networkSwitchListener) - export default class GetBlocks { private retryTime: number private retryInterval: number diff --git a/packages/neuron-wallet/src/startup/sync-block-task/create.ts b/packages/neuron-wallet/src/startup/sync-block-task/create.ts index d8a381c8b4..d9724cf2a1 100644 --- a/packages/neuron-wallet/src/startup/sync-block-task/create.ts +++ b/packages/neuron-wallet/src/startup/sync-block-task/create.ts @@ -1,5 +1,5 @@ import { BrowserWindow } from 'electron' -import { ReplaySubject, Subscription } from 'rxjs' +import { ReplaySubject } from 'rxjs' import path from 'path' import { networkSwitchSubject, NetworkWithID } from '../../services/networks' import env from '../../env' @@ -54,16 +54,9 @@ const createSyncBlockTask = () => { syncBlockBackgroundWindow.on('closed', () => { syncBlockBackgroundWindow = null - createSyncBlockTask() }) return syncBlockBackgroundWindow } -export const onCloseEvent = (window: BrowserWindow, listener: Subscription) => { - window.once('close', () => { - listener.unsubscribe() - }) -} - export default createSyncBlockTask diff --git a/packages/neuron-wallet/src/startup/sync-block-task/task.ts b/packages/neuron-wallet/src/startup/sync-block-task/task.ts index 7498ded889..2e8503264a 100644 --- a/packages/neuron-wallet/src/startup/sync-block-task/task.ts +++ b/packages/neuron-wallet/src/startup/sync-block-task/task.ts @@ -1,5 +1,5 @@ import { remote } from 'electron' -import { Subject, Subscription } from 'rxjs' +import { Subject } from 'rxjs' import { initConnection as initAddressConnection } from '../../database/address/ormconfig' import AddressService from '../../services/addresses' import LockUtils from '../../models/lock-utils' @@ -10,13 +10,6 @@ import { initDatabase } from './init-database' import { register as registerTxStatusListener } from '../../listeners/tx-status' import Utils from '../../services/sync/utils' -const { onCloseEvent } = remote.require('./startup/sync-block-task/create') -const currentWindow = remote.getCurrentWindow() - -const closeListener = (listener: Subscription) => { - onCloseEvent(currentWindow, listener) -} - const { nodeService, addressDbChangedSubject, @@ -54,7 +47,7 @@ export const switchNetwork = async () => { // start sync blocks service let blockListener = new BlockListener(lockHashes, nodeService.tipNumberSubject) - const addressDBChangedListener = addressDbChangedSubject.subscribe(async (event: string) => { + addressDbChangedSubject.subscribe(async (event: string) => { // ignore update and remove if (event === 'AfterInsert') { const hashes: string[] = await loadAddressesAndConvert() @@ -62,15 +55,13 @@ export const switchNetwork = async () => { } }) - closeListener(addressDBChangedListener) - const regenerateListener = async () => { const hashes: string[] = await loadAddressesAndConvert() blockListener = new BlockListener(hashes, nodeService.tipNumberSubject) await blockListener.start(true) } - const walletCreatedListener = walletCreatedSubject.subscribe(async (type: string) => { + walletCreatedSubject.subscribe(async (type: string) => { if (type === 'import') { await blockListener.stop() // wait former queue to be drained @@ -79,8 +70,6 @@ export const switchNetwork = async () => { } }) - closeListener(walletCreatedListener) - stopLoopSubject.subscribe(() => { blockListener.stop() }) @@ -90,12 +79,11 @@ export const switchNetwork = async () => { export const run = async () => { await initAddressConnection() - const dbInitListener = databaseInitSubject.subscribe(async (network: NetworkWithID | undefined) => { + databaseInitSubject.subscribe(async (network: NetworkWithID | undefined) => { if (network) { await switchNetwork() } }) - closeListener(dbInitListener) registerTxStatusListener() } From f2f792d8bdae2a028004be1694a2edcaa8520eb2 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 25 Jul 2019 09:25:31 +0900 Subject: [PATCH 19/20] feat: Make Windows installer as assisted installer --- packages/neuron-wallet/electron-builder.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/neuron-wallet/electron-builder.yml b/packages/neuron-wallet/electron-builder.yml index 522ea86ab6..95baa45b15 100644 --- a/packages/neuron-wallet/electron-builder.yml +++ b/packages/neuron-wallet/electron-builder.yml @@ -1,5 +1,5 @@ appId: com.nervos.neuron -copyright: Copyright (C) 2019 Nervos Foundation. All rights reserved +copyright: Copyright (C) 2019 Nervos Foundation. productName: Neuron asar: true @@ -30,8 +30,10 @@ files: to: "node_modules/escape-string-regexp" nsis: + oneClick: false createDesktopShortcut: always createStartMenuShortcut: true + runAfterFinish: false dmg: sign: false @@ -39,6 +41,7 @@ dmg: win: artifactName: "${productName}-v${version}-${os}-${arch}-installer.${ext}" icon: assets/images/icon.ico + publisherName: Nervos Foundation target: - target: nsis arch: From 2ec6c306ef2c05e8e667ed4dbbb71f7002c88a94 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 25 Jul 2019 11:15:09 +0900 Subject: [PATCH 20/20] chore: Releasing v0.1.0-alpha.15 --- lerna.json | 2 +- package.json | 2 +- packages/neuron-ui/package.json | 2 +- packages/neuron-wallet/package.json | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lerna.json b/lerna.json index 240d344a7c..490e98f423 100644 --- a/lerna.json +++ b/lerna.json @@ -2,7 +2,7 @@ "packages": [ "packages/*" ], - "version": "0.1.0-alpha.14", + "version": "0.1.0-alpha.15", "npmClient": "yarn", "useWorkspaces": true } diff --git a/package.json b/package.json index 67898d60c7..d8ba39bbd9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@nervosnetwork/neuron", "productName": "Neuron", "description": "CKB Neuron Wallet", - "version": "0.1.0-alpha.14", + "version": "0.1.0-alpha.15", "private": true, "author": { "name": "Nervos Core Dev", diff --git a/packages/neuron-ui/package.json b/packages/neuron-ui/package.json index 007fc1c150..d3dd5a2009 100644 --- a/packages/neuron-ui/package.json +++ b/packages/neuron-ui/package.json @@ -1,6 +1,6 @@ { "name": "@nervosnetwork/neuron-ui", - "version": "0.1.0-alpha.14", + "version": "0.1.0-alpha.15", "private": true, "author": { "name": "Nervos Core Dev", diff --git a/packages/neuron-wallet/package.json b/packages/neuron-wallet/package.json index 53e54a65da..1947ebaf3c 100644 --- a/packages/neuron-wallet/package.json +++ b/packages/neuron-wallet/package.json @@ -3,7 +3,7 @@ "productName": "Neuron", "description": "CKB Neuron Wallet", "homepage": "https://www.nervos.org/", - "version": "0.1.0-alpha.14", + "version": "0.1.0-alpha.15", "private": true, "author": { "name": "Nervos Core Dev", @@ -48,7 +48,7 @@ }, "devDependencies": { "@nervosnetwork/ckb-types": "0.15.1", - "@nervosnetwork/neuron-ui": "0.1.0-alpha.14", + "@nervosnetwork/neuron-ui": "0.1.0-alpha.15", "@types/async": "3.0.0", "@types/electron-devtools-installer": "2.2.0", "@types/elliptic": "6.4.8",