From 13f0abaf07d7a96fbc7cb8b88de0686efb824204 Mon Sep 17 00:00:00 2001 From: devchenyan Date: Wed, 22 Nov 2023 22:12:21 +0800 Subject: [PATCH 1/9] fix: some ui issue --- packages/neuron-ui/src/components/NetworkSetting/index.tsx | 6 +++++- .../TransactionStatusWrap/transactionStatusWrap.module.scss | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/neuron-ui/src/components/NetworkSetting/index.tsx b/packages/neuron-ui/src/components/NetworkSetting/index.tsx index e82447e235..7af39881f5 100644 --- a/packages/neuron-ui/src/components/NetworkSetting/index.tsx +++ b/packages/neuron-ui/src/components/NetworkSetting/index.tsx @@ -101,7 +101,11 @@ const NetworkSetting = ({ chain = chainState, settings: { networks = [] } }: Sta value: network.id, label: (
-

{`${network.name} (${network.remote})`}

+

{`${network.name} (${ + network.remote.length > 40 + ? `${network.remote.slice(0, 20)}...${network.remote.slice(-20)}` + : network.remote + })`}

{t(getNetworkLabelI18nkey(network.chain))}
), diff --git a/packages/neuron-ui/src/components/TransactionStatusWrap/transactionStatusWrap.module.scss b/packages/neuron-ui/src/components/TransactionStatusWrap/transactionStatusWrap.module.scss index 7e87b9f483..c19f1df9b9 100644 --- a/packages/neuron-ui/src/components/TransactionStatusWrap/transactionStatusWrap.module.scss +++ b/packages/neuron-ui/src/components/TransactionStatusWrap/transactionStatusWrap.module.scss @@ -20,5 +20,6 @@ color: #999; font-size: 12px; margin-left: 4px; + white-space: nowrap; } } From 5847658378857cbba7496e3201517c0430e8a561 Mon Sep 17 00:00:00 2001 From: devchenyan Date: Sun, 26 Nov 2023 12:01:36 +0800 Subject: [PATCH 2/9] fix: some ui issue --- .../src/components/GeneralSetting/index.tsx | 12 +++++++++--- .../src/components/History/history.module.scss | 7 +++++++ packages/neuron-ui/src/components/History/index.tsx | 10 +++++++++- packages/neuron-ui/src/containers/Main/hooks.ts | 1 + packages/neuron-ui/src/widgets/Icons/Clean.svg | 3 +++ packages/neuron-ui/src/widgets/Icons/icon.tsx | 3 ++- 6 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 packages/neuron-ui/src/widgets/Icons/Clean.svg diff --git a/packages/neuron-ui/src/components/GeneralSetting/index.tsx b/packages/neuron-ui/src/components/GeneralSetting/index.tsx index 8819e4b5eb..ffa7090d5f 100644 --- a/packages/neuron-ui/src/components/GeneralSetting/index.tsx +++ b/packages/neuron-ui/src/components/GeneralSetting/index.tsx @@ -56,6 +56,14 @@ const UpdateDownloadStatus = ({ return { __html: releaseNotes } } + const versionText = () => { + let text = releaseNotes.match(/(?<=

).*?(?=<\/h1>)/)?.[0] + if (!text) { + text = `${newVersion} (${uniformTimeFormatter(new Date(releaseDate)).split(' ')[0]})` + } + return text + } + /* eslint-disable react/no-danger */ return ( @@ -71,9 +79,7 @@ const UpdateDownloadStatus = ({ }} >
-

- {newVersion} ({uniformTimeFormatter(new Date(releaseDate)).split(' ')[0]}) -

+

{versionText()}

diff --git a/packages/neuron-ui/src/components/History/history.module.scss b/packages/neuron-ui/src/components/History/history.module.scss index 61438e54d6..5f210ad382 100644 --- a/packages/neuron-ui/src/components/History/history.module.scss +++ b/packages/neuron-ui/src/components/History/history.module.scss @@ -37,6 +37,13 @@ body { font-weight: 500; padding-right: 10px; } + .searchBoxSuffix { + font-family: inherit; + display: flex; + align-items: center; + padding-left: 10px; + cursor: pointer; + } .exportButton { color: var(--main-text-color); border-color: var(--history-button-border); diff --git a/packages/neuron-ui/src/components/History/index.tsx b/packages/neuron-ui/src/components/History/index.tsx index 1329d5281b..38c96c5429 100644 --- a/packages/neuron-ui/src/components/History/index.tsx +++ b/packages/neuron-ui/src/components/History/index.tsx @@ -6,7 +6,7 @@ import SUDTAvatar from 'widgets/SUDTAvatar' import Button from 'widgets/Button' import Table, { TableProps } from 'widgets/Table' import TextField from 'widgets/TextField' -import { Download, Search, ArrowNext } from 'widgets/Icons/icon' +import { Download, Search, ArrowNext, Clean } from 'widgets/Icons/icon' import PageContainer from 'components/PageContainer' import TransactionStatusWrap from 'components/TransactionStatusWrap' @@ -47,6 +47,7 @@ const History = () => { const { keywords, onKeywordsChange } = useSearch(search, id, dispatch) const onSearch = useCallback(() => navigate(`${RoutePath.History}?keywords=${keywords}`), [navigate, keywords]) + const onClean = useCallback(() => onKeywordsChange(undefined, ''), [onKeywordsChange]) const onExport = useCallback(() => { setIsExporting(true) const timer = setTimeout(() => { @@ -183,6 +184,13 @@ const History = () => { } + suffix={ + keywords ? ( + + + + ) : null + } placeholder={t('history.search.placeholder')} className={styles.tableHeaderInput} stack={false} diff --git a/packages/neuron-ui/src/containers/Main/hooks.ts b/packages/neuron-ui/src/containers/Main/hooks.ts index b332e2ca9d..3111c1ca43 100644 --- a/packages/neuron-ui/src/containers/Main/hooks.ts +++ b/packages/neuron-ui/src/containers/Main/hooks.ts @@ -198,6 +198,7 @@ export const useSubscription = ({ }) CONNECTING_DEADLINE = Date.now() + CONNECTING_BUFFER currentNetworkIDCache.save(currentNetworkID) + updateAddressListAndBalance(walletID)(dispatch) }) const connectionStatusSubscription = ConnectionStatusSubject.subscribe(status => { if (isCurrentUrl(status.url)) { diff --git a/packages/neuron-ui/src/widgets/Icons/Clean.svg b/packages/neuron-ui/src/widgets/Icons/Clean.svg new file mode 100644 index 0000000000..9edcc0df86 --- /dev/null +++ b/packages/neuron-ui/src/widgets/Icons/Clean.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/neuron-ui/src/widgets/Icons/icon.tsx b/packages/neuron-ui/src/widgets/Icons/icon.tsx index 542cb2843d..a38b9d0891 100644 --- a/packages/neuron-ui/src/widgets/Icons/icon.tsx +++ b/packages/neuron-ui/src/widgets/Icons/icon.tsx @@ -46,7 +46,7 @@ import { ReactComponent as AddressbookSvg } from './Addressbook.svg' import { ReactComponent as AddSvg } from './Add.svg' import { ReactComponent as AddSimpleSvg } from './AddSimple.svg' import { ReactComponent as SwitchSvg } from './Switch.svg' - +import { ReactComponent as CleanSvg } from './Clean.svg' import styles from './icon.module.scss' function WrapSvg(SvgComponent: React.FC>, classNameForTheme: string = '') { @@ -108,3 +108,4 @@ export const Addressbook = WrapSvg(AddressbookSvg) export const Add = WrapSvg(AddSvg) export const Switch = WrapSvg(SwitchSvg) export const AddSimple = WrapSvg(AddSimpleSvg) +export const Clean = WrapSvg(CleanSvg) From 3e81350da8263a51341ad23645a780d96cddadfc Mon Sep 17 00:00:00 2001 From: devchenyan Date: Mon, 27 Nov 2023 12:15:17 +0800 Subject: [PATCH 3/9] feat: validateCapacity --- .../neuron-ui/src/components/Send/index.tsx | 2 +- .../SendFromMultisigDialog/hooks.ts | 4 ++-- packages/neuron-ui/src/exceptions/amount.ts | 12 ++++++++++ packages/neuron-ui/src/utils/hooks/index.ts | 9 +++++--- .../src/utils/validators/capacity.ts | 22 +++++++++++++++++++ .../neuron-ui/src/utils/validators/index.ts | 1 + 6 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 packages/neuron-ui/src/utils/validators/capacity.ts diff --git a/packages/neuron-ui/src/components/Send/index.tsx b/packages/neuron-ui/src/components/Send/index.tsx index 97240daadb..05b2cb61ca 100644 --- a/packages/neuron-ui/src/components/Send/index.tsx +++ b/packages/neuron-ui/src/components/Send/index.tsx @@ -169,7 +169,7 @@ const Send = () => { !send.generatedTx || outputs.some(v => !v.address) - const outputErrors = useOutputErrors(outputs, isMainnet) + const outputErrors = useOutputErrors(outputs, isMainnet, isSendMax) const isMaxBtnDisabled = (() => { try { diff --git a/packages/neuron-ui/src/components/SendFromMultisigDialog/hooks.ts b/packages/neuron-ui/src/components/SendFromMultisigDialog/hooks.ts index e183db9ff0..e2463e3c31 100644 --- a/packages/neuron-ui/src/components/SendFromMultisigDialog/hooks.ts +++ b/packages/neuron-ui/src/components/SendFromMultisigDialog/hooks.ts @@ -133,7 +133,8 @@ export const useSendInfo = ({ }, [setSendInfoList] ) - const outputErrors = useOutputErrors(sendInfoList, isMainnet) + const [isSendMax, setIsSendMax] = useState(false) + const outputErrors = useOutputErrors(sendInfoList, isMainnet, isSendMax) const totalAmount = useMemo( () => outputsToTotalAmount(sendInfoList.filter((v, idx) => !!v.amount && !outputErrors[idx].amountError)), [sendInfoList, outputErrors] @@ -172,7 +173,6 @@ export const useSendInfo = ({ } }, 300) }, [sendInfoList, setErrorMessage, multisigConfig, dispatch, t, isMainnet, outputErrors]) - const [isSendMax, setIsSendMax] = useState(false) const onSendMaxClick = useCallback(() => { if (!isSendMax) { setIsSendMax(true) diff --git a/packages/neuron-ui/src/exceptions/amount.ts b/packages/neuron-ui/src/exceptions/amount.ts index f24fd01d78..f148c17714 100644 --- a/packages/neuron-ui/src/exceptions/amount.ts +++ b/packages/neuron-ui/src/exceptions/amount.ts @@ -56,3 +56,15 @@ export class AmountNegativeException extends RangeError { this.i18n.fieldValue = value } } + +export class CapacityTooSmallException extends Error { + public code = ErrorCode.CapacityTooSmall + public i18n: { + bytes: string + } + + constructor(bytes: string) { + super(`${I18N_PATH}${ErrorCode.CapacityTooSmall}`) + this.i18n = { bytes } + } +} diff --git a/packages/neuron-ui/src/utils/hooks/index.ts b/packages/neuron-ui/src/utils/hooks/index.ts index 0d2d63f131..a706e78ce1 100644 --- a/packages/neuron-ui/src/utils/hooks/index.ts +++ b/packages/neuron-ui/src/utils/hooks/index.ts @@ -23,6 +23,7 @@ import { validateAmount, validateAddress, validateAmountRange, + validateCapacity, } from 'utils/validators' import { MenuItemConstructorOptions, shell } from 'electron' import { ErrorWithI18n, isErrorWithI18n } from 'exceptions' @@ -499,18 +500,20 @@ export const useForceUpdate = void>(cb: T) => { } export const useOutputErrors = ( - outputs: Partial>[], - isMainnet: boolean + outputs: Partial>[], + isMainnet: boolean, + isSendMax?: boolean ) => { return useMemo( () => - outputs.map(({ address, amount, date }) => { + outputs.map(({ address, amount, date, unit }, index) => { let amountError: ErrorWithI18n | undefined if (amount !== undefined) { try { const extraSize = date ? CONSTANTS.SINCE_FIELD_SIZE : 0 validateAmount(amount) validateAmountRange(amount, extraSize) + validateCapacity({ address, amount, unit }, isSendMax, index === outputs.length - 1) } catch (err) { if (isErrorWithI18n(err)) { amountError = err diff --git a/packages/neuron-ui/src/utils/validators/capacity.ts b/packages/neuron-ui/src/utils/validators/capacity.ts new file mode 100644 index 0000000000..d43ce6d19a --- /dev/null +++ b/packages/neuron-ui/src/utils/validators/capacity.ts @@ -0,0 +1,22 @@ +import { CKBToShannonFormatter } from 'utils/formatters' +import { CapacityTooSmallException } from 'exceptions' +import { bytes as byteUtils } from '@ckb-lumos/codec' +import { ckbCore } from 'services/chain' + +export const validateCapacity = (item: State.Output, isSendMax?: boolean, isLast?: boolean) => { + const { amount, unit, address } = item + const capacity = CKBToShannonFormatter(amount, unit) + const script = ckbCore.utils.addressToScript(address as string) + + const size = 1 + byteUtils.concat(script.args, script.codeHash).byteLength + const outputSize = 8 + byteUtils.bytify('0x').byteLength + size + + const judgement = isSendMax ? !isLast : true + + if (BigInt(capacity) < BigInt(outputSize) * BigInt(10 ** 8) && judgement) { + throw new CapacityTooSmallException(outputSize.toString()) + } + + return true +} +export default validateCapacity diff --git a/packages/neuron-ui/src/utils/validators/index.ts b/packages/neuron-ui/src/utils/validators/index.ts index f17bd58683..9a2e61c4e6 100644 --- a/packages/neuron-ui/src/utils/validators/index.ts +++ b/packages/neuron-ui/src/utils/validators/index.ts @@ -13,3 +13,4 @@ export * from './tokenId' export * from './tokenName' export * from './symbol' export * from './decimal' +export * from './capacity' From 88bd62bf0e8b360126a222e3a1b033a3d67497a7 Mon Sep 17 00:00:00 2001 From: devchenyan Date: Wed, 29 Nov 2023 11:10:57 +0800 Subject: [PATCH 4/9] fix: syncIcon --- .../components/BalanceSyncingIcon/balanceSyncIcon.module.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/neuron-ui/src/components/BalanceSyncingIcon/balanceSyncIcon.module.scss b/packages/neuron-ui/src/components/BalanceSyncingIcon/balanceSyncIcon.module.scss index 116c7a0466..c51b395b6a 100644 --- a/packages/neuron-ui/src/components/BalanceSyncingIcon/balanceSyncIcon.module.scss +++ b/packages/neuron-ui/src/components/BalanceSyncingIcon/balanceSyncIcon.module.scss @@ -5,6 +5,6 @@ margin-left: 4px; path { - fill: #ffffff; + fill: var(--main-text-color); } } From fd086e2ab57d9d0e32e9ccfdb4eb4943cf0f0d7e Mon Sep 17 00:00:00 2001 From: devchenyan Date: Mon, 4 Dec 2023 14:56:26 +0800 Subject: [PATCH 5/9] fix: comments --- .../src/components/GeneralSetting/index.tsx | 12 +++------ .../src/tests/validators/capacity/fixtures.ts | 20 +++++++++++++++ .../tests/validators/capacity/index.test.ts | 25 +++++++++++++++++++ packages/neuron-ui/src/utils/hooks/index.ts | 4 ++- .../src/utils/validators/capacity.ts | 7 ++---- .../neuron-wallet/src/controllers/update.ts | 16 +++++++++--- 6 files changed, 65 insertions(+), 19 deletions(-) create mode 100644 packages/neuron-ui/src/tests/validators/capacity/fixtures.ts create mode 100644 packages/neuron-ui/src/tests/validators/capacity/index.test.ts diff --git a/packages/neuron-ui/src/components/GeneralSetting/index.tsx b/packages/neuron-ui/src/components/GeneralSetting/index.tsx index ffa7090d5f..8819e4b5eb 100644 --- a/packages/neuron-ui/src/components/GeneralSetting/index.tsx +++ b/packages/neuron-ui/src/components/GeneralSetting/index.tsx @@ -56,14 +56,6 @@ const UpdateDownloadStatus = ({ return { __html: releaseNotes } } - const versionText = () => { - let text = releaseNotes.match(/(?<=

).*?(?=<\/h1>)/)?.[0] - if (!text) { - text = `${newVersion} (${uniformTimeFormatter(new Date(releaseDate)).split(' ')[0]})` - } - return text - } - /* eslint-disable react/no-danger */ return ( @@ -79,7 +71,9 @@ const UpdateDownloadStatus = ({ }} >
-

{versionText()}

+

+ {newVersion} ({uniformTimeFormatter(new Date(releaseDate)).split(' ')[0]}) +

diff --git a/packages/neuron-ui/src/tests/validators/capacity/fixtures.ts b/packages/neuron-ui/src/tests/validators/capacity/fixtures.ts new file mode 100644 index 0000000000..002fcad53b --- /dev/null +++ b/packages/neuron-ui/src/tests/validators/capacity/fixtures.ts @@ -0,0 +1,20 @@ +import { ErrorCode } from 'utils/enums' + +export default { + 'Should throw an error when address is not a string': { + params: { + address: 'ckb1qrgqep8saj8agswr30pls73hra28ry8jlnlc3ejzh3dl2ju7xxpjxqgqqy28n5m69va267nv0wvsudngtxz8t9jwss3xkhpk', + amount: '62', + unit: 'ckb', + }, + exception: ErrorCode.CapacityTooSmall, + }, + 'Should throw an error when address is required but not provided': { + params: { + address: 'ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2n0egquval9ljqm2ga6t9509kwcex5ejq3hy6dk', + amount: '62', + unit: 'ckb', + }, + exception: null, + }, +} diff --git a/packages/neuron-ui/src/tests/validators/capacity/index.test.ts b/packages/neuron-ui/src/tests/validators/capacity/index.test.ts new file mode 100644 index 0000000000..d750f0b52f --- /dev/null +++ b/packages/neuron-ui/src/tests/validators/capacity/index.test.ts @@ -0,0 +1,25 @@ +import { describe, test, expect } from '@jest/globals' +import { isErrorWithI18n } from 'exceptions' +import { validateCapacity } from 'utils/validators' +import fixtures from './fixtures' + +const fixtureTable: Fixture.Validator[] = Object.entries(fixtures).map( + ([title, { params, exception }]) => [title, [params], exception] +) + +describe(`Test capacity validator`, () => { + test.each(fixtureTable)(`%s`, (_title, [params], exception) => { + if (exception) { + expect.assertions(2) + try { + validateCapacity(params) + } catch (err) { + expect(isErrorWithI18n(err)).toBeTruthy() + expect((err as { code: number }).code).toBe(exception) + } + } else { + expect.assertions(1) + expect(validateCapacity(params)).toBeTruthy() + } + }) +}) diff --git a/packages/neuron-ui/src/utils/hooks/index.ts b/packages/neuron-ui/src/utils/hooks/index.ts index a706e78ce1..9496c06422 100644 --- a/packages/neuron-ui/src/utils/hooks/index.ts +++ b/packages/neuron-ui/src/utils/hooks/index.ts @@ -513,7 +513,9 @@ export const useOutputErrors = ( const extraSize = date ? CONSTANTS.SINCE_FIELD_SIZE : 0 validateAmount(amount) validateAmountRange(amount, extraSize) - validateCapacity({ address, amount, unit }, isSendMax, index === outputs.length - 1) + if (!(isSendMax && index === outputs.length - 1)) { + validateCapacity({ address, amount, unit }) + } } catch (err) { if (isErrorWithI18n(err)) { amountError = err diff --git a/packages/neuron-ui/src/utils/validators/capacity.ts b/packages/neuron-ui/src/utils/validators/capacity.ts index d43ce6d19a..2f3a53f0c6 100644 --- a/packages/neuron-ui/src/utils/validators/capacity.ts +++ b/packages/neuron-ui/src/utils/validators/capacity.ts @@ -3,17 +3,14 @@ import { CapacityTooSmallException } from 'exceptions' import { bytes as byteUtils } from '@ckb-lumos/codec' import { ckbCore } from 'services/chain' -export const validateCapacity = (item: State.Output, isSendMax?: boolean, isLast?: boolean) => { +export const validateCapacity = (item: State.Output) => { const { amount, unit, address } = item const capacity = CKBToShannonFormatter(amount, unit) const script = ckbCore.utils.addressToScript(address as string) - const size = 1 + byteUtils.concat(script.args, script.codeHash).byteLength const outputSize = 8 + byteUtils.bytify('0x').byteLength + size - const judgement = isSendMax ? !isLast : true - - if (BigInt(capacity) < BigInt(outputSize) * BigInt(10 ** 8) && judgement) { + if (BigInt(capacity) < BigInt(outputSize) * BigInt(10 ** 8)) { throw new CapacityTooSmallException(outputSize.toString()) } diff --git a/packages/neuron-wallet/src/controllers/update.ts b/packages/neuron-wallet/src/controllers/update.ts index 2be6ea3c71..e8a0dacab8 100644 --- a/packages/neuron-wallet/src/controllers/update.ts +++ b/packages/neuron-wallet/src/controllers/update.ts @@ -1,4 +1,5 @@ import { autoUpdater, UpdateInfo, CancellationToken, ProgressInfo } from 'electron-updater' +import { net } from 'electron' import AppUpdaterSubject, { AppUpdater } from '../models/subjects/app-updater' import logger from '../utils/logger' @@ -76,11 +77,18 @@ export default class UpdateController { if (UpdateController.isChecking) { UpdateController.isChecking = false UpdateController.updatePackageSize = info.files[0].size ?? 0 - this.notify({ - version: info.version, - releaseDate: info.releaseDate, - releaseNotes: info.releaseNotes as string, + const request = net.request(`https://api.github.com/repos/nervosnetwork/neuron/releases/tags/v${info.version}`) + request.on('response', response => { + response.on('data', chunk => { + const res = JSON.parse(chunk.toString()) + this.notify({ + version: info.version, + releaseDate: res.published_at, + releaseNotes: info.releaseNotes as string, + }) + }) }) + request.end() } }) From 824b544d3b48ac30d288b177437c878e0b838d1d Mon Sep 17 00:00:00 2001 From: devchenyan Date: Tue, 5 Dec 2023 10:19:38 +0800 Subject: [PATCH 6/9] fix: releaseDate --- .../neuron-ui/src/components/GeneralSetting/index.tsx | 2 +- packages/neuron-wallet/src/controllers/update.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/neuron-ui/src/components/GeneralSetting/index.tsx b/packages/neuron-ui/src/components/GeneralSetting/index.tsx index 8819e4b5eb..c5e04b2edb 100644 --- a/packages/neuron-ui/src/components/GeneralSetting/index.tsx +++ b/packages/neuron-ui/src/components/GeneralSetting/index.tsx @@ -72,7 +72,7 @@ const UpdateDownloadStatus = ({ >

- {newVersion} ({uniformTimeFormatter(new Date(releaseDate)).split(' ')[0]}) + {newVersion} {releaseDate ? `(${uniformTimeFormatter(new Date(releaseDate)).split(' ')[0]})` : null}

diff --git a/packages/neuron-wallet/src/controllers/update.ts b/packages/neuron-wallet/src/controllers/update.ts index e8a0dacab8..72b68cf695 100644 --- a/packages/neuron-wallet/src/controllers/update.ts +++ b/packages/neuron-wallet/src/controllers/update.ts @@ -83,11 +83,18 @@ export default class UpdateController { const res = JSON.parse(chunk.toString()) this.notify({ version: info.version, - releaseDate: res.published_at, + releaseDate: res?.published_at || '', releaseNotes: info.releaseNotes as string, }) }) }) + request.on('error', () => { + this.notify({ + version: info.version, + releaseDate: '', + releaseNotes: info.releaseNotes as string, + }) + }) request.end() } }) From 71c29174ea37f652662037827c18d85e98571f65 Mon Sep 17 00:00:00 2001 From: devchenyan Date: Thu, 14 Dec 2023 10:45:52 +0800 Subject: [PATCH 7/9] fix: Issue on UI withdrawing from NervosDao --- .../components/GeneralSetting/generalSetting.module.scss | 6 ++++++ packages/neuron-ui/src/locales/en.json | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/neuron-ui/src/components/GeneralSetting/generalSetting.module.scss b/packages/neuron-ui/src/components/GeneralSetting/generalSetting.module.scss index c9fb6d0603..e55142e967 100644 --- a/packages/neuron-ui/src/components/GeneralSetting/generalSetting.module.scss +++ b/packages/neuron-ui/src/components/GeneralSetting/generalSetting.module.scss @@ -85,6 +85,12 @@ $action-button-width: 11.25rem; background: var(--table-head-background-color); color: var(--dialog-secondary-text-color); + h1 { + &:first-child { + display: none; + } + } + ul { list-style-type: disc; padding-left: 30px; diff --git a/packages/neuron-ui/src/locales/en.json b/packages/neuron-ui/src/locales/en.json index 0720469ccc..08c1ba3add 100644 --- a/packages/neuron-ui/src/locales/en.json +++ b/packages/neuron-ui/src/locales/en.json @@ -678,7 +678,7 @@ "cancel": "Cancel", "proceed": "Proceed", "compensation": "Compensation", - "notice-wait-time": "Notice: You are initiating withdrawn and the final withdrawn will need to wait for {{epochs}} epochs {{blocks}} blocks (about {{days} days).", + "notice-wait-time": "Notice: You are initiating withdrawn and the final withdrawn will need to wait for {{epochs}} epochs {{blocks}} blocks (about {{days}} days).", "deposit-dialog-title": "Deposit", "deposit-terms": "Nervos DAO needs 102 CKBytes for deposit cell storage, which is not compensation-bearing.
Please visit the <0>Nervos DAO RFC for more information about Nervos DAO", "minimal-fee-required": "The minimum deposit capacity is {{minimal}} CKBytes", @@ -728,7 +728,7 @@ "nervos-dao-detail": { "tx-detail": "Transaction Detail", "deposited": "Deposited", - "withdrawn": "Withdrawn", + "withdrawn": "Withdraw", "unlocked": "Unlocked", "basic-information": "Basic Information", "transaction-hash": "Transaction Hash", From 2a884ea293006a8421b58bf60329c0c0a4be0c91 Mon Sep 17 00:00:00 2001 From: devchenyan Date: Fri, 15 Dec 2023 20:41:19 +0800 Subject: [PATCH 8/9] fix: releaseDate --- .../src/components/GeneralSetting/index.tsx | 18 +++++++++++---- .../neuron-wallet/src/controllers/update.ts | 23 ++++--------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/packages/neuron-ui/src/components/GeneralSetting/index.tsx b/packages/neuron-ui/src/components/GeneralSetting/index.tsx index c5e04b2edb..877ead8315 100644 --- a/packages/neuron-ui/src/components/GeneralSetting/index.tsx +++ b/packages/neuron-ui/src/components/GeneralSetting/index.tsx @@ -18,7 +18,6 @@ interface UpdateDownloadStatusProps { onCancel: () => void progress: number newVersion: string - releaseDate: string releaseNotes: string progressInfo: null | State.ProgressInfo } @@ -28,13 +27,13 @@ const UpdateDownloadStatus = ({ onCancel, progress = 0, newVersion = '', - releaseDate = '', releaseNotes = '', progressInfo, }: UpdateDownloadStatusProps) => { const [t] = useTranslation() const available = newVersion !== '' && progress < 0 const downloaded = progress >= 1 + const [publisedAt, setPublisedAt] = useState('') const handleConfirm = useCallback( (e: React.FormEvent) => { @@ -51,6 +50,18 @@ const UpdateDownloadStatus = ({ [downloadUpdate, installUpdate] ) + useEffect(() => { + if (available) { + fetch(`https://api.github.com/repos/nervosnetwork/neuron/releases/tags/v${newVersion}`) + .then(async res => { + // eslint-disable-next-line camelcase + const { published_at } = await res.json() + setPublisedAt(published_at) + }) + .catch(() => {}) + } + }, [available, setPublisedAt]) + if (available) { const releaseNotesHtml = () => { return { __html: releaseNotes } @@ -72,7 +83,7 @@ const UpdateDownloadStatus = ({ >

- {newVersion} {releaseDate ? `(${uniformTimeFormatter(new Date(releaseDate)).split(' ')[0]})` : null} + {newVersion} {publisedAt ? `(${uniformTimeFormatter(new Date(publisedAt)).split(' ')[0]})` : null}

@@ -217,7 +228,6 @@ const GeneralSetting = ({ updater }: GeneralSettingProps) => { progress={updater.downloadProgress} progressInfo={updater.progressInfo} newVersion={updater.version} - releaseDate={updater.releaseDate} releaseNotes={updater.releaseNotes} /> diff --git a/packages/neuron-wallet/src/controllers/update.ts b/packages/neuron-wallet/src/controllers/update.ts index 72b68cf695..2be6ea3c71 100644 --- a/packages/neuron-wallet/src/controllers/update.ts +++ b/packages/neuron-wallet/src/controllers/update.ts @@ -1,5 +1,4 @@ import { autoUpdater, UpdateInfo, CancellationToken, ProgressInfo } from 'electron-updater' -import { net } from 'electron' import AppUpdaterSubject, { AppUpdater } from '../models/subjects/app-updater' import logger from '../utils/logger' @@ -77,25 +76,11 @@ export default class UpdateController { if (UpdateController.isChecking) { UpdateController.isChecking = false UpdateController.updatePackageSize = info.files[0].size ?? 0 - const request = net.request(`https://api.github.com/repos/nervosnetwork/neuron/releases/tags/v${info.version}`) - request.on('response', response => { - response.on('data', chunk => { - const res = JSON.parse(chunk.toString()) - this.notify({ - version: info.version, - releaseDate: res?.published_at || '', - releaseNotes: info.releaseNotes as string, - }) - }) + this.notify({ + version: info.version, + releaseDate: info.releaseDate, + releaseNotes: info.releaseNotes as string, }) - request.on('error', () => { - this.notify({ - version: info.version, - releaseDate: '', - releaseNotes: info.releaseNotes as string, - }) - }) - request.end() } }) From bf0d23428465a82be3b5966c82b19bdfa488fd9c Mon Sep 17 00:00:00 2001 From: devchenyan Date: Fri, 15 Dec 2023 20:44:09 +0800 Subject: [PATCH 9/9] fix --- .../neuron-ui/src/components/GeneralSetting/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/neuron-ui/src/components/GeneralSetting/index.tsx b/packages/neuron-ui/src/components/GeneralSetting/index.tsx index 877ead8315..7866c4eaaa 100644 --- a/packages/neuron-ui/src/components/GeneralSetting/index.tsx +++ b/packages/neuron-ui/src/components/GeneralSetting/index.tsx @@ -33,7 +33,7 @@ const UpdateDownloadStatus = ({ const [t] = useTranslation() const available = newVersion !== '' && progress < 0 const downloaded = progress >= 1 - const [publisedAt, setPublisedAt] = useState('') + const [publishedAt, setPublishedAt] = useState('') const handleConfirm = useCallback( (e: React.FormEvent) => { @@ -56,11 +56,11 @@ const UpdateDownloadStatus = ({ .then(async res => { // eslint-disable-next-line camelcase const { published_at } = await res.json() - setPublisedAt(published_at) + setPublishedAt(published_at) }) .catch(() => {}) } - }, [available, setPublisedAt]) + }, [available, setPublishedAt]) if (available) { const releaseNotesHtml = () => { @@ -83,7 +83,7 @@ const UpdateDownloadStatus = ({ >

- {newVersion} {publisedAt ? `(${uniformTimeFormatter(new Date(publisedAt)).split(' ')[0]})` : null} + {newVersion} {publishedAt ? `(${uniformTimeFormatter(new Date(publishedAt)).split(' ')[0]})` : null}