Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
96b4ef6
feat(neuron-ui): add border color on dao records
Keith-CY Nov 12, 2019
e8398b6
feat(neuron-ui): adjust the order of dao records
Keith-CY Nov 12, 2019
cd44e43
feat(neuron-ui): update the info and message of nervos dao
Keith-CY Nov 12, 2019
15d0cc8
feat(neuron-ui): add an alert when past epochs are less than 5
Keith-CY Nov 12, 2019
7e9e9e3
feat(neuron-ui): remove the user-confirmation from phase2 of nervos dao
Keith-CY Nov 12, 2019
154a892
Merge pull request #1087 from Keith-CY/update-nervos-dao-ui
ashchan Nov 12, 2019
c67aa36
feat(neuron-ui): remove redundant error messages
Keith-CY Nov 13, 2019
297b50d
Merge pull request #1088 from Keith-CY/remove-redundant-error-messages
Keith-CY Nov 13, 2019
3c62598
feat(neuron-ui): add more translation of nervos dao
Keith-CY Nov 13, 2019
a07e972
Merge pull request #1089 from Keith-CY/add-translation
Keith-CY Nov 13, 2019
430f682
chore: Update release checksums script to reflect recent
ashchan Nov 13, 2019
f6a3225
chore: only get dao cells in live or failed
classicalliu Nov 13, 2019
4f41d9d
fix: dao i18n
classicalliu Nov 13, 2019
dd6a1db
Merge remote-tracking branch 'origin/master' into develop
ashchan Nov 13, 2019
ec810de
Merge pull request #1090 from nervosnetwork/update-release-checksums-…
ashchan Nov 13, 2019
1784095
Merge pull request #1091 from nervosnetwork/dao-cell-failed
classicalliu Nov 13, 2019
20bbf33
feat(neuron-ui): use the same style of overview on nervos dao overview
Keith-CY Nov 13, 2019
dd0c7dc
feat(neuron-ui): add content in deposit notice
Keith-CY Nov 13, 2019
6003676
refactor: Add a simple json store to persist addresses
ashchan Nov 13, 2019
617a9a3
feat: Send address db changed event when address store
ashchan Nov 13, 2019
4eb367f
Merge pull request #1095 from Keith-CY/update-notice-of-nervos-dao
Keith-CY Nov 13, 2019
6f95340
feat: Remove address sqlite db
ashchan Nov 13, 2019
dc82cbb
feat(neuron-ui): add global apy estimation (#1092)
Keith-CY Nov 13, 2019
543cdd0
fix: current block number should be -1 if not start
classicalliu Nov 13, 2019
4c587a8
feat(neuron-ui): rename deposit record to deposit receipt
Keith-CY Nov 13, 2019
61eab4f
fix(neuron-ui): add decimal validation on deposit value (#1093)
Keith-CY Nov 13, 2019
74a48e6
Merge pull request #1094 from Keith-CY/update-the-overview-style-the-…
Keith-CY Nov 13, 2019
99f77aa
feat(neuron-ui): use the same style of activity record on deposit rec…
Keith-CY Nov 13, 2019
8b1ee0e
Merge pull request #1096 from Keith-CY/update-i18n-of-dao
Keith-CY Nov 13, 2019
63a46dd
Merge pull request #1097 from nervosnetwork/fix-default-current-number
classicalliu Nov 13, 2019
9988a13
feat: Regenerate addresses if necessary on launch
ashchan Nov 13, 2019
170dd4d
refactor(neuron-ui): remove useless Math.floor in calculateAPY
Keith-CY Nov 13, 2019
9b36192
Merge pull request #1099 from Keith-CY/remove-useless-math_floor
Keith-CY Nov 13, 2019
46a15b0
Merge pull request #1098 from Keith-CY/update-dao-record-style
ashchan Nov 13, 2019
0eafab2
refactor: Remove unnecessary async/await call on address modules
ashchan Nov 14, 2019
af9bf3c
refactor: Remove more await call
ashchan Nov 14, 2019
e03ec80
test: Remove async/await when testing address dao
ashchan Nov 14, 2019
f3b6b27
test: Do not run address tests as async
ashchan Nov 14, 2019
8e2d505
refactor(neuron-ui): improve precision of calculateAPY (#1102)
Keith-CY Nov 14, 2019
e6d6060
feat(neuron-ui): rename interest to compensation
Keith-CY Nov 14, 2019
6057138
test: Do not run address tests as async
ashchan Nov 14, 2019
c337a21
feat(neuron-ui): rename APY to APC
Keith-CY Nov 14, 2019
50fb9b4
chore: Test mode should not log all kinds of typeorm levels
ashchan Nov 14, 2019
a9c23e8
test: Delete mockDeleteAddressByWalletId
ashchan Nov 14, 2019
13e6ebe
chore(ci): Run wallet CI with runInBand option
ashchan Nov 14, 2019
15fed88
Merge pull request #1103 from Keith-CY/rename-interest-to-compensation
ashchan Nov 14, 2019
4de678c
Merge pull request #1100 from nervosnetwork/address-json-store
ashchan Nov 14, 2019
a7b463b
chore: Bump to v0.24.5
ashchan Nov 14, 2019
674cec4
docs: Update changelog
ashchan Nov 14, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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