Skip to content

Commit

Permalink
Merge pull request #1104 from nervosnetwork/rc/v0.24.5
Browse files Browse the repository at this point in the history
[ᚬmaster] Rc/v0.24.5
  • Loading branch information
ashchan authored Nov 14, 2019
2 parents c141b2c + 674cec4 commit df7f4db
Show file tree
Hide file tree
Showing 56 changed files with 808 additions and 901 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
## [0.24.5](https://github.com/nervosnetwork/neuron/compare/v0.24.4...v0.24.5) (2019-11-14)


### Bug Fixes

* **neuron-ui:** add decimal validation on deposit value ([#1093](https://github.com/nervosnetwork/neuron/issues/1093)) ([61eab4f](https://github.com/nervosnetwork/neuron/commit/61eab4f))
* current block number should be -1 if not start ([543cdd0](https://github.com/nervosnetwork/neuron/commit/543cdd0))
* dao i18n ([4f41d9d](https://github.com/nervosnetwork/neuron/commit/4f41d9d))


### Features

* **neuron-ui:** add an alert when past epochs are less than 5 ([15d0cc8](https://github.com/nervosnetwork/neuron/commit/15d0cc8))
* **neuron-ui:** add border color on dao records ([96b4ef6](https://github.com/nervosnetwork/neuron/commit/96b4ef6))
* **neuron-ui:** rename APY to APC ([c337a21](https://github.com/nervosnetwork/neuron/commit/c337a21))
* **neuron-ui:** rename interest to compensation ([e6d6060](https://github.com/nervosnetwork/neuron/commit/e6d6060))
* Regenerate addresses if necessary on launch ([9988a13](https://github.com/nervosnetwork/neuron/commit/9988a13))
* **neuron-ui:** add content in deposit notice ([dd0c7dc](https://github.com/nervosnetwork/neuron/commit/dd0c7dc))
* **neuron-ui:** add global apy estimation ([#1092](https://github.com/nervosnetwork/neuron/issues/1092)) ([dc82cbb](https://github.com/nervosnetwork/neuron/commit/dc82cbb))
* **neuron-ui:** add more translation of nervos dao ([3c62598](https://github.com/nervosnetwork/neuron/commit/3c62598))
* **neuron-ui:** adjust the order of dao records ([e8398b6](https://github.com/nervosnetwork/neuron/commit/e8398b6))
* **neuron-ui:** remove the user-confirmation from phase2 of nervos dao ([7e9e9e3](https://github.com/nervosnetwork/neuron/commit/7e9e9e3))
* **neuron-ui:** rename deposit record to deposit receipt ([4c587a8](https://github.com/nervosnetwork/neuron/commit/4c587a8))
* **neuron-ui:** use the same style of activity record on deposit record. ([99f77aa](https://github.com/nervosnetwork/neuron/commit/99f77aa))
* Remove address sqlite db ([6f95340](https://github.com/nervosnetwork/neuron/commit/6f95340))
* Send address db changed event when address store ([617a9a3](https://github.com/nervosnetwork/neuron/commit/617a9a3))
* **neuron-ui:** remove redundant error messages ([c67aa36](https://github.com/nervosnetwork/neuron/commit/c67aa36))
* **neuron-ui:** update the info and message of nervos dao ([cd44e43](https://github.com/nervosnetwork/neuron/commit/cd44e43))
* **neuron-ui:** use the same style of overview on nervos dao overview ([20bbf33](https://github.com/nervosnetwork/neuron/commit/20bbf33))



## [0.24.4](https://github.com/nervosnetwork/neuron/compare/v0.24.3...v0.24.4) (2019-11-12)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "0.24.4",
"version": "0.24.5",
"npmClient": "yarn",
"useWorkspaces": true
}
21 changes: 0 additions & 21 deletions ormconfig-address.json

This file was deleted.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "neuron",
"productName": "Neuron",
"description": "CKB Neuron Wallet",
"version": "0.24.4",
"version": "0.24.5",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down Expand Up @@ -34,8 +34,7 @@
"test:e2e": "yarn build && ./scripts/copy-ui-files.sh && lerna run --parallel test:e2e",
"lint": "lerna run --stream lint",
"postinstall": "lerna run rebuild:nativemodules",
"db:chain": "node ./node_modules/.bin/typeorm",
"db:address": "node ./node_modules/.bin/typeorm --config ormconfig-address.json"
"db:chain": "node ./node_modules/.bin/typeorm"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neuron-ui",
"version": "0.24.4",
"version": "0.24.5",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down
52 changes: 43 additions & 9 deletions packages/neuron-ui/src/components/CustomRows/DAORecordRow.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useEffect, useState } from 'react'
import React, { useEffect, useState, useMemo } from 'react'
import { DefaultButton } from 'office-ui-fabric-react'
import { useTranslation } from 'react-i18next'
import { ckbCore, getBlockByNumber } from 'services/chain'
import calculateAPY from 'utils/calculateAPY'
import { showMessage } from 'services/remote'
import calculateAPC from 'utils/calculateAPC'
import { shannonToCKBFormatter, uniformTimeFormatter, localNumberFormatter } from 'utils/formatters'
import calculateClaimEpochNumber from 'utils/calculateClaimEpochNumber'
import { epochParser } from 'utils/parsers'
Expand All @@ -21,19 +22,28 @@ const DAORecord = ({
depositOutPoint,
epoch,
withdraw,
connectionStatus,
}: State.NervosDAORecord & {
actionLabel: string
onClick: any
tipBlockNumber: string
epoch: string
withdraw: string | null
connectionStatus: 'online' | 'offline'
}) => {
const [t] = useTranslation()
const [withdrawingEpoch, setWithdrawingEpoch] = useState('')
const [depositEpoch, setDepositEpoch] = useState('')

useEffect(() => {
if (!depositOutPoint) {
getBlockByNumber(BigInt(blockNumber))
.then(b => {
setDepositEpoch(b.header.epoch)
})
.catch((err: Error) => {
console.error(err)
})
return
}
const depositBlockNumber = ckbCore.utils.bytesToHex(ckbCore.utils.hexToBytes(daoData).reverse())
Expand All @@ -54,13 +64,13 @@ const DAORecord = ({
})
}, [daoData, depositOutPoint, blockNumber])

const interest = BigInt(withdraw || capacity) - BigInt(capacity)
const compensation = BigInt(withdraw || capacity) - BigInt(capacity)

let ready = false
let metaInfo = 'Ready'
if (!depositOutPoint) {
const duration = BigInt(tipBlockNumber) - BigInt(blockNumber)
metaInfo = t('nervos-dao.interest-accumulated', {
metaInfo = t('nervos-dao.compensation-accumulated', {
blockNumber: localNumberFormatter(duration >= BigInt(0) ? duration : 0),
})
} else {
Expand All @@ -81,18 +91,42 @@ const DAORecord = ({
}
}

const onActionClick = useMemo(() => {
const currentEpochInfo = epochParser(epoch)
const thresholdEpoch = withdrawingEpoch || depositEpoch
if (thresholdEpoch) {
const thresholdEpochInfo = epochParser(thresholdEpoch)
if (thresholdEpochInfo.number + BigInt(4) >= currentEpochInfo.number) {
return () =>
showMessage(
{
title: t('nervos-dao.insufficient-period-alert-title'),
message: t('nervos-dao.insufficient-period-alert-title'),
detail: t('nervos-dao.insufficient-period-alert-message'),
},
() => {}
)
}
}
return onClick
}, [onClick, epoch, depositEpoch, withdrawingEpoch, t])

return (
<div className={styles.daoRecord}>
<div className={`${styles.daoRecord} ${depositOutPoint ? styles.isClaim : ''}`}>
<div className={styles.primaryInfo}>
<div>{interest >= BigInt(0) ? `${shannonToCKBFormatter(interest.toString()).toString()} CKB` : ''}</div>
<div>
{compensation >= BigInt(0)
? `${depositOutPoint ? '' : '~'}${shannonToCKBFormatter(compensation.toString()).toString()} CKB`
: ''}
</div>
<div>{`${shannonToCKBFormatter(capacity)} CKB`}</div>
<div>
<DefaultButton
text={actionLabel}
data-tx-hash={txHash}
data-index={index}
onClick={onClick}
disabled={depositOutPoint && !ready}
onClick={onActionClick}
disabled={connectionStatus === 'offline' || (depositOutPoint && !ready)}
styles={{
flexContainer: {
pointerEvents: 'none',
Expand All @@ -108,7 +142,7 @@ const DAORecord = ({
</div>
</div>
<div className={styles.secondaryInfo}>
<span>{`APY: ~${calculateAPY(interest.toString(), capacity, `${Date.now() - +timestamp}`)}%`}</span>
<span>{`APC: ~${calculateAPC(compensation.toString(), capacity, `${Date.now() - +timestamp}`)}%`}</span>
<span>{uniformTimeFormatter(+timestamp)}</span>
<span>{metaInfo}</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
.daoRecord {
display: flex;
flex-direction: column;
border: 1px solid #000;
border-radius: 5px;
margin: 10px 0;
padding: 5px 15px;
border-radius: 2px;
margin: 15px 0;
border-right: 1px solid #eee;
border-left: 5px solid green;
box-sizing: border-box;
padding: 5px 10px;
box-shadow: 0 1px 5px 1px rgba(0, 0, 0, 0.14);

.primaryInfo,
.secondaryInfo {
Expand Down Expand Up @@ -32,4 +35,7 @@
color: #666;
}

&.isClaim {
border-left-color: blue;
}
}
6 changes: 3 additions & 3 deletions packages/neuron-ui/src/components/ImportKeystore/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ const ImportKeystore = (props: React.PropsWithoutRef<StateWithDispatch & RouteCo
return t(`messages.codes.${ErrorCode.FieldRequired}`, { fieldName: `keystore-${key}` })
}
if (key === 'name' && isNameUsed) {
return t(`messages.codes.${ErrorCode.FieldUsed}`, { fieldName: `name`, fieldValue: text })
return t(`messages.codes.${ErrorCode.FieldUsed}`, { fieldName: `keystore-name`, fieldValue: '' })
}
if (text && maxLength && text.length > maxLength) {
return t(`messages.codes.${ErrorCode.FieldTooLong}`, {
fieldName: key,
fieldValue: key === 'password' ? '' : text,
fieldName: `keystore-${key}`,
fieldValue: '',
length: maxLength,
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const DepositDialog = ({
</Text>
<Stack>
<Text as="h2" variant="large">
{t('nervos-dao.notice')}
{`${t('nervos-dao.notice')}:`}
</Text>
{t('nervos-dao.deposit-terms')
.split('\n')
Expand Down
29 changes: 22 additions & 7 deletions packages/neuron-ui/src/components/NervosDAO/WithdrawDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react'
import { Dialog, DialogFooter, DefaultButton, PrimaryButton, DialogType } from 'office-ui-fabric-react'
import { Dialog, DialogFooter, DefaultButton, PrimaryButton, DialogType, Text } from 'office-ui-fabric-react'
import { useTranslation } from 'react-i18next'
import { shannonToCKBFormatter, localNumberFormatter } from 'utils/formatters'
import { ckbCore } from 'services/chain'
Expand Down Expand Up @@ -65,6 +65,16 @@ const WithdrawDialog = ({
blocks: localNumberFormatter(currentEpochInfo.length - currentEpochInfo.index),
days: localNumberFormatter(epochs / BigInt(6)),
})

const alert =
epochs <= BigInt(5)
? t('nervos-dao.withdraw-alert', {
epochs,
nextLeftEpochs: epochs + BigInt(180),
days: (epochs + BigInt(180)) / BigInt(6),
})
: ''

return (
<Dialog
hidden={!record}
Expand All @@ -77,20 +87,25 @@ const WithdrawDialog = ({
>
{record ? (
<>
<div>
<Text as="p" variant="large" block>
<span>{`${t('nervos-dao.deposit')}: `}</span>
<span>{`${shannonToCKBFormatter(record.capacity)} CKB`}</span>
</div>
<div>
<span>{`${t('nervos-dao.interest')}: `}</span>
</Text>
<Text as="p" variant="large" block>
<span>{`${t('nervos-dao.compensation')}: `}</span>
<span>
{withdrawValue
? `${shannonToCKBFormatter((BigInt(withdrawValue) - BigInt(record.capacity)).toString())} CKB`
: ''}
</span>
</div>
</Text>
<div>
<span>{message}</span>
<Text as="p" variant="small" block>
{message}
</Text>
<Text as="p" variant="xSmall" block styles={{ root: { color: 'red' } }}>
{alert}
</Text>
</div>
</>
) : null}
Expand Down
Loading

0 comments on commit df7f4db

Please sign in to comment.