Skip to content

Commit d75a887

Browse files
authored
Merge pull request #715 from nervosnetwork/rc/v0.1.0-alpha.13
[ᚬmaster] Rc/v0.1.0 alpha.13
2 parents 95a10b9 + ac7732f commit d75a887

File tree

26 files changed

+191
-451
lines changed

26 files changed

+191
-451
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "0.1.0-alpha.12",
5+
"version": "0.1.0-alpha.13",
66
"npmClient": "yarn",
77
"useWorkspaces": true
88
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@nervosnetwork/neuron",
33
"productName": "Neuron",
44
"description": "CKB Neuron Wallet",
5-
"version": "0.1.0-alpha.12",
5+
"version": "0.1.0-alpha.13",
66
"private": true,
77
"author": {
88
"name": "Nervos Core Dev",

packages/neuron-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nervosnetwork/neuron-ui",
3-
"version": "0.1.0-alpha.12",
3+
"version": "0.1.0-alpha.13",
44
"private": true,
55
"author": {
66
"name": "Nervos Core Dev",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { appCalls } from 'services/UILayer'
1717

1818
import { useLocalDescription } from 'utils/hooks'
1919
import { MIN_CELL_WIDTH, Routes } from 'utils/const'
20-
import { shannonToCKBFormatter } from 'utils/formatters'
20+
import { localNumberFormatter, shannonToCKBFormatter } from 'utils/formatters'
2121

2222
const Addresses = ({
2323
wallet: { id, addresses = [] },
@@ -150,7 +150,7 @@ const Addresses = ({
150150
isCollapsible: false,
151151
onRender: (item?: State.Address) => {
152152
if (item) {
153-
return (+item.txCount).toLocaleString()
153+
return localNumberFormatter(item.txCount)
154154
}
155155
return '-'
156156
},

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

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import React, { useState, useCallback, useMemo, useEffect, useRef } from 'react'
22
import { RouteComponentProps } from 'react-router-dom'
33
import { useTranslation } from 'react-i18next'
4+
import { Copy } from 'grommet-icons'
45
import {
56
Stack,
67
Text,
8+
ActionButton,
79
DefaultButton,
810
DetailsList,
911
DetailsRow,
@@ -15,13 +17,24 @@ import {
1517
IDetailsRowStyles,
1618
FontSizes,
1719
Callout,
20+
MessageBar,
21+
MessageBarType,
1822
} from 'office-ui-fabric-react'
1923

2024
import { StateWithDispatch } from 'states/stateProvider/reducer'
2125
import actionCreators from 'states/stateProvider/actionCreators'
2226

27+
import { showErrorMessage } from 'services/remote'
28+
2329
import { localNumberFormatter, shannonToCKBFormatter } from 'utils/formatters'
2430
import { PAGE_SIZE, MIN_CELL_WIDTH } from 'utils/const'
31+
import { registerIcons } from 'utils/icons'
32+
33+
registerIcons({
34+
icons: {
35+
Copy: <Copy size="small" />,
36+
},
37+
})
2538

2639
const timeFormatter = new Intl.DateTimeFormat(undefined, {
2740
year: 'numeric',
@@ -82,8 +95,9 @@ const PropertyList = ({
8295
const Overview = ({
8396
dispatch,
8497
app: { tipBlockNumber, chain, epoch, difficulty },
85-
wallet: { id, name, balance = '' },
98+
wallet: { id, name, balance = '', addresses = [] },
8699
chain: {
100+
codeHash = '',
87101
transactions: { items = [] },
88102
},
89103
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {
@@ -252,7 +266,7 @@ const Overview = ({
252266
},
253267
{
254268
label: t('overview.difficulty'),
255-
value: difficulty,
269+
value: localNumberFormatter(+difficulty),
256270
},
257271
],
258272
[t, chain, epoch, difficulty, tipBlockNumber]
@@ -271,6 +285,20 @@ const Overview = ({
271285
setDisplayMinerInfo(false)
272286
}, [setDisplayMinerInfo])
273287

288+
const defaultAddress = useMemo(() => {
289+
return addresses.find(addr => addr.type === 0 && addr.index === 0)
290+
}, [addresses])
291+
292+
const onCopyPubkeyHash = useCallback(() => {
293+
if (defaultAddress) {
294+
window.navigator.clipboard.writeText(defaultAddress.identifier)
295+
hideMinerInfo()
296+
// TODO: Add notification
297+
} else {
298+
showErrorMessage(t('messages.error'), t('messages.can-not-find-the-default-address'))
299+
}
300+
}, [defaultAddress, t, hideMinerInfo])
301+
274302
return (
275303
<Stack tokens={{ childrenGap: 15 }} verticalFill horizontalAlign="stretch">
276304
<Text as="h1" variant={TITLE_FONT_SIZE}>
@@ -306,15 +334,46 @@ const Overview = ({
306334
onDismiss={hideBlockchainStatus}
307335
gapSpace={0}
308336
>
309-
<Stack>
337+
<Stack tokens={{ padding: 15 }}>
310338
<PropertyList columns={blockchainStatusColumns} items={blockchainStatusItems} isHeaderVisible={false} />
311339
</Stack>
312340
</Callout>
313341
) : null}
314-
{/* TODO: Implement this */}
315342
{minerInfoRef.current ? (
316343
<Callout target={minerInfoRef.current} hidden={!displayMinerInfo} onDismiss={hideMinerInfo} gapSpace={0}>
317-
{t('overview.miner-info')}
344+
<Stack tokens={{ padding: 15 }}>
345+
{defaultAddress ? (
346+
<Stack tokens={{ childrenGap: 15 }}>
347+
<Stack tokens={{ childrenGap: 15 }}>
348+
<Text variant="medium">{t('overview.address')}</Text>
349+
<Text variant="small" className="fixedWidth">
350+
{defaultAddress.address}
351+
</Text>
352+
</Stack>
353+
<Stack tokens={{ childrenGap: 15 }}>
354+
<Text variant="medium">{t('overview.code-hash')}</Text>
355+
<Text variant="small" className="fixedWidth">
356+
{codeHash}
357+
</Text>
358+
</Stack>
359+
<Stack tokens={{ childrenGap: 15 }}>
360+
<Text variant="medium">{t('overview.lock-arg')}</Text>
361+
<Text variant="small" className="fixedWidth">
362+
{defaultAddress.identifier}
363+
</Text>
364+
</Stack>
365+
<Stack horizontalAlign="end">
366+
<ActionButton iconProps={{ iconName: 'Copy' }} onClick={onCopyPubkeyHash}>
367+
{t('overview.copy-pubkey-hash')}
368+
</ActionButton>
369+
</Stack>
370+
</Stack>
371+
) : (
372+
<MessageBar messageBarType={MessageBarType.error}>
373+
{t('messages.can-not-find-the-default-address')}
374+
</MessageBar>
375+
)}
376+
</Stack>
318377
</Callout>
319378
) : null}
320379
</Stack>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const Receive = ({
2323
)
2424

2525
const copyAddress = useCallback(() => {
26-
window.clipboard.writeText(accountAddress)
26+
window.navigator.clipboard.writeText(accountAddress)
2727
}, [accountAddress])
2828

2929
if (!accountAddress) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useCallback } from 'react'
22
import { Route, RouteComponentProps } from 'react-router-dom'
33
import { useTranslation } from 'react-i18next'
4-
import { Stack, Pivot, PivotItem, IconButton } from 'office-ui-fabric-react'
4+
import { Stack, Pivot, PivotItem, IconButton, Text } from 'office-ui-fabric-react'
55
import { FormPreviousLink } from 'grommet-icons'
66

77
import { StateWithDispatch } from 'states/stateProvider/reducer'
@@ -54,12 +54,12 @@ const Settings = ({
5454
<Stack tokens={{ childrenGap: 15 }}>
5555
<Stack horizontal>
5656
<Stack.Item align="center">
57-
<IconButton onClick={goToOverview}>
57+
<IconButton onClick={goToOverview} styles={{ root: { marginRight: 20 } }}>
5858
<FormPreviousLink />
5959
</IconButton>
6060
</Stack.Item>
6161
<Stack.Item align="center">
62-
<h1>{t('navbar.settings')}</h1>
62+
<Text variant="xLarge" as="h1">{t('navbar.settings')}</Text>
6363
</Stack.Item>
6464
</Stack>
6565

packages/neuron-ui/src/containers/Main/hooks.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
addresses as addressesCache,
2525
currentNetworkID as currentNetworkIDCache,
2626
currentWallet as currentWalletCache,
27+
systemScript as systemScriptCache,
2728
} from 'utils/localCache'
2829

2930
let timer: NodeJS.Timeout
@@ -116,6 +117,7 @@ export const useChannelListeners = ({
116117
locale: string
117118
tipNumber: string
118119
connectStatus: boolean
120+
codeHash: string
119121
}>
120122
) => {
121123
if (args.status) {
@@ -129,6 +131,7 @@ export const useChannelListeners = ({
129131
transactions = initStates.chain.transactions,
130132
tipNumber = '0',
131133
connectStatus = false,
134+
codeHash = '',
132135
} = args.result
133136
if (locale !== i18n.language) {
134137
i18n.changeLanguage(locale)
@@ -148,6 +151,7 @@ export const useChannelListeners = ({
148151
type: NeuronWalletActions.Chain,
149152
payload: {
150153
tipBlockNumber: tipNumber,
154+
codeHash,
151155
connectStatus: connectStatus ? ConnectStatus.Online : ConnectStatus.Offline,
152156
transactions: { ...chain.transactions, ...transactions },
153157
},
@@ -158,6 +162,7 @@ export const useChannelListeners = ({
158162
walletsCache.save(wallets)
159163
addressesCache.save(addresses)
160164
networksCache.save(networks)
165+
systemScriptCache.save({ codeHash })
161166
} else {
162167
/* eslint-disable no-alert */
163168
// TODO: better prompt, prd required
@@ -207,6 +212,16 @@ export const useChannelListeners = ({
207212
})
208213
break
209214
}
215+
case ChainMethod.SystemScript: {
216+
const { codeHash = '' } = args.result
217+
dispatch({
218+
type: NeuronWalletActions.Chain,
219+
payload: {
220+
codeHash,
221+
},
222+
})
223+
break
224+
}
210225
default: {
211226
break
212227
}

packages/neuron-ui/src/locales/en.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
"tip-block-number": "Block Number",
2626
"epoch": "Epoch",
2727
"difficulty": "Difficulty",
28-
"miner-info": "Miner Info"
28+
"miner-info": "Miner Info",
29+
"lock-arg": "Lock Arg",
30+
"address": "Address",
31+
"code-hash": "Code Hash",
32+
"copy-pubkey-hash": "Copy Lock Arg (Pubkey Hash)",
33+
"can-not-find-the-default-address": "Cannot find the default address"
2934
},
3035
"wizard": {
3136
"welcome-to-nervos-neuron": "Welcome to Neuron",

packages/neuron-ui/src/locales/zh.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
"tip-block-number": "区块高度",
2626
"epoch": "Epoch",
2727
"difficulty": "难度",
28-
"miner-info": "挖矿信息"
28+
"miner-info": "挖矿信息",
29+
"lock-arg": "Lock Arg",
30+
"address": "地址",
31+
"code-hash": "Code Hash",
32+
"copy-pubkey-hash": "复制 Lock Arg (Pubkey Hash)",
33+
"can-not-find-the-default-address": "未获得默认地址"
2934
},
3035
"wizard": {
3136
"welcome-to-nervos-ckb": "欢迎使用 Neuron",
@@ -71,7 +76,7 @@
7176
"receive": {
7277
"click-to-copy": "点击复制地址",
7378
"address-not-found": "未找到地址",
74-
"prompt": "为了保护隐私,Neuron 会怎么选择一个新收款地址。如果您想使用旧的收款地址,请访问地址管理页面。",
79+
"prompt": "为了保护隐私,Neuron 会自动选择一个新收款地址。如果您想使用旧的收款地址,请访问地址管理页面。",
7580
"address-qrcode": "地址二维码"
7681
},
7782
"history": {
@@ -209,7 +214,8 @@
209214
"wallet-not-found": "未找到钱包",
210215
"no-transactions": "没有交易",
211216
"error": "错误",
212-
"invalid-mnemonic": "助记词不合法"
217+
"invalid-mnemonic": "助记词不合法",
218+
"can-not-find-the-default-address": "找不到默认地址"
213219
},
214220
"sync": {
215221
"syncing": "同步中",

0 commit comments

Comments
 (0)