Skip to content

Commit 4dcdad4

Browse files
committed
feat: Remove miner info feature
1 parent 07dc1b3 commit 4dcdad4

6 files changed

Lines changed: 6 additions & 143 deletions

File tree

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

Lines changed: 4 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
import React, { useState, useCallback, useMemo } from 'react'
1+
import React, { useCallback } from 'react'
22
import { RouteComponentProps } from 'react-router-dom'
33
import { useTranslation } from 'react-i18next'
4-
import {
5-
Stack,
6-
PrimaryButton,
7-
ChoiceGroup,
8-
IChoiceGroupOption,
9-
Text,
10-
Callout,
11-
MessageBar,
12-
MessageBarType,
13-
ActionButton,
14-
getTheme,
15-
} from 'office-ui-fabric-react'
4+
import { Stack, PrimaryButton, ChoiceGroup, IChoiceGroupOption } from 'office-ui-fabric-react'
165

176
import { StateWithDispatch } from 'states/stateProvider/reducer'
18-
import { setCurrentWallet, addPopup } from 'states/stateProvider/actionCreators'
7+
import { setCurrentWallet } from 'states/stateProvider/actionCreators'
198

209
import { WalletWizardPath } from 'components/WalletWizard'
2110

2211
import { contextMenu } from 'services/remote'
23-
import { Routes, MnemonicAction, ErrorCode } from 'utils/const'
24-
25-
const theme = getTheme()
12+
import { Routes, MnemonicAction } from 'utils/const'
2613

2714
const buttons = [
2815
{
@@ -41,33 +28,11 @@ const buttons = [
4128

4229
const WalletSetting = ({
4330
wallet: { id: currentID = '' },
44-
chain: { codeHash = '' },
4531
settings: { wallets = [] },
4632
dispatch,
4733
history,
4834
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {
4935
const [t] = useTranslation()
50-
const [target, setTarget] = useState<any>(null)
51-
const [minerInfo, setMinerInfo] = useState<{ address: string; identifier: string }>({
52-
address: '',
53-
identifier: '',
54-
})
55-
56-
const [showMinerInfo, hideMinerInfo] = useMemo(
57-
() => [
58-
(info: { address: string; identifier: string }) => setMinerInfo(info),
59-
() => setMinerInfo({ address: '', identifier: '' }),
60-
],
61-
[setMinerInfo]
62-
)
63-
64-
const onCopyPubkeyHash = useCallback(() => {
65-
if (minerInfo) {
66-
window.navigator.clipboard.writeText(minerInfo.identifier)
67-
hideMinerInfo()
68-
addPopup('lock-arg-copied')(dispatch)
69-
}
70-
}, [minerInfo, hideMinerInfo, dispatch])
7136

7237
const onChange = useCallback(
7338
(_e, option) => {
@@ -105,24 +70,6 @@ const WalletSetting = ({
10570
<span className="ms-ChoiceFieldLabel" onContextMenu={onContextMenu(wallet.id)}>
10671
{text}
10772
</span>
108-
{wallet.minerAddress ? (
109-
<Text
110-
variant="tiny"
111-
className="ms-ChoiceFieldLabel"
112-
onClick={(e: React.MouseEvent<HTMLDivElement>) => {
113-
e.preventDefault()
114-
setTarget(e.target)
115-
if (wallet.minerAddress) {
116-
showMinerInfo(wallet.minerAddress)
117-
}
118-
}}
119-
styles={{
120-
root: [{ color: theme.semanticColors.bodySubtext, fontSize: '12px!important' }],
121-
}}
122-
>
123-
{t('overview.miner-info')}
124-
</Text>
125-
) : null}
12673
</Stack>
12774
)
12875
},
@@ -135,47 +82,6 @@ const WalletSetting = ({
13582
<PrimaryButton key={label} onClick={navTo(url)} text={t(label)} />
13683
))}
13784
</Stack>
138-
<Callout target={target} hidden={!minerInfo.address} onDismiss={hideMinerInfo} gapSpace={0}>
139-
<Stack tokens={{ padding: 15 }}>
140-
{minerInfo.address ? (
141-
<Stack tokens={{ childrenGap: 15 }} styles={{ root: { padding: 5 } }}>
142-
<Stack tokens={{ childrenGap: 15 }}>
143-
<Text variant="small" style={{ fontWeight: 600 }}>
144-
{t('overview.address')}
145-
</Text>
146-
<Text variant="small" className="monospacedFont">
147-
{minerInfo.address}
148-
</Text>
149-
</Stack>
150-
<Stack tokens={{ childrenGap: 15 }}>
151-
<Text variant="small" style={{ fontWeight: 600 }}>
152-
{t('overview.code-hash')}
153-
</Text>
154-
<Text variant="small" className="monospacedFont">
155-
{codeHash}
156-
</Text>
157-
</Stack>
158-
<Stack tokens={{ childrenGap: 15 }}>
159-
<Text variant="small" style={{ fontWeight: 600 }}>
160-
{t('overview.lock-arg')}
161-
</Text>
162-
<Text variant="small" className="monospacedFont">
163-
{minerInfo.identifier}
164-
</Text>
165-
</Stack>
166-
<Stack horizontalAlign="end">
167-
<ActionButton iconProps={{ iconName: 'MiniCopy' }} onClick={onCopyPubkeyHash}>
168-
{t('overview.copy-pubkey-hash')}
169-
</ActionButton>
170-
</Stack>
171-
</Stack>
172-
) : (
173-
<MessageBar messageBarType={MessageBarType.error}>
174-
{t(`messages.codes.${ErrorCode.FieldNotFound}`, { fieldName: `default-address` })}
175-
</MessageBar>
176-
)}
177-
</Stack>
178-
</Callout>
17985
</Stack>
18086
)
18187
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@
2525
"tip-block-number": "Block Number",
2626
"epoch": "Epoch",
2727
"difficulty": "Difficulty",
28-
"miner-info": "Miner Info",
29-
"lock-arg": "Lock Arg",
3028
"address": "Address",
31-
"code-hash": "Code Hash",
32-
"copy-pubkey-hash": "Copy Lock Arg (Pubkey Hash)",
3329
"confirmation": "{{confirmationCount}} Confirmation",
3430
"confirmations": "{{confirmationCount}} Confirmations",
3531
"sent": "Sent",
@@ -260,7 +256,6 @@
260256
"update-network-successfully": "The network was updated",
261257
"addr-copied": "Address has been copied to the clipboard",
262258
"qrcode-copied": "QR Code has been copied to the clipboard",
263-
"lock-arg-copied": "Lock Arg has been copied to the clipboard",
264259
"fields": {
265260
"wallet": "Wallet",
266261
"name": "Name",

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@
2525
"tip-block-number": "区块高度",
2626
"epoch": "Epoch",
2727
"difficulty": "难度",
28-
"miner-info": "挖矿信息",
29-
"lock-arg": "Lock Arg",
3028
"address": "地址",
31-
"code-hash": "Code Hash",
32-
"copy-pubkey-hash": "复制 Lock Arg (Pubkey Hash)",
3329
"confirmation": "{{confirmationCount}} 个确认",
3430
"confirmations": "{{confirmationCount}} 个确认",
3531
"sent": "已发送",
@@ -260,7 +256,6 @@
260256
"update-network-successfully": "已更新节点信息",
261257
"addr-copied": "已复制地址到剪贴板",
262258
"qrcode-copied": "已复制二维码到剪贴板",
263-
"lock-arg-copied": "已复制 Lock Arg 到剪贴板",
264259
"fields": {
265260
"wallet": "钱包",
266261
"name": "名称",

packages/neuron-ui/src/types/App/index.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ declare namespace State {
112112
interface WalletIdentity {
113113
id: string
114114
name: string
115-
minerAddress?: { address: string; identifier: string }
116115
}
117116

118117
interface Address {

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,6 @@ export default class ApiController {
6969
}),
7070
])
7171

72-
const minerAddresses = await Promise.all(
73-
wallets.map(({ id }) =>
74-
WalletsController.getAllAddresses(id).then(addrRes => {
75-
if (addrRes.result) {
76-
const minerAddr = addrRes.result.find(addr => addr.type === 0 && addr.index === 0)
77-
if (minerAddr) {
78-
return {
79-
address: minerAddr.address,
80-
identifier: minerAddr.identifier,
81-
}
82-
}
83-
}
84-
return undefined
85-
}),
86-
),
87-
)
8872
const addresses: Controller.Address[] = await (currentWallet
8973
? WalletsController.getAllAddresses(currentWallet.id).then(res => res.result)
9074
: [])
@@ -102,7 +86,7 @@ export default class ApiController {
10286

10387
const initState = {
10488
currentWallet,
105-
wallets: [...wallets.map(({ name, id }, idx: number) => ({ id, name, minerAddress: minerAddresses[idx] }))],
89+
wallets: [...wallets.map(({ name, id }) => ({ id, name }))],
10690
currentNetworkID,
10791
networks,
10892
addresses,

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,9 @@ export default class WalletsController {
2828
if (!wallets) {
2929
throw new ServiceHasNoResponse('Wallet')
3030
}
31-
const minerAddresses = await Promise.all(
32-
wallets.map(({ id }) =>
33-
WalletsController.getAllAddresses(id).then(addrRes => {
34-
if (addrRes.result) {
35-
const minerAddr = addrRes.result.find(addr => addr.type === 0 && addr.index === 0)
36-
if (minerAddr) {
37-
return {
38-
address: minerAddr.address,
39-
identifier: minerAddr.identifier,
40-
}
41-
}
42-
}
43-
return undefined
44-
})
45-
)
46-
)
4731
return {
4832
status: ResponseCode.Success,
49-
result: wallets.map(({ name, id }, idx) => ({ name, id, minerAddress: minerAddresses[idx] })),
33+
result: wallets.map(({ name, id }) => ({ name, id })),
5034
}
5135
}
5236

0 commit comments

Comments
 (0)