Skip to content

Commit c141b2c

Browse files
authored
Merge pull request #1086 from nervosnetwork/rc/v0.24.4
[ᚬmaster] Rc/v0.24.4
2 parents e27bfb4 + ffdd258 commit c141b2c

File tree

78 files changed

+2105
-348
lines changed

Some content is hidden

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

78 files changed

+2105
-348
lines changed

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1+
## [0.24.4](https://github.com/nervosnetwork/neuron/compare/v0.24.3...v0.24.4) (2019-11-12)
2+
3+
4+
### Bug Fixes
5+
6+
* **neuron-ui:** fix the apy calculation ([03c88d2](https://github.com/nervosnetwork/neuron/commit/03c88d2))
7+
* **neuron-ui:** fix the free and locked value of nervos dao ([16b2233](https://github.com/nervosnetwork/neuron/commit/16b2233))
8+
* **neuron-ui:** fix the minimal withdraw epoch number ([1c19582](https://github.com/nervosnetwork/neuron/commit/1c19582))
9+
* **neuron-ui:** fix the yield of nervos dao records ([544becd](https://github.com/nervosnetwork/neuron/commit/544becd))
10+
* **neuron-ui:** including keywords on tx list paging ([935950d](https://github.com/nervosnetwork/neuron/commit/935950d))
11+
* calculate tx serialized size for dao ([2088d5c](https://github.com/nervosnetwork/neuron/commit/2088d5c))
12+
* calculateDaoMaximumWithdraw return type ([22ee960](https://github.com/nervosnetwork/neuron/commit/22ee960))
13+
* deposit dao and withdraw step1 error ([77a505d](https://github.com/nervosnetwork/neuron/commit/77a505d))
14+
* fix getDaoCells return ([c914dff](https://github.com/nervosnetwork/neuron/commit/c914dff))
15+
* fix withdraw dao bug ([9b1c0ed](https://github.com/nervosnetwork/neuron/commit/9b1c0ed))
16+
* getDaoCells and its tests ([2460b0b](https://github.com/nervosnetwork/neuron/commit/2460b0b))
17+
* getDaoCells load dao cells except dead ([d5ba396](https://github.com/nervosnetwork/neuron/commit/d5ba396))
18+
* load init txs in windows ([8880d34](https://github.com/nervosnetwork/neuron/commit/8880d34))
19+
* mark depositOutPoint when create step1 ([85a851b](https://github.com/nervosnetwork/neuron/commit/85a851b))
20+
21+
22+
### Features
23+
24+
* add dao methods to controller ([41953bf](https://github.com/nervosnetwork/neuron/commit/41953bf))
25+
* add inputIndex to inputs ([c760db5](https://github.com/nervosnetwork/neuron/commit/c760db5))
26+
* add typeHash and daoData to Output ([5efe225](https://github.com/nervosnetwork/neuron/commit/5efe225))
27+
* add typeHash and daoData when sync ([1b6b062](https://github.com/nervosnetwork/neuron/commit/1b6b062))
28+
* generate dao transactions ([36ba523](https://github.com/nervosnetwork/neuron/commit/36ba523))
29+
* remove SkipDataAndType module ([1bc25eb](https://github.com/nervosnetwork/neuron/commit/1bc25eb))
30+
* remove totalBalance ([5b0df6f](https://github.com/nervosnetwork/neuron/commit/5b0df6f))
31+
* Shorter binary file names ([337790d](https://github.com/nervosnetwork/neuron/commit/337790d))
32+
* **neuron-ui:** add nervos dao view ([ca46665](https://github.com/nervosnetwork/neuron/commit/ca46665))
33+
* **neuron-ui:** allow user to claim since unlock epoch. ([f1ad76b](https://github.com/nervosnetwork/neuron/commit/f1ad76b))
34+
* **neuron-ui:** update i18n of nervos dao ([3b72042](https://github.com/nervosnetwork/neuron/commit/3b72042))
35+
36+
37+
138
## [0.24.3](https://github.com/nervosnetwork/neuron/compare/v0.24.2...v0.24.3) (2019-11-11)
239

340

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.3",
5+
"version": "0.24.4",
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.24.3",
5+
"version": "0.24.4",
66
"private": true,
77
"author": {
88
"name": "Nervos Core Dev",

packages/neuron-ui/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "neuron-ui",
3-
"version": "0.24.3",
3+
"version": "0.24.4",
44
"private": true,
55
"author": {
66
"name": "Nervos Core Dev",
@@ -43,7 +43,7 @@
4343
"last 2 chrome versions"
4444
],
4545
"dependencies": {
46-
"@nervosnetwork/ckb-sdk-core": "0.24.1",
46+
"@nervosnetwork/ckb-sdk-core": "0.25.0-alpha.0",
4747
"@uifabric/experiments": "7.16.1",
4848
"@uifabric/styling": "7.6.2",
4949
"canvg": "2.0.0",
@@ -53,7 +53,7 @@
5353
"qr.js": "0.0.0",
5454
"react": "16.9.0",
5555
"react-dom": "16.9.0",
56-
"react-i18next": "10.12.2",
56+
"react-i18next": "11.0.1",
5757
"react-router-dom": "5.0.1",
5858
"react-scripts": "3.2.0",
5959
"styled-components": "5.0.0-beta.0"
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import React, { useEffect, useState } from 'react'
2+
import { DefaultButton } from 'office-ui-fabric-react'
3+
import { useTranslation } from 'react-i18next'
4+
import { ckbCore, getBlockByNumber } from 'services/chain'
5+
import calculateAPY from 'utils/calculateAPY'
6+
import { shannonToCKBFormatter, uniformTimeFormatter, localNumberFormatter } from 'utils/formatters'
7+
import calculateClaimEpochNumber from 'utils/calculateClaimEpochNumber'
8+
import { epochParser } from 'utils/parsers'
9+
10+
import * as styles from './daoRecordRow.module.scss'
11+
12+
const DAORecord = ({
13+
daoData,
14+
blockNumber,
15+
outPoint: { txHash, index },
16+
tipBlockNumber,
17+
capacity,
18+
actionLabel,
19+
onClick,
20+
timestamp,
21+
depositOutPoint,
22+
epoch,
23+
withdraw,
24+
}: State.NervosDAORecord & {
25+
actionLabel: string
26+
onClick: any
27+
tipBlockNumber: string
28+
epoch: string
29+
withdraw: string | null
30+
}) => {
31+
const [t] = useTranslation()
32+
const [withdrawingEpoch, setWithdrawingEpoch] = useState('')
33+
const [depositEpoch, setDepositEpoch] = useState('')
34+
35+
useEffect(() => {
36+
if (!depositOutPoint) {
37+
return
38+
}
39+
const depositBlockNumber = ckbCore.utils.bytesToHex(ckbCore.utils.hexToBytes(daoData).reverse())
40+
getBlockByNumber(BigInt(depositBlockNumber))
41+
.then(b => {
42+
setDepositEpoch(b.header.epoch)
43+
})
44+
.catch((err: Error) => {
45+
console.error(err)
46+
})
47+
48+
getBlockByNumber(BigInt(blockNumber))
49+
.then(b => {
50+
setWithdrawingEpoch(b.header.epoch)
51+
})
52+
.catch((err: Error) => {
53+
console.error(err)
54+
})
55+
}, [daoData, depositOutPoint, blockNumber])
56+
57+
const interest = BigInt(withdraw || capacity) - BigInt(capacity)
58+
59+
let ready = false
60+
let metaInfo = 'Ready'
61+
if (!depositOutPoint) {
62+
const duration = BigInt(tipBlockNumber) - BigInt(blockNumber)
63+
metaInfo = t('nervos-dao.interest-accumulated', {
64+
blockNumber: localNumberFormatter(duration >= BigInt(0) ? duration : 0),
65+
})
66+
} else {
67+
const depositEpochInfo = epochParser(depositEpoch)
68+
const currentEpochInfo = epochParser(epoch)
69+
const withdrawingEpochInfo = epochParser(withdrawingEpoch)
70+
const targetEpochNumber = calculateClaimEpochNumber(depositEpochInfo, withdrawingEpochInfo)
71+
if (targetEpochNumber <= currentEpochInfo.number) {
72+
metaInfo = 'Ready'
73+
ready = true
74+
} else {
75+
const epochs = targetEpochNumber - currentEpochInfo.number - BigInt(1)
76+
metaInfo = t('nervos-dao.blocks-left', {
77+
epochs: localNumberFormatter(epochs),
78+
blocks: localNumberFormatter(currentEpochInfo.length - currentEpochInfo.index),
79+
days: localNumberFormatter(epochs / BigInt(6)),
80+
})
81+
}
82+
}
83+
84+
return (
85+
<div className={styles.daoRecord}>
86+
<div className={styles.primaryInfo}>
87+
<div>{interest >= BigInt(0) ? `${shannonToCKBFormatter(interest.toString()).toString()} CKB` : ''}</div>
88+
<div>{`${shannonToCKBFormatter(capacity)} CKB`}</div>
89+
<div>
90+
<DefaultButton
91+
text={actionLabel}
92+
data-tx-hash={txHash}
93+
data-index={index}
94+
onClick={onClick}
95+
disabled={depositOutPoint && !ready}
96+
styles={{
97+
flexContainer: {
98+
pointerEvents: 'none',
99+
},
100+
textContainer: {
101+
pointerEvents: 'none',
102+
},
103+
label: {
104+
pointerEvents: 'none',
105+
},
106+
}}
107+
/>
108+
</div>
109+
</div>
110+
<div className={styles.secondaryInfo}>
111+
<span>{`APY: ~${calculateAPY(interest.toString(), capacity, `${Date.now() - +timestamp}`)}%`}</span>
112+
<span>{uniformTimeFormatter(+timestamp)}</span>
113+
<span>{metaInfo}</span>
114+
</div>
115+
</div>
116+
)
117+
}
118+
119+
DAORecord.displayName = 'DAORecord'
120+
121+
export default DAORecord
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.daoRecord {
2+
display: flex;
3+
flex-direction: column;
4+
border: 1px solid #000;
5+
border-radius: 5px;
6+
margin: 10px 0;
7+
padding: 5px 15px;
8+
9+
.primaryInfo,
10+
.secondaryInfo {
11+
display: flex;
12+
justify-content: space-between;
13+
14+
&>div,
15+
&>span {
16+
flex: 1;
17+
text-align: center;
18+
19+
&:first-child {
20+
text-align: left;
21+
}
22+
23+
&:last-child {
24+
text-align: right;
25+
}
26+
}
27+
28+
}
29+
30+
.secondaryInfo {
31+
font-size: 12px;
32+
color: #666;
33+
}
34+
35+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const History = ({
7676
lastPageIconProps={{ iconName: 'LastPage' }}
7777
format="buttons"
7878
onPageChange={(idx: number) => {
79-
history.push(`${Routes.History}?pageNo=${idx + 1}`)
79+
history.push(`${Routes.History}?pageNo=${idx + 1}&keywords=${keywords}`)
8080
}}
8181
/>
8282
</Stack>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import React from 'react'
2+
import {
3+
Stack,
4+
Dialog,
5+
TextField,
6+
Slider,
7+
Text,
8+
DefaultButton,
9+
PrimaryButton,
10+
DialogType,
11+
DialogFooter,
12+
Spinner,
13+
SpinnerSize,
14+
} from 'office-ui-fabric-react'
15+
import { useTranslation } from 'react-i18next'
16+
import { SHANNON_CKB_RATIO } from 'utils/const'
17+
18+
const DepositDialog = ({
19+
show,
20+
value,
21+
fee,
22+
balance,
23+
onChange,
24+
onSlide,
25+
onSubmit,
26+
onDismiss,
27+
isDepositing,
28+
errorMessage,
29+
}: any) => {
30+
const [t] = useTranslation()
31+
const maxValue = +(BigInt(balance) / BigInt(SHANNON_CKB_RATIO)).toString()
32+
33+
if (!show) {
34+
return null
35+
}
36+
37+
return (
38+
<Dialog
39+
hidden={false}
40+
onDismiss={onDismiss}
41+
dialogContentProps={{
42+
type: DialogType.close,
43+
title: t('nervos-dao.deposit-to-nervos-dao'),
44+
}}
45+
modalProps={{
46+
isBlocking: false,
47+
styles: { main: { maxWidth: '500px!important' } },
48+
}}
49+
>
50+
{isDepositing ? (
51+
<Spinner size={SpinnerSize.large} />
52+
) : (
53+
<>
54+
<TextField label={t('nervos-dao.deposit')} value={value} onChange={onChange} suffix="CKB" />
55+
<Slider value={value} min={0} max={maxValue} step={1} showValue={false} onChange={onSlide} />
56+
<Text as="p" variant="small" block>
57+
{`${t('nervos-dao.fee')}: ${fee}`}
58+
</Text>
59+
<Text as="span" variant="tiny" block styles={{ root: { color: 'red' } }}>
60+
{errorMessage}
61+
</Text>
62+
<Stack>
63+
<Text as="h2" variant="large">
64+
{t('nervos-dao.notice')}
65+
</Text>
66+
{t('nervos-dao.deposit-terms')
67+
.split('\n')
68+
.map(term => (
69+
<Text as="p" key={term}>
70+
{term}
71+
</Text>
72+
))}
73+
</Stack>
74+
<DialogFooter>
75+
<DefaultButton onClick={onDismiss} text={t('nervos-dao.cancel')} />
76+
<PrimaryButton onClick={onSubmit} text={t('nervos-dao.proceed')} disabled={errorMessage} />
77+
</DialogFooter>
78+
</>
79+
)}
80+
</Dialog>
81+
)
82+
}
83+
84+
DepositDialog.displayName = 'DepositDialog'
85+
86+
export default DepositDialog

0 commit comments

Comments
 (0)