Skip to content

Commit a563a02

Browse files
authored
Merge pull request #1448 from nervosnetwork/rc/v0.29.0
[ᚬmaster] Rc/v0.29.0
2 parents 5fc2686 + fd07961 commit a563a02

File tree

36 files changed

+668
-255
lines changed

36 files changed

+668
-255
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
# 0.29.0-rc2 (2020-03-10)
2+
3+
This is an RC version to preview the changes in the next release.
4+
5+
### Bundled CKB node
6+
7+
CKB v0.29.0 was released on Feb 26th, 2020. This version of CKB node is now bundled and preconfigured in Neuron.
8+
9+
### New features
10+
11+
We added several new features with this version:
12+
13+
* Sign/Verify message: Sign a message with an address and its private key, or verify a signed message with an address and its public key.
14+
* Customized assets: List customized assets that have non-standard cells, e.g. cells with locktime. Holders with locked assets from the genesis block would be able to view them now.
15+
* Transaction with locktime: Send a transaction that could only be released after the locktime.
16+
17+
### Performance tweak
18+
19+
Thanks to the community we have found and fixed a serious performance issue. Miner wallets usually receive transactions with huge amount of inputs. When syncing this kind of wallets Neuron became very slow and unresponsive, and couldn't calculate the balance correctly. With this release we've tweaked the sync process, making it run faster and handle transactions with many inputs/outputs properly.
20+
21+
22+
123
# 0.29.0-rc1 (2020-03-02)
224

325
This is an RC version to preview the changes in the next release.

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.29.0-rc1",
5+
"version": "0.29.0-rc2",
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.29.0-rc1",
5+
"version": "0.29.0-rc2",
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.29.0-rc1",
3+
"version": "0.29.0-rc2",
44
"private": true,
55
"author": {
66
"name": "Nervos Core Dev",

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ import React, { useRef } from 'react'
22
import { useTranslation } from 'react-i18next'
33
import Button from 'widgets/Button'
44
import { useDialog } from 'utils/hooks'
5+
import { WITHDRAW_EPOCHS } from 'utils/const'
56

67
import styles from './compensationPeriodDialog.module.scss'
78

89
interface CompensationPeriodDialogProps {
910
onDismiss: () => void
1011
compensationPeriod: {
11-
currentEpochNumber: bigint
12-
currentEpochIndex: bigint
13-
currentEpochLength: bigint
14-
targetEpochNumber: bigint
12+
currentEpochValue: number
13+
targetEpochValue: number
1514
} | null
1615
}
1716

@@ -20,18 +19,11 @@ const CompensationPeriodDialog = ({ onDismiss, compensationPeriod }: Compensatio
2019
const dialogRef = useRef<HTMLDialogElement | null>(null)
2120
useDialog({ show: compensationPeriod, dialogRef, onClose: onDismiss })
2221

23-
let pastEpochs = 0
24-
if (compensationPeriod) {
25-
pastEpochs =
26-
Number(compensationPeriod.currentEpochNumber) -
27-
Number(compensationPeriod.targetEpochNumber) +
28-
180 +
29-
(compensationPeriod.currentEpochLength === BigInt(0)
30-
? 0
31-
: +(Number(compensationPeriod.currentEpochIndex) / Number(compensationPeriod.currentEpochLength)).toFixed(1))
32-
}
22+
const pastEpochs = compensationPeriod
23+
? +(compensationPeriod.currentEpochValue - compensationPeriod.targetEpochValue + WITHDRAW_EPOCHS).toFixed(1)
24+
: 0
3325

34-
const totalHours = Math.ceil((180 - pastEpochs) * 4)
26+
const totalHours = Math.ceil((WITHDRAW_EPOCHS - pastEpochs) * 4)
3527
const leftDays = Math.floor(totalHours / 24)
3628
const leftHours = totalHours % 24
3729

packages/neuron-ui/src/components/ImportKeystore/importKeystore.module.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
@import '../../styles/mixin.scss';
22

33
.container {
4-
height: 100%;
4+
position: absolute;
5+
top: 0;
6+
left: 30px;
7+
right: 30px;
8+
height: 100vh;
59
display: flex;
610
flex-direction: column;
711
justify-content: center;

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { TFunction } from 'i18next'
33
import { AppActions, StateAction } from 'states/stateProvider/reducer'
44
import { verifyAmount } from 'utils/validators'
55
import { epochParser } from 'utils/parsers'
6-
import calculateClaimEpochNumber from 'utils/calculateClaimEpochNumber'
6+
import calculateClaimEpochValue from 'utils/calculateClaimEpochValue'
77
import calculateAPC from 'utils/calculateAPC'
88
import { updateNervosDaoData, clearNervosDaoData } from 'states/stateProvider/actionCreators'
99

@@ -25,7 +25,7 @@ import {
2525
generateDaoDepositTx,
2626
generateDaoClaimTx,
2727
} from 'services/remote'
28-
import { getHeader, getHeaderByNumber, calculateDaoMaximumWithdraw } from 'services/chain'
28+
import { ckbCore, getHeaderByNumber, calculateDaoMaximumWithdraw } from 'services/chain'
2929

3030
let timer: NodeJS.Timeout
3131

@@ -93,7 +93,8 @@ export const useInitData = ({
9393
clearNervosDaoData()(dispatch)
9494
clearGeneratedTx()
9595
}
96-
}, [clearGeneratedTx, dispatch, updateDepositValue, wallet.id, wallet.balance, setGenesisBlockTimestamp])
96+
// eslint-disable-next-line
97+
}, [])
9798

9899
export const useClearGeneratedTx = (dispatch: React.Dispatch<StateAction>) =>
99100
useCallback(() => {
@@ -238,12 +239,13 @@ export const useCompensationPeriods = ({
238239
try {
239240
const depositEpochInfo = epochParser(depositEpoch)
240241
const currentEpochInfo = epochParser(currentEpoch)
241-
const targetEpochNumber = calculateClaimEpochNumber(depositEpochInfo, currentEpochInfo)
242+
const targetEpochValue = calculateClaimEpochValue(depositEpochInfo, currentEpochInfo)
242243
return {
243-
targetEpochNumber,
244-
currentEpochNumber: currentEpochInfo.number,
245-
currentEpochIndex: currentEpochInfo.index,
246-
currentEpochLength: currentEpochInfo.length,
244+
depositEpochValue:
245+
Number(depositEpochInfo.number) + Number(depositEpochInfo.index) / Number(depositEpochInfo.length),
246+
targetEpochValue,
247+
currentEpochValue:
248+
Number(currentEpochInfo.number) + Number(currentEpochInfo.index) / Number(currentEpochInfo.length),
247249
}
248250
} catch {
249251
return null
@@ -491,11 +493,12 @@ export const useUpdateDepositEpochList = ({
491493
useEffect(() => {
492494
if (connectionStatus === 'online') {
493495
Promise.all(
494-
records.map(({ blockHash }) =>
495-
getHeader(blockHash)
496+
records.map(({ daoData, depositOutPoint, blockNumber }) => {
497+
const depositBlockNumber = depositOutPoint ? ckbCore.utils.toHexInLittleEndian(daoData) : blockNumber
498+
return getHeaderByNumber(BigInt(depositBlockNumber))
496499
.then(header => header.epoch)
497500
.catch(() => null)
498-
)
501+
})
499502
).then(epochsList => setDepositEpochList(epochsList))
500503
}
501504
}, [records, setDepositEpochList, connectionStatus])

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

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -132,27 +132,21 @@ const NervosDAO = () => {
132132
<h2 className={styles.recordsTitle}>{t('nervos-dao.deposit-records')}</h2>
133133
<Stack className={styles.recordsContainer}>
134134
{records.map((record, i) => {
135-
let stage = 'deposited'
136-
if (record.depositOutPoint) {
137-
stage = 'withdrawing'
135+
const props = {
136+
...record,
137+
tipBlockTimestamp,
138+
compensationPeriod: compensationPeriods[i],
139+
withdrawCapacity: withdrawList[i],
140+
key: `${record.outPoint.txHash}-${record.outPoint.index}`,
141+
onClick: onActionClick,
142+
onCompensationPeriodExplanationClick,
143+
tipBlockNumber,
144+
depositEpoch: depositEpochList[i] || '',
145+
currentEpoch: epoch,
146+
genesisBlockTimestamp,
147+
connectionStatus,
138148
}
139-
return (
140-
<DAORecord
141-
{...record}
142-
compensationPeriod={compensationPeriods[i]}
143-
withdraw={withdrawList[i]}
144-
actionLabel={t(`nervos-dao.${stage}-action-label`)}
145-
key={JSON.stringify(record.outPoint)}
146-
onClick={onActionClick}
147-
onCompensationPeriodExplanationClick={onCompensationPeriodExplanationClick}
148-
tipBlockNumber={tipBlockNumber}
149-
tipBlockTimestamp={tipBlockTimestamp}
150-
epoch={epoch}
151-
genesisBlockTimestamp={genesisBlockTimestamp}
152-
connectionStatus={connectionStatus}
153-
dispatch={dispatch}
154-
/>
155-
)
149+
return <DAORecord {...props} />
156150
})}
157151
</Stack>
158152
</>
@@ -169,7 +163,7 @@ const NervosDAO = () => {
169163
connectionStatus,
170164
genesisBlockTimestamp,
171165
tipBlockTimestamp,
172-
dispatch,
166+
depositEpochList,
173167
])
174168

175169
const MemoizedDepositDialog = useMemo(() => {
@@ -188,6 +182,7 @@ const NervosDAO = () => {
188182
isTxGenerated={!!send.generatedTx}
189183
/>
190184
)
185+
// eslint-disable-next-line
191186
}, [
192187
showDepositDialog,
193188
depositValue,
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { useEffect } from 'react'
2+
import { getHeaderByNumber } from 'services/chain'
3+
import { MILLISECONDS_IN_YEAR } from 'utils/const'
4+
import calculateAPC from 'utils/calculateAPC'
5+
6+
export const useUpdateEpochs = ({
7+
depositOutPoint,
8+
blockNumber,
9+
setWithdrawingEpoch,
10+
}: {
11+
depositOutPoint: CKBComponents.OutPoint | undefined
12+
blockNumber: CKBComponents.BlockNumber
13+
setWithdrawingEpoch: React.Dispatch<string>
14+
}) => {
15+
useEffect(() => {
16+
if (depositOutPoint) {
17+
// It's under withdrawing, the block number is the one that withdrawing starts at
18+
getHeaderByNumber(BigInt(blockNumber))
19+
.then(header => {
20+
setWithdrawingEpoch(header.epoch)
21+
})
22+
.catch((err: Error) => {
23+
console.error(err)
24+
})
25+
}
26+
}, [depositOutPoint, blockNumber, setWithdrawingEpoch])
27+
}
28+
29+
export const useUpdateApc = ({
30+
depositTimestamp,
31+
genesisBlockTimestamp = 0,
32+
timestamp,
33+
tipBlockTimestamp,
34+
setApc,
35+
}: {
36+
depositTimestamp: number
37+
genesisBlockTimestamp: number
38+
timestamp: number
39+
tipBlockTimestamp: number
40+
setApc: React.Dispatch<number>
41+
}) => {
42+
useEffect(() => {
43+
if (depositTimestamp) {
44+
const startYearNumber = (depositTimestamp - genesisBlockTimestamp) / MILLISECONDS_IN_YEAR
45+
const endYearNumber = (timestamp - genesisBlockTimestamp) / MILLISECONDS_IN_YEAR
46+
try {
47+
const calculatedAPC = calculateAPC({
48+
startYearNumber,
49+
endYearNumber,
50+
})
51+
setApc(calculatedAPC)
52+
} catch (err) {
53+
console.error(err)
54+
}
55+
} else {
56+
const startYearNumber = (timestamp - genesisBlockTimestamp) / MILLISECONDS_IN_YEAR
57+
const endYearNumber = (tipBlockTimestamp - genesisBlockTimestamp) / MILLISECONDS_IN_YEAR
58+
try {
59+
const calculatedAPC = calculateAPC({
60+
startYearNumber,
61+
endYearNumber,
62+
})
63+
setApc(calculatedAPC)
64+
} catch (err) {
65+
console.error(err)
66+
}
67+
}
68+
}, [depositTimestamp, tipBlockTimestamp, timestamp, genesisBlockTimestamp, setApc])
69+
}
70+
71+
export default { useUpdateEpochs, useUpdateApc }

0 commit comments

Comments
 (0)