Skip to content

Commit 247c1a1

Browse files
authored
Merge pull request #1028 from nervosnetwork/rc/v0.23.1
[ᚬmaster] Rc/v0.23.1
2 parents 52de35d + f53e258 commit 247c1a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+462
-481
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
## [0.23.1](https://github.com/nervosnetwork/neuron/compare/v0.23.0...v0.23.1) (2019-10-28)
2+
3+
4+
### Bug Fixes
5+
6+
* break => continue ([05ae69e](https://github.com/nervosnetwork/neuron/commit/05ae69e))
7+
* return => break ([97b8ea4](https://github.com/nervosnetwork/neuron/commit/97b8ea4))
8+
9+
10+
### Features
11+
12+
* Add a few db indices ([83dffb5](https://github.com/nervosnetwork/neuron/commit/83dffb5))
13+
* display disconnection errors and dismiss them on getting connec… ([#1019](https://github.com/nervosnetwork/neuron/issues/1019)) ([e866c66](https://github.com/nervosnetwork/neuron/commit/e866c66))
14+
* Optimize output db query ([6e36550](https://github.com/nervosnetwork/neuron/commit/6e36550))
15+
* stringify the result from api controller ([1f4d4ea](https://github.com/nervosnetwork/neuron/commit/1f4d4ea))
16+
* **neuron-ui:** add a tooltip to display synchronized block number and the tip block number ([9e52fef](https://github.com/nervosnetwork/neuron/commit/9e52fef))
17+
* **neuron-ui:** display confirmations of pending transactions in the recent activity list ([9aebede](https://github.com/nervosnetwork/neuron/commit/9aebede))
18+
* **neuron-ui:** update history list to make it more compact ([35d8b87](https://github.com/nervosnetwork/neuron/commit/35d8b87))
19+
* **neuron-ui:** update the Send View according to the new transaction fee model. ([dc415f3](https://github.com/nervosnetwork/neuron/commit/dc415f3))
20+
21+
22+
123
# [0.23.0](https://github.com/nervosnetwork/neuron/compare/v0.22.2...v0.23.0) (2019-10-23)
224

325

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.23.0",
5+
"version": "0.23.1",
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": "neuron",
33
"productName": "Neuron",
44
"description": "CKB Neuron Wallet",
5-
"version": "0.23.0",
5+
"version": "0.23.1",
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": "neuron-ui",
3-
"version": "0.23.0",
3+
"version": "0.23.1",
44
"private": true,
55
"author": {
66
"name": "Nervos Core Dev",

packages/neuron-ui/src/components/CustomRows/ActivityRow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ const ActivityRow = (props?: ActivityRowProps) => {
3434
return (
3535
<div
3636
className={`${styles.activityRow} ${styles[status]}`}
37-
title={`${hash}: ${description}`}
37+
title={`${hash}: ${description || ''}`}
3838
onDoubleClick={onDoubleClick}
3939
>
4040
<div className={styles.action}>{`${typeLabel} ${shannonToCKBFormatter(value)} CKB`}</div>
4141
<div className={styles.status}>{statusLabel}</div>
4242
<div className={styles.time}>{time}</div>
43-
<div className={styles.meta}>{status === 'success' ? confirmations : ''}</div>
43+
<div className={styles.meta}>{confirmations}</div>
4444
</div>
4545
)
4646
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react'
2+
import { Stack, Text, getTheme } from 'office-ui-fabric-react'
3+
4+
const {
5+
palette: { neutralLighterAlt, neutralSecondary, neutralLighter },
6+
} = getTheme()
7+
8+
const GroupHeader = ({ group }: any) => {
9+
const { name } = group
10+
return (
11+
<Stack
12+
tokens={{ padding: 15 }}
13+
styles={{
14+
root: {
15+
background: neutralLighterAlt,
16+
borderTop: `1px solid ${neutralSecondary}`,
17+
borderBottom: `1px solid ${neutralLighter}`,
18+
padding: `15px 12px 5px`,
19+
minWidth: '100%!important',
20+
},
21+
}}
22+
>
23+
<Text variant="medium">{name}</Text>
24+
</Stack>
25+
)
26+
}
27+
export default GroupHeader
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react'
2+
import { DetailsRow, IDetailsRowProps } from 'office-ui-fabric-react'
3+
4+
const HistoryRow = (props?: IDetailsRowProps) => {
5+
return props ? (
6+
<DetailsRow
7+
{...props}
8+
styles={{
9+
root: {
10+
animationDuration: '0!important',
11+
minWidth: '100%!important',
12+
},
13+
cell: {
14+
paddingTop: 0,
15+
paddingBottom: 0,
16+
},
17+
}}
18+
/>
19+
) : null
20+
}
21+
22+
export default HistoryRow

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const Overview = ({
118118
const activityItems: ActivityItem[] = useMemo(
119119
() =>
120120
items.map(item => {
121-
let confirmations = '(-)'
121+
let confirmations = ''
122122
let typeLabel: string = item.type
123123
let { status } = item
124124
if (item.blockNumber !== undefined) {
@@ -147,7 +147,7 @@ const Overview = ({
147147
status,
148148
statusLabel: t(`overview.statusLabel.${status}`),
149149
value: item.value.replace(/^-/, ''),
150-
confirmations: item.status === 'success' ? confirmations : '',
150+
confirmations: ['success', 'pending'].includes(item.status) ? confirmations : '',
151151
typeLabel: t(`overview.${typeLabel}`),
152152
}
153153
}),

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import { useTranslation } from 'react-i18next'
44
import { Stack, Text, Label, Modal, TextField, PrimaryButton, DefaultButton } from 'office-ui-fabric-react'
55
import { StateWithDispatch, AppActions } from 'states/stateProvider/reducer'
66
import { sendTransaction, deleteWallet, backupWallet } from 'states/stateProvider/actionCreators'
7-
import { priceToFee, CKBToShannonFormatter } from 'utils/formatters'
87

98
const PasswordRequest = ({
109
app: {
11-
send: { txID, outputs, description, price, cycles },
10+
send: { description, generatedTx },
1211
loadings: { sending: isSending = false },
1312
passwordRequest: { walletID = '', actionType = null, password = '' },
1413
},
@@ -32,15 +31,10 @@ const PasswordRequest = ({
3231
break
3332
}
3433
sendTransaction({
35-
id: txID,
3634
walletID,
37-
items: outputs.map(output => ({
38-
address: output.address,
39-
capacity: CKBToShannonFormatter(output.amount, output.unit),
40-
})),
35+
tx: generatedTx,
4136
description,
4237
password,
43-
fee: priceToFee(price, cycles),
4438
})(dispatch, history)
4539
break
4640
}
@@ -62,7 +56,7 @@ const PasswordRequest = ({
6256
break
6357
}
6458
}
65-
}, [dispatch, walletID, password, actionType, txID, description, outputs, cycles, price, history, isSending])
59+
}, [dispatch, walletID, password, actionType, description, history, isSending, generatedTx])
6660

6761
const onChange = useCallback(
6862
(_e, value?: string) => {

packages/neuron-ui/src/components/Send/hooks.ts

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import React, { useState, useCallback, useEffect, useMemo } from 'react'
22

33
import { AppActions, StateDispatch } from 'states/stateProvider/reducer'
4-
import { calculateCycles } from 'services/remote/wallets'
4+
import { generateTx } from 'services/remote/wallets'
55

6-
import { outputsToTotalAmount, priceToFee } from 'utils/formatters'
6+
import { outputsToTotalAmount, CKBToShannonFormatter } from 'utils/formatters'
77
import { verifyAddress, verifyAmount, verifyAmountRange, verifyTransactionOutputs } from 'utils/validators'
8-
import { ErrorCode } from 'utils/const'
9-
import { MAX_DECIMAL_DIGITS } from '../../utils/const'
8+
import { ErrorCode, MAX_DECIMAL_DIGITS } from 'utils/const'
9+
import calculateFee from 'utils/calculateFee'
10+
1011
import { TransactionOutput } from '.'
1112

12-
let cyclesTimer: ReturnType<typeof setTimeout>
13+
let generateTxTimer: ReturnType<typeof setTimeout>
1314

1415
const useUpdateTransactionOutput = (dispatch: StateDispatch) =>
1516
useCallback(
@@ -49,49 +50,47 @@ const useRemoveTransactionOutput = (dispatch: StateDispatch) =>
4950
const useOnTransactionChange = (
5051
walletID: string,
5152
items: TransactionOutput[],
53+
price: string,
5254
dispatch: StateDispatch,
5355
setIsTransactionValid: Function,
5456
setTotalAmount: Function
5557
) => {
5658
useEffect(() => {
57-
clearTimeout(cyclesTimer)
58-
cyclesTimer = setTimeout(() => {
59+
clearTimeout(generateTxTimer)
60+
generateTxTimer = setTimeout(() => {
61+
dispatch({
62+
type: AppActions.UpdateGeneratedTx,
63+
payload: null,
64+
})
5965
if (verifyTransactionOutputs(items)) {
6066
setIsTransactionValid(true)
6167
const totalAmount = outputsToTotalAmount(items)
6268
setTotalAmount(totalAmount)
63-
calculateCycles({
69+
const realParams = {
6470
walletID,
65-
capacities: totalAmount,
66-
})
67-
.then(response => {
68-
if (response.status) {
69-
if (Number.isNaN(+response.result)) {
70-
throw new Error('Invalid Cycles')
71-
}
71+
items: items.map(item => ({
72+
address: item.address,
73+
capacity: CKBToShannonFormatter(item.amount, item.unit),
74+
})),
75+
feeRate: price,
76+
}
77+
generateTx(realParams)
78+
.then((res: any) => {
79+
if (res.status === 1) {
7280
dispatch({
73-
type: AppActions.UpdateSendCycles,
74-
payload: response.result,
81+
type: AppActions.UpdateGeneratedTx,
82+
payload: res.result,
7583
})
76-
} else {
77-
throw new Error('Cycles Not Calculated')
7884
}
7985
})
80-
.catch(() => {
81-
dispatch({
82-
type: AppActions.UpdateSendCycles,
83-
payload: '0',
84-
})
86+
.catch((err: Error) => {
87+
console.error(err)
8588
})
8689
} else {
8790
setIsTransactionValid(false)
88-
dispatch({
89-
type: AppActions.UpdateSendCycles,
90-
payload: '0',
91-
})
9291
}
9392
}, 300)
94-
}, [walletID, items, dispatch, setIsTransactionValid, setTotalAmount])
93+
}, [walletID, items, price, dispatch, setIsTransactionValid, setTotalAmount])
9594
}
9695

9796
const useOnSubmit = (items: TransactionOutput[], dispatch: StateDispatch) =>
@@ -170,12 +169,12 @@ const useClear = (dispatch: StateDispatch) => useCallback(() => clear(dispatch),
170169

171170
export const useInitialize = (
172171
items: TransactionOutput[],
173-
price: string,
174-
cycles: string,
172+
generatedTx: any | null,
175173
dispatch: React.Dispatch<any>,
176174
t: any
177175
) => {
178-
const fee = useMemo(() => priceToFee(price, cycles), [price, cycles]) // in shannon
176+
const fee = useMemo(() => calculateFee(generatedTx), [generatedTx])
177+
179178
const [isTransactionValid, setIsTransactionValid] = useState(false)
180179
const [totalAmount, setTotalAmount] = useState('0')
181180

0 commit comments

Comments
 (0)