Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
2026921
feat: verify address according to chain type
Keith-CY Nov 11, 2019
6f4c1d9
Update packages/neuron-ui/src/components/Send/index.tsx
Keith-CY Nov 11, 2019
98ba68d
feat(neuron-ui): add difficulty formatter (#1105)
Keith-CY Nov 14, 2019
4f70064
test(e2e): fix the test of invalid address.
Keith-CY Nov 11, 2019
ee7727a
refactor(neuron-ui): use MAINNET_TAG to distinguish chain type
Keith-CY Nov 14, 2019
2cb5047
feat(neuron-ui): update chain types on launch
Keith-CY Nov 14, 2019
1f3409c
chore: generate addresses if count <= 3
classicalliu Nov 14, 2019
abdab3f
fix(neuron): use deposit timestamp to calculate phase2 dao cell apc
Keith-CY Nov 14, 2019
1b66ea3
feat: Do not allow importing keystore from cli
ashchan Nov 14, 2019
a7dc73b
fix(neuron-ui): fix the missing field in error message.
Keith-CY Nov 14, 2019
fffd2f0
fix: next address order
classicalliu Nov 14, 2019
e4fc0d3
refactor(neuron-wallet): remove default chain type because they are u…
Keith-CY Nov 14, 2019
e17c47c
Merge pull request #1071 from Keith-CY/strengthen-address-validation
ashchan Nov 14, 2019
12deeb1
Merge pull request #1109 from Keith-CY/fix-error-message
Keith-CY Nov 14, 2019
108d5b1
feat: add depositTimestamp
classicalliu Nov 14, 2019
b0e2e33
Merge pull request #1108 from nervosnetwork/reject-cli-keystore
ashchan Nov 14, 2019
f00b241
Merge pull request #1110 from nervosnetwork/check-and-generate-address
ashchan Nov 14, 2019
e501072
fix(neuron-ui): remove sort of dao cells
Keith-CY Nov 14, 2019
9d1fcc4
Merge pull request #1111 from Keith-CY/remove-sort-of-dao-cells
classicalliu Nov 14, 2019
8d2e58d
Merge pull request #1106 from Keith-CY/update-chain-type-on-launch
ashchan Nov 14, 2019
e8ac6fb
Merge pull request #1112 from nervosnetwork/deposit-timestamp
Keith-CY Nov 14, 2019
b5d4b35
Merge pull request #1107 from Keith-CY/fix-withdraw-apc
Keith-CY Nov 14, 2019
e96ca61
feat(neuron-ui): use calculateGlobalAPC to update Nervos DAO APC
Keith-CY Nov 14, 2019
a52a531
feat: Let addresses regeneration happen before sync task starts
ashchan Nov 14, 2019
28bebd9
refactor(neuron-ui): set apc as a state in dao record row
Keith-CY Nov 14, 2019
b3e3d0e
feat(neuron-ui): hide the general settings and redirect to wallets se…
Keith-CY Nov 14, 2019
ad5fd4b
Merge pull request #1115 from nervosnetwork/gen-addresses-before-sync…
ashchan Nov 14, 2019
19d07bd
fix(neuron-ui): fix the missing of password request dialog
Keith-CY Nov 14, 2019
89aa04c
feat(neuron-ui): add a guide link to run a ckb mainnet node.
Keith-CY Nov 14, 2019
8c4c12a
Merge pull request #1113 from Keith-CY/update-apc-algorithm
ashchan Nov 14, 2019
df3eb0e
Merge pull request #1116 from Keith-CY/hide-general-settings
ashchan Nov 14, 2019
a7ab2c8
Update packages/neuron-ui/src/locales/en.json
Keith-CY Nov 15, 2019
a3a4220
Update packages/neuron-ui/src/locales/zh.json
Keith-CY Nov 15, 2019
1979e8a
feat: Preset mainnet network configuration
ashchan Nov 14, 2019
a3ccf2d
feat: Update all networks' chain and genesis hash when NetworkService
ashchan Nov 14, 2019
d8d9fa5
test: Fix networks tests
ashchan Nov 15, 2019
33b9e59
test: Update e2e tests to use mainnet address
ashchan Nov 15, 2019
ac30da1
test: Remove color option when running jest tests
ashchan Nov 15, 2019
17c1715
feat: If chain info couldn't be fetched set as ckb_dev
ashchan Nov 15, 2019
74b6fa3
test: Fix networks tests
ashchan Nov 15, 2019
5274edd
fix(neuron-ui): cache the genesis block timestamp in the nervos dao c…
Keith-CY Nov 15, 2019
9b5b52c
feat: Prefer network's chain and genesis hash when syncing
ashchan Nov 15, 2019
6c7117f
feat: Set current wallet to null if it's undefined
ashchan Nov 15, 2019
ce5e264
fix: add typeHash when generate dao tx
classicalliu Nov 15, 2019
952ae72
fix(neuron-ui): fix the missing word in i18n
Keith-CY Nov 15, 2019
2cded1c
fix(neuron-ui): hide the countdown if the current epoch number is gre…
Keith-CY Nov 15, 2019
e819439
feat(neuron-ui): update the warning in withdraw dialog.
Keith-CY Nov 15, 2019
97ee2a1
fix: capacity null when calculate bytes
classicalliu Nov 15, 2019
4f3e35d
test: Update e2e tests
ashchan Nov 15, 2019
0ca1f4a
Merge pull request #1117 from Keith-CY/add-user-guide-in-alert-message
ashchan Nov 15, 2019
2e45b68
Merge pull request #1121 from nervosnetwork/fix-generate-type-hash
classicalliu Nov 15, 2019
b5e4c34
Merge pull request #1122 from Keith-CY/hide-countdown-on-target-epoch
Keith-CY Nov 15, 2019
8a26a3f
Merge pull request #1123 from Keith-CY/update-notice-in-withdraw-dialog
Keith-CY Nov 15, 2019
20587f3
Merge pull request #1118 from nervosnetwork/mainnet-network
ashchan Nov 15, 2019
6664233
Merge branch 'develop' into fix-i18n
ashchan Nov 15, 2019
a83cd70
Merge pull request #1120 from Keith-CY/fix-i18n
ashchan Nov 15, 2019
63cc495
Merge pull request #1124 from nervosnetwork/fix-capacity-null
ashchan Nov 15, 2019
b8d4473
refactor(neuron-ui): use getHeaderByNumber instead of getBlockByNumbe…
Keith-CY Nov 15, 2019
0bec01e
feat(neuron-ui): update the hint of withdraw dialog
Keith-CY Nov 15, 2019
aba7ee5
Merge pull request #1119 from Keith-CY/cache-genesis-block-info
Keith-CY Nov 15, 2019
7d0cc67
feat(neuron-ui): add hint for synchronization not started.
Keith-CY Nov 15, 2019
5a6a3ca
Merge pull request #1125 from Keith-CY/update-i18n
Keith-CY Nov 15, 2019
cc3cd03
refactor(neuron-ui): convert block number into bigint for comparison
Keith-CY Nov 15, 2019
d97b877
Merge pull request #1126 from Keith-CY/hide-progress-if-synced-blockn…
Keith-CY Nov 15, 2019
a078e76
chore: Bump to v0.25.0
ashchan Nov 15, 2019
59f2dd5
feat(neuron-ui): add a guide bubble in connection status
Keith-CY Nov 15, 2019
9b85589
feat(neuron-ui): limit the times of guide bubble to 3
Keith-CY Nov 15, 2019
00b0068
Merge pull request #1127 from Keith-CY/add-disconnection-info-in-footer
Keith-CY Nov 15, 2019
0673343
feat: ChainInfo delegates Networks Service to get current chain
ashchan Nov 15, 2019
81f1eff
feat: Remove ChainInfo moving its feature into NetworksService
ashchan Nov 15, 2019
7cb8ad3
Merge pull request #1128 from nervosnetwork/better-chain-info
ashchan Nov 15, 2019
b8fe366
fix: update tx and its outputs in different sqls
classicalliu Nov 15, 2019
b9a5fca
Merge pull request #1130 from nervosnetwork/fix-save-exists-tx
ashchan Nov 15, 2019
761a4a8
feat: Always load genesis hash and chain info when
ashchan Nov 15, 2019
bd8e4e4
feat: If genesis hash doesn't match do not proceed to sync
ashchan Nov 15, 2019
cdbb1f5
Merge pull request #1131 from nervosnetwork/offline-history
ashchan Nov 15, 2019
c7b47d0
docs: Update changelog for v0.25.0
ashchan Nov 15, 2019
02c9bb5
chore: Update release date
ashchan Nov 15, 2019
9cee7ce
docs: Update changelog
ashchan Nov 15, 2019
c8a4132
chore: Set mainnet genesis hash
ashchan Nov 15, 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
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
# [0.25.0](https://github.com/nervosnetwork/neuron/compare/v0.24.5...v0.25.0) (2019-11-16)


### Bug Fixes

* capacity null when calculate bytes ([97ee2a1](https://github.com/nervosnetwork/neuron/commit/97ee2a1))
* update tx and its outputs in different sqls ([b8fe366](https://github.com/nervosnetwork/neuron/commit/b8fe366))
* **neuron:** use deposit timestamp to calculate phase2 dao cell apc ([abdab3f](https://github.com/nervosnetwork/neuron/commit/abdab3f))
* **neuron-ui:** cache the genesis block timestamp in the nervos dao component instead of in global ([5274edd](https://github.com/nervosnetwork/neuron/commit/5274edd))
* **neuron-ui:** fix the missing field in error message. ([a7dc73b](https://github.com/nervosnetwork/neuron/commit/a7dc73b))
* **neuron-ui:** fix the missing of password request dialog ([19d07bd](https://github.com/nervosnetwork/neuron/commit/19d07bd))
* **neuron-ui:** fix the missing word in i18n ([952ae72](https://github.com/nervosnetwork/neuron/commit/952ae72))
* **neuron-ui:** hide the countdown if the current epoch number is greater than the target epoch number. ([2cded1c](https://github.com/nervosnetwork/neuron/commit/2cded1c))
* add typeHash when generate dao tx ([ce5e264](https://github.com/nervosnetwork/neuron/commit/ce5e264))
* **neuron-ui:** remove sort of dao cells ([e501072](https://github.com/nervosnetwork/neuron/commit/e501072))
* next address order ([fffd2f0](https://github.com/nervosnetwork/neuron/commit/fffd2f0))


### Features

* Always load genesis hash and chain info when ([761a4a8](https://github.com/nervosnetwork/neuron/commit/761a4a8))
* ChainInfo delegates Networks Service to get current chain ([0673343](https://github.com/nervosnetwork/neuron/commit/0673343))
* If genesis hash doesn't match do not proceed to sync ([bd8e4e4](https://github.com/nervosnetwork/neuron/commit/bd8e4e4))
* Remove ChainInfo moving its feature into NetworksService ([81f1eff](https://github.com/nervosnetwork/neuron/commit/81f1eff))
* **neuron-ui:** add a guide bubble in connection status ([59f2dd5](https://github.com/nervosnetwork/neuron/commit/59f2dd5))
* **neuron-ui:** add a guide link to run a ckb mainnet node. ([89aa04c](https://github.com/nervosnetwork/neuron/commit/89aa04c))
* **neuron-ui:** add difficulty formatter ([#1105](https://github.com/nervosnetwork/neuron/issues/1105)) ([98ba68d](https://github.com/nervosnetwork/neuron/commit/98ba68d))
* **neuron-ui:** add hint for synchronization not started. ([7d0cc67](https://github.com/nervosnetwork/neuron/commit/7d0cc67))
* **neuron-ui:** hide the general settings and redirect to wallets setting ([b3e3d0e](https://github.com/nervosnetwork/neuron/commit/b3e3d0e))
* **neuron-ui:** limit the times of guide bubble to 3 ([9b85589](https://github.com/nervosnetwork/neuron/commit/9b85589))
* **neuron-ui:** update chain types on launch ([2cb5047](https://github.com/nervosnetwork/neuron/commit/2cb5047))
* **neuron-ui:** update the hint of withdraw dialog ([0bec01e](https://github.com/nervosnetwork/neuron/commit/0bec01e))
* **neuron-ui:** update the warning in withdraw dialog. ([e819439](https://github.com/nervosnetwork/neuron/commit/e819439))
* add depositTimestamp ([108d5b1](https://github.com/nervosnetwork/neuron/commit/108d5b1))
* Do not allow importing keystore from cli ([1b66ea3](https://github.com/nervosnetwork/neuron/commit/1b66ea3))
* If chain info couldn't be fetched set as ckb_dev ([17c1715](https://github.com/nervosnetwork/neuron/commit/17c1715))
* Let addresses regeneration happen before sync task starts ([a52a531](https://github.com/nervosnetwork/neuron/commit/a52a531))
* Prefer network's chain and genesis hash when syncing ([9b5b52c](https://github.com/nervosnetwork/neuron/commit/9b5b52c))
* Preset mainnet network configuration ([1979e8a](https://github.com/nervosnetwork/neuron/commit/1979e8a))
* Set current wallet to null if it's undefined ([6c7117f](https://github.com/nervosnetwork/neuron/commit/6c7117f))
* Update all networks' chain and genesis hash when NetworkService ([a3ccf2d](https://github.com/nervosnetwork/neuron/commit/a3ccf2d))
* **neuron-ui:** use calculateGlobalAPC to update Nervos DAO APC ([e96ca61](https://github.com/nervosnetwork/neuron/commit/e96ca61))
* verify address according to chain type ([2026921](https://github.com/nervosnetwork/neuron/commit/2026921))



## [0.24.5](https://github.com/nervosnetwork/neuron/compare/v0.24.4...v0.24.5) (2019-11-14)


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.5",
"version": "0.25.0",
"npmClient": "yarn",
"useWorkspaces": true
}
2 changes: 1 addition & 1 deletion 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.5",
"version": "0.25.0",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down
4 changes: 2 additions & 2 deletions 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.5",
"version": "0.25.0",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand All @@ -17,7 +17,7 @@
"scripts": {
"start": "react-app-rewired start",
"lint": "eslint --fix --ext .tsx,.ts,.js src",
"test": "react-app-rewired test --env=jsdom --color --watchAll=false",
"test": "react-app-rewired test --env=jsdom --watchAll=false",
"build": "react-app-rewired build",
"clean": "rimraf build/*",
"precommit": "lint-staged",
Expand Down
34 changes: 22 additions & 12 deletions packages/neuron-ui/src/components/CustomRows/DAORecordRow.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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 { ckbCore, getHeaderByNumber } from 'services/chain'
import { showMessage } from 'services/remote'
import calculateAPC from 'utils/calculateAPC'
import calculateGlobalAPC from 'utils/calculateGlobalAPC'
import { shannonToCKBFormatter, uniformTimeFormatter, localNumberFormatter } from 'utils/formatters'
import calculateClaimEpochNumber from 'utils/calculateClaimEpochNumber'
import { epochParser } from 'utils/parsers'
Expand All @@ -19,6 +19,8 @@ const DAORecord = ({
actionLabel,
onClick,
timestamp,
genesisBlockTimestamp,
depositTimestamp,
depositOutPoint,
epoch,
withdraw,
Expand All @@ -29,35 +31,43 @@ const DAORecord = ({
tipBlockNumber: string
epoch: string
withdraw: string | null
genesisBlockTimestamp: number | undefined
connectionStatus: 'online' | 'offline'
}) => {
const [t] = useTranslation()
const [withdrawingEpoch, setWithdrawingEpoch] = useState('')
const [depositEpoch, setDepositEpoch] = useState('')
const [apc, setApc] = useState(0)

useEffect(() => {
calculateGlobalAPC(+(depositTimestamp || timestamp), genesisBlockTimestamp).then(res => {
setApc(res)
})
}, [depositTimestamp, timestamp, genesisBlockTimestamp])

useEffect(() => {
if (!depositOutPoint) {
getBlockByNumber(BigInt(blockNumber))
.then(b => {
setDepositEpoch(b.header.epoch)
getHeaderByNumber(BigInt(blockNumber))
.then(header => {
setDepositEpoch(header.epoch)
})
.catch((err: Error) => {
console.error(err)
})
return
}
const depositBlockNumber = ckbCore.utils.bytesToHex(ckbCore.utils.hexToBytes(daoData).reverse())
getBlockByNumber(BigInt(depositBlockNumber))
.then(b => {
setDepositEpoch(b.header.epoch)
getHeaderByNumber(BigInt(depositBlockNumber))
.then(header => {
setDepositEpoch(header.epoch)
})
.catch((err: Error) => {
console.error(err)
})

getBlockByNumber(BigInt(blockNumber))
.then(b => {
setWithdrawingEpoch(b.header.epoch)
getHeaderByNumber(BigInt(blockNumber))
.then(header => {
setWithdrawingEpoch(header.epoch)
})
.catch((err: Error) => {
console.error(err)
Expand Down Expand Up @@ -142,7 +152,7 @@ const DAORecord = ({
</div>
</div>
<div className={styles.secondaryInfo}>
<span>{`APC: ~${calculateAPC(compensation.toString(), capacity, `${Date.now() - +timestamp}`)}%`}</span>
<span>{`APC: ~${apc}%`}</span>
<span>{uniformTimeFormatter(+timestamp)}</span>
<span>{metaInfo}</span>
</div>
Expand Down
17 changes: 10 additions & 7 deletions packages/neuron-ui/src/components/NervosDAO/WithdrawDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,20 @@ const WithdrawDialog = ({
const currentEpochInfo = epochParser(currentEpoch)
const targetEpochNumber = calculateTargetEpochNumber(depositEpochInfo, currentEpochInfo)
const epochs = targetEpochNumber - currentEpochInfo.number - BigInt(1)
const message = t('nervos-dao.notice-wait-time', {
epochs: localNumberFormatter(epochs),
blocks: localNumberFormatter(currentEpochInfo.length - currentEpochInfo.index),
days: localNumberFormatter(epochs / BigInt(6)),
})
const message =
epochs >= BigInt(0)
? t('nervos-dao.notice-wait-time', {
epochs: localNumberFormatter(epochs),
blocks: localNumberFormatter(currentEpochInfo.length - currentEpochInfo.index),
days: localNumberFormatter(epochs / BigInt(6)),
})
: ''

const alert =
epochs <= BigInt(5)
epochs <= BigInt(5) && epochs >= BigInt(0)
? t('nervos-dao.withdraw-alert', {
epochs,
nextLeftEpochs: epochs + BigInt(180),
hours: epochs * BigInt(4),
days: (epochs + BigInt(180)) / BigInt(6),
})
: ''
Expand Down
23 changes: 15 additions & 8 deletions packages/neuron-ui/src/components/NervosDAO/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { updateNervosDaoData, clearNervosDaoData } from 'states/stateProvider/ac
import calculateGlobalAPC from 'utils/calculateGlobalAPC'
import calculateFee from 'utils/calculateFee'
import { shannonToCKBFormatter, CKBToShannonFormatter } from 'utils/formatters'
import { MIN_DEPOSIT_AMOUNT, MEDIUM_FEE_RATE, SHANNON_CKB_RATIO, CapacityUnit } from 'utils/const'
import { MIN_DEPOSIT_AMOUNT, MEDIUM_FEE_RATE, SHANNON_CKB_RATIO, MAX_DECIMAL_DIGITS, CapacityUnit } from 'utils/const'
import { verifyAmount } from 'utils/validators'

import { generateDepositTx, generateWithdrawTx, generateClaimTx } from 'services/remote'
import { ckbCore } from 'services/chain'
import { ckbCore, getHeaderByNumber } from 'services/chain'
import { epochParser } from 'utils/parsers'

import DAORecord from 'components/CustomRows/DAORecordRow'
Expand Down Expand Up @@ -46,6 +46,7 @@ const NervosDAO = ({
const [errorMessage, setErrorMessage] = useState('')
const [withdrawList, setWithdrawList] = useState<(string | null)[]>([])
const [globalAPC, setGlobalAPC] = useState(0)
const [genesisBlockTimestamp, setGenesisBlockTimestamp] = useState<number | undefined>(undefined)

const clearGeneratedTx = useCallback(() => {
dispatch({
Expand All @@ -66,7 +67,7 @@ const NervosDAO = ({

const verifyRes = verifyAmount(value)
if (verifyRes !== true) {
setErrorMessage(t(`messages.codes.${verifyRes.code}`, { fieldName: 'deposit' }))
setErrorMessage(t(`messages.codes.${verifyRes.code}`, { fieldName: 'deposit', length: MAX_DECIMAL_DIGITS }))
return
}

Expand Down Expand Up @@ -98,6 +99,9 @@ const NervosDAO = ({
useEffect(() => {
updateNervosDaoData({ walletID: wallet.id })(dispatch)
updateDepositValue(`${MIN_DEPOSIT_AMOUNT}`)
getHeaderByNumber('0x0')
.then(header => setGenesisBlockTimestamp(+header.timestamp))
.catch(err => console.error(err))
return () => {
clearNervosDaoData()(dispatch)
clearGeneratedTx()
Expand All @@ -106,11 +110,13 @@ const NervosDAO = ({

useEffect(() => {
if (tipBlockTimestamp) {
calculateGlobalAPC(tipBlockTimestamp).then(apc => {
setGlobalAPC(apc)
})
calculateGlobalAPC(tipBlockTimestamp, genesisBlockTimestamp)
.then(apc => {
setGlobalAPC(apc)
})
.catch(err => console.error(err))
}
}, [tipBlockTimestamp])
}, [tipBlockTimestamp, genesisBlockTimestamp])

const onDepositDialogDismiss = () => {
setShowDepositDialog(false)
Expand Down Expand Up @@ -276,14 +282,15 @@ const NervosDAO = ({
onClick={onActionClick}
tipBlockNumber={tipBlockNumber}
epoch={epoch}
genesisBlockTimestamp={genesisBlockTimestamp}
connectionStatus={connectionStatus}
/>
)
})}
</Stack>
</>
)
}, [records, withdrawList, t, onActionClick, tipBlockNumber, epoch, connectionStatus])
}, [records, withdrawList, t, onActionClick, tipBlockNumber, epoch, connectionStatus, genesisBlockTimestamp])

const free = BigInt(wallet.balance)
const locked = withdrawList.reduce((acc, w) => acc + BigInt(w || 0), BigInt(0))
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-ui/src/components/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PropertyList, { Property } from 'widgets/PropertyList'
import { StateWithDispatch } from 'states/stateProvider/reducer'
import { updateTransactionList } from 'states/stateProvider/actionCreators'

import { localNumberFormatter, shannonToCKBFormatter } from 'utils/formatters'
import { localNumberFormatter, shannonToCKBFormatter, difficultyFormatter } from 'utils/formatters'
import { epochParser } from 'utils/parsers'
import { PAGE_SIZE, Routes, CONFIRMATION_THRESHOLD } from 'utils/const'
import { backToTop } from 'utils/animations'
Expand Down Expand Up @@ -104,7 +104,7 @@ const Overview = ({
},
{
label: t('overview.difficulty'),
value: localNumberFormatter(+difficulty),
value: difficultyFormatter(difficulty),
},
],
[t, chain, epoch, difficulty, tipBlockNumber]
Expand Down
10 changes: 8 additions & 2 deletions packages/neuron-ui/src/components/Send/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,17 @@ export const useInitialize = (
clear(dispatch)
}, [walletID, dispatch])

const onGetAddressErrorMessage = useCallback(
(addr: string) => {
const onGetAddressErrorMessage: (isMainnet: boolean) => (addr: string) => string = useCallback(
(isMainnet: boolean) => (addr: string) => {
if (addr === '') {
return t(`messages.codes.${ErrorCode.AddressIsEmpty}`)
}
if (isMainnet && !addr.startsWith('ckb')) {
return t(`messages.mainnet-address-required`)
}
if (!isMainnet && !addr.startsWith('ckt')) {
return t(`messages.testnet-address-required`)
}
if (!verifyAddress(addr)) {
return t(`messages.codes.${ErrorCode.FieldInvalid}`, {
fieldName: 'address',
Expand Down
9 changes: 6 additions & 3 deletions packages/neuron-ui/src/components/Send/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import QRScanner from 'widgets/QRScanner'
import { StateWithDispatch } from 'states/stateProvider/reducer'
import appState from 'states/initStates/app'

import { PlaceHolders, CapacityUnit, ErrorCode } from 'utils/const'
import { PlaceHolders, CapacityUnit, ErrorCode, MAINNET_TAG } from 'utils/const'
import { shannonToCKBFormatter } from 'utils/formatters'

import { verifyTotalAmount } from 'utils/validators'
Expand All @@ -38,7 +38,8 @@ const Send = ({
loadings: { sending = false },
},
wallet: { id: walletID = '', balance = '' },
chain: { connectionStatus },
chain: { networkID, connectionStatus },
settings: { networks = [] },
dispatch,
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps<{ address: string }>>) => {
const { t } = useTranslation()
Expand Down Expand Up @@ -66,6 +67,8 @@ const Send = ({
const errorMessageUnderTotal = verifyTotalAmount(totalAmount, fee, balance)
? errorMessage
: t(`messages.codes.${ErrorCode.AmountNotEnough}`)
const network = networks.find(n => n.id === networkID)
const isMainnet = (network && network.chain === MAINNET_TAG) || false

return (
<Stack verticalFill tokens={{ childrenGap: 15, padding: '20px 0 0 0' }}>
Expand Down Expand Up @@ -97,7 +100,7 @@ const Send = ({
onChange={onItemChange}
required
validateOnLoad={false}
onGetErrorMessage={onGetAddressErrorMessage}
onGetErrorMessage={onGetAddressErrorMessage(isMainnet)}
/>
</Stack.Item>
<Stack styles={{ root: { width: '48px' } }} verticalAlign="start">
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/components/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { WalletWizardPath } from 'components/WalletWizard'
import { Routes } from 'utils/const'

const pivotItems = [
{ label: 'settings.setting-tabs.general', url: Routes.SettingsGeneral },
// { label: 'settings.setting-tabs.general', url: Routes.SettingsGeneral },
{ label: 'settings.setting-tabs.wallets', url: Routes.SettingsWallets },
{ label: 'settings.setting-tabs.network', url: Routes.SettingsNetworks },
]
Expand Down
Loading