Skip to content

Commit df7f4db

Browse files
authored
Merge pull request #1104 from nervosnetwork/rc/v0.24.5
[ᚬmaster] Rc/v0.24.5
2 parents c141b2c + 674cec4 commit df7f4db

File tree

56 files changed

+808
-901
lines changed

Some content is hidden

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

56 files changed

+808
-901
lines changed

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
## [0.24.5](https://github.com/nervosnetwork/neuron/compare/v0.24.4...v0.24.5) (2019-11-14)
2+
3+
4+
### Bug Fixes
5+
6+
* **neuron-ui:** add decimal validation on deposit value ([#1093](https://github.com/nervosnetwork/neuron/issues/1093)) ([61eab4f](https://github.com/nervosnetwork/neuron/commit/61eab4f))
7+
* current block number should be -1 if not start ([543cdd0](https://github.com/nervosnetwork/neuron/commit/543cdd0))
8+
* dao i18n ([4f41d9d](https://github.com/nervosnetwork/neuron/commit/4f41d9d))
9+
10+
11+
### Features
12+
13+
* **neuron-ui:** add an alert when past epochs are less than 5 ([15d0cc8](https://github.com/nervosnetwork/neuron/commit/15d0cc8))
14+
* **neuron-ui:** add border color on dao records ([96b4ef6](https://github.com/nervosnetwork/neuron/commit/96b4ef6))
15+
* **neuron-ui:** rename APY to APC ([c337a21](https://github.com/nervosnetwork/neuron/commit/c337a21))
16+
* **neuron-ui:** rename interest to compensation ([e6d6060](https://github.com/nervosnetwork/neuron/commit/e6d6060))
17+
* Regenerate addresses if necessary on launch ([9988a13](https://github.com/nervosnetwork/neuron/commit/9988a13))
18+
* **neuron-ui:** add content in deposit notice ([dd0c7dc](https://github.com/nervosnetwork/neuron/commit/dd0c7dc))
19+
* **neuron-ui:** add global apy estimation ([#1092](https://github.com/nervosnetwork/neuron/issues/1092)) ([dc82cbb](https://github.com/nervosnetwork/neuron/commit/dc82cbb))
20+
* **neuron-ui:** add more translation of nervos dao ([3c62598](https://github.com/nervosnetwork/neuron/commit/3c62598))
21+
* **neuron-ui:** adjust the order of dao records ([e8398b6](https://github.com/nervosnetwork/neuron/commit/e8398b6))
22+
* **neuron-ui:** remove the user-confirmation from phase2 of nervos dao ([7e9e9e3](https://github.com/nervosnetwork/neuron/commit/7e9e9e3))
23+
* **neuron-ui:** rename deposit record to deposit receipt ([4c587a8](https://github.com/nervosnetwork/neuron/commit/4c587a8))
24+
* **neuron-ui:** use the same style of activity record on deposit record. ([99f77aa](https://github.com/nervosnetwork/neuron/commit/99f77aa))
25+
* Remove address sqlite db ([6f95340](https://github.com/nervosnetwork/neuron/commit/6f95340))
26+
* Send address db changed event when address store ([617a9a3](https://github.com/nervosnetwork/neuron/commit/617a9a3))
27+
* **neuron-ui:** remove redundant error messages ([c67aa36](https://github.com/nervosnetwork/neuron/commit/c67aa36))
28+
* **neuron-ui:** update the info and message of nervos dao ([cd44e43](https://github.com/nervosnetwork/neuron/commit/cd44e43))
29+
* **neuron-ui:** use the same style of overview on nervos dao overview ([20bbf33](https://github.com/nervosnetwork/neuron/commit/20bbf33))
30+
31+
32+
133
## [0.24.4](https://github.com/nervosnetwork/neuron/compare/v0.24.3...v0.24.4) (2019-11-12)
234

335

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.24.4",
5+
"version": "0.24.5",
66
"npmClient": "yarn",
77
"useWorkspaces": true
88
}

ormconfig-address.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 3 deletions
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.24.4",
5+
"version": "0.24.5",
66
"private": true,
77
"author": {
88
"name": "Nervos Core Dev",
@@ -34,8 +34,7 @@
3434
"test:e2e": "yarn build && ./scripts/copy-ui-files.sh && lerna run --parallel test:e2e",
3535
"lint": "lerna run --stream lint",
3636
"postinstall": "lerna run rebuild:nativemodules",
37-
"db:chain": "node ./node_modules/.bin/typeorm",
38-
"db:address": "node ./node_modules/.bin/typeorm --config ormconfig-address.json"
37+
"db:chain": "node ./node_modules/.bin/typeorm"
3938
},
4039
"husky": {
4140
"hooks": {

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.24.4",
3+
"version": "0.24.5",
44
"private": true,
55
"author": {
66
"name": "Nervos Core Dev",

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

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import React, { useEffect, useState } from 'react'
1+
import React, { useEffect, useState, useMemo } from 'react'
22
import { DefaultButton } from 'office-ui-fabric-react'
33
import { useTranslation } from 'react-i18next'
44
import { ckbCore, getBlockByNumber } from 'services/chain'
5-
import calculateAPY from 'utils/calculateAPY'
5+
import { showMessage } from 'services/remote'
6+
import calculateAPC from 'utils/calculateAPC'
67
import { shannonToCKBFormatter, uniformTimeFormatter, localNumberFormatter } from 'utils/formatters'
78
import calculateClaimEpochNumber from 'utils/calculateClaimEpochNumber'
89
import { epochParser } from 'utils/parsers'
@@ -21,19 +22,28 @@ const DAORecord = ({
2122
depositOutPoint,
2223
epoch,
2324
withdraw,
25+
connectionStatus,
2426
}: State.NervosDAORecord & {
2527
actionLabel: string
2628
onClick: any
2729
tipBlockNumber: string
2830
epoch: string
2931
withdraw: string | null
32+
connectionStatus: 'online' | 'offline'
3033
}) => {
3134
const [t] = useTranslation()
3235
const [withdrawingEpoch, setWithdrawingEpoch] = useState('')
3336
const [depositEpoch, setDepositEpoch] = useState('')
3437

3538
useEffect(() => {
3639
if (!depositOutPoint) {
40+
getBlockByNumber(BigInt(blockNumber))
41+
.then(b => {
42+
setDepositEpoch(b.header.epoch)
43+
})
44+
.catch((err: Error) => {
45+
console.error(err)
46+
})
3747
return
3848
}
3949
const depositBlockNumber = ckbCore.utils.bytesToHex(ckbCore.utils.hexToBytes(daoData).reverse())
@@ -54,13 +64,13 @@ const DAORecord = ({
5464
})
5565
}, [daoData, depositOutPoint, blockNumber])
5666

57-
const interest = BigInt(withdraw || capacity) - BigInt(capacity)
67+
const compensation = BigInt(withdraw || capacity) - BigInt(capacity)
5868

5969
let ready = false
6070
let metaInfo = 'Ready'
6171
if (!depositOutPoint) {
6272
const duration = BigInt(tipBlockNumber) - BigInt(blockNumber)
63-
metaInfo = t('nervos-dao.interest-accumulated', {
73+
metaInfo = t('nervos-dao.compensation-accumulated', {
6474
blockNumber: localNumberFormatter(duration >= BigInt(0) ? duration : 0),
6575
})
6676
} else {
@@ -81,18 +91,42 @@ const DAORecord = ({
8191
}
8292
}
8393

94+
const onActionClick = useMemo(() => {
95+
const currentEpochInfo = epochParser(epoch)
96+
const thresholdEpoch = withdrawingEpoch || depositEpoch
97+
if (thresholdEpoch) {
98+
const thresholdEpochInfo = epochParser(thresholdEpoch)
99+
if (thresholdEpochInfo.number + BigInt(4) >= currentEpochInfo.number) {
100+
return () =>
101+
showMessage(
102+
{
103+
title: t('nervos-dao.insufficient-period-alert-title'),
104+
message: t('nervos-dao.insufficient-period-alert-title'),
105+
detail: t('nervos-dao.insufficient-period-alert-message'),
106+
},
107+
() => {}
108+
)
109+
}
110+
}
111+
return onClick
112+
}, [onClick, epoch, depositEpoch, withdrawingEpoch, t])
113+
84114
return (
85-
<div className={styles.daoRecord}>
115+
<div className={`${styles.daoRecord} ${depositOutPoint ? styles.isClaim : ''}`}>
86116
<div className={styles.primaryInfo}>
87-
<div>{interest >= BigInt(0) ? `${shannonToCKBFormatter(interest.toString()).toString()} CKB` : ''}</div>
117+
<div>
118+
{compensation >= BigInt(0)
119+
? `${depositOutPoint ? '' : '~'}${shannonToCKBFormatter(compensation.toString()).toString()} CKB`
120+
: ''}
121+
</div>
88122
<div>{`${shannonToCKBFormatter(capacity)} CKB`}</div>
89123
<div>
90124
<DefaultButton
91125
text={actionLabel}
92126
data-tx-hash={txHash}
93127
data-index={index}
94-
onClick={onClick}
95-
disabled={depositOutPoint && !ready}
128+
onClick={onActionClick}
129+
disabled={connectionStatus === 'offline' || (depositOutPoint && !ready)}
96130
styles={{
97131
flexContainer: {
98132
pointerEvents: 'none',
@@ -108,7 +142,7 @@ const DAORecord = ({
108142
</div>
109143
</div>
110144
<div className={styles.secondaryInfo}>
111-
<span>{`APY: ~${calculateAPY(interest.toString(), capacity, `${Date.now() - +timestamp}`)}%`}</span>
145+
<span>{`APC: ~${calculateAPC(compensation.toString(), capacity, `${Date.now() - +timestamp}`)}%`}</span>
112146
<span>{uniformTimeFormatter(+timestamp)}</span>
113147
<span>{metaInfo}</span>
114148
</div>

packages/neuron-ui/src/components/CustomRows/daoRecordRow.module.scss

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
.daoRecord {
22
display: flex;
33
flex-direction: column;
4-
border: 1px solid #000;
5-
border-radius: 5px;
6-
margin: 10px 0;
7-
padding: 5px 15px;
4+
border-radius: 2px;
5+
margin: 15px 0;
6+
border-right: 1px solid #eee;
7+
border-left: 5px solid green;
8+
box-sizing: border-box;
9+
padding: 5px 10px;
10+
box-shadow: 0 1px 5px 1px rgba(0, 0, 0, 0.14);
811

912
.primaryInfo,
1013
.secondaryInfo {
@@ -32,4 +35,7 @@
3235
color: #666;
3336
}
3437

38+
&.isClaim {
39+
border-left-color: blue;
40+
}
3541
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ const ImportKeystore = (props: React.PropsWithoutRef<StateWithDispatch & RouteCo
105105
return t(`messages.codes.${ErrorCode.FieldRequired}`, { fieldName: `keystore-${key}` })
106106
}
107107
if (key === 'name' && isNameUsed) {
108-
return t(`messages.codes.${ErrorCode.FieldUsed}`, { fieldName: `name`, fieldValue: text })
108+
return t(`messages.codes.${ErrorCode.FieldUsed}`, { fieldName: `keystore-name`, fieldValue: '' })
109109
}
110110
if (text && maxLength && text.length > maxLength) {
111111
return t(`messages.codes.${ErrorCode.FieldTooLong}`, {
112-
fieldName: key,
113-
fieldValue: key === 'password' ? '' : text,
112+
fieldName: `keystore-${key}`,
113+
fieldValue: '',
114114
length: maxLength,
115115
})
116116
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const DepositDialog = ({
6161
</Text>
6262
<Stack>
6363
<Text as="h2" variant="large">
64-
{t('nervos-dao.notice')}
64+
{`${t('nervos-dao.notice')}:`}
6565
</Text>
6666
{t('nervos-dao.deposit-terms')
6767
.split('\n')

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect } from 'react'
2-
import { Dialog, DialogFooter, DefaultButton, PrimaryButton, DialogType } from 'office-ui-fabric-react'
2+
import { Dialog, DialogFooter, DefaultButton, PrimaryButton, DialogType, Text } from 'office-ui-fabric-react'
33
import { useTranslation } from 'react-i18next'
44
import { shannonToCKBFormatter, localNumberFormatter } from 'utils/formatters'
55
import { ckbCore } from 'services/chain'
@@ -65,6 +65,16 @@ const WithdrawDialog = ({
6565
blocks: localNumberFormatter(currentEpochInfo.length - currentEpochInfo.index),
6666
days: localNumberFormatter(epochs / BigInt(6)),
6767
})
68+
69+
const alert =
70+
epochs <= BigInt(5)
71+
? t('nervos-dao.withdraw-alert', {
72+
epochs,
73+
nextLeftEpochs: epochs + BigInt(180),
74+
days: (epochs + BigInt(180)) / BigInt(6),
75+
})
76+
: ''
77+
6878
return (
6979
<Dialog
7080
hidden={!record}
@@ -77,20 +87,25 @@ const WithdrawDialog = ({
7787
>
7888
{record ? (
7989
<>
80-
<div>
90+
<Text as="p" variant="large" block>
8191
<span>{`${t('nervos-dao.deposit')}: `}</span>
8292
<span>{`${shannonToCKBFormatter(record.capacity)} CKB`}</span>
83-
</div>
84-
<div>
85-
<span>{`${t('nervos-dao.interest')}: `}</span>
93+
</Text>
94+
<Text as="p" variant="large" block>
95+
<span>{`${t('nervos-dao.compensation')}: `}</span>
8696
<span>
8797
{withdrawValue
8898
? `${shannonToCKBFormatter((BigInt(withdrawValue) - BigInt(record.capacity)).toString())} CKB`
8999
: ''}
90100
</span>
91-
</div>
101+
</Text>
92102
<div>
93-
<span>{message}</span>
103+
<Text as="p" variant="small" block>
104+
{message}
105+
</Text>
106+
<Text as="p" variant="xSmall" block styles={{ root: { color: 'red' } }}>
107+
{alert}
108+
</Text>
94109
</div>
95110
</>
96111
) : null}

0 commit comments

Comments
 (0)