From 08f2948ea6768432e205dd0af6c5f7299c7edee5 Mon Sep 17 00:00:00 2001 From: devchenyan Date: Wed, 22 Nov 2023 21:46:26 +0800 Subject: [PATCH 01/68] fix: Issue of create mutisig address --- packages/neuron-ui/src/components/MultisigAddress/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/neuron-ui/src/components/MultisigAddress/index.tsx b/packages/neuron-ui/src/components/MultisigAddress/index.tsx index e8f61a250c..fdfd91c33a 100644 --- a/packages/neuron-ui/src/components/MultisigAddress/index.tsx +++ b/packages/neuron-ui/src/components/MultisigAddress/index.tsx @@ -7,7 +7,7 @@ import { useExitOnWalletChange, useGoBack, } from 'utils' -import { useState as useGlobalState, withProvider } from 'states' +import { useState as useGlobalState } from 'states' import MultisigAddressCreateDialog from 'components/MultisigAddressCreateDialog' import MultisigAddressInfo from 'components/MultisigAddressInfo' import SendFromMultisigDialog from 'components/SendFromMultisigDialog' @@ -387,4 +387,4 @@ const MultisigAddress = () => { MultisigAddress.displayName = 'MultisigAddress' -export default withProvider(MultisigAddress) +export default MultisigAddress From 6dc256395412fe64b967bd5704675bfecdff01cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E5=9B=BD=E5=AE=87?= <841185308@qq.com> Date: Fri, 24 Nov 2023 17:12:34 +0800 Subject: [PATCH 02/68] feat: Cell manage (#2859) * feat: Cell manage * fix: Fix bugs of issue 298(1, 2, 3, 4, 5, 6) * fix: Disable lock or unlock when all of the selected status is same. Others optimize 1. rename `type` to `Category` 2. delete `walletId` in the `getSudtTokenInfo` function. * fix: Add left join to add assetAccounts field. * fix: Show the tips for locked cells. * fix: Send max for consume appointed cells. * fix: Show claim in Customized Assets if the lock time is reached. * fix: Use filter option to get live and sent cell. * fix: fix conversation 1. Better name cellManagement. 2. Move transformer to CellLocalInfo entity. 3. Use `UpdateCellLocalInfo` to replace multi params. * fix: Fix test case * fix: Adapt Spore for cell management. * fix: Hide the balance when use consume cell --- .../AddressBook/addressBook.module.scss | 42 +- .../src/components/AddressBook/index.tsx | 37 +- .../CellManagement/cellManagement.module.scss | 238 ++++++++++ .../src/components/CellManagement/hooks.ts | 419 +++++++++++++++++ .../src/components/CellManagement/index.tsx | 431 ++++++++++++++++++ .../src/components/History/RowExtend.tsx | 38 +- .../components/History/history.module.scss | 39 -- .../historyDetailPage.module.scss | 9 - .../components/HistoryDetailPage/index.tsx | 12 +- .../src/components/NervosDAODetail/index.tsx | 22 +- .../src/components/Overview/index.tsx | 61 ++- .../components/Overview/overview.module.scss | 44 +- .../neuron-ui/src/components/Send/hooks.ts | 15 +- .../neuron-ui/src/components/Send/index.tsx | 57 ++- packages/neuron-ui/src/locales/en.json | 52 ++- packages/neuron-ui/src/locales/zh-tw.json | 52 ++- packages/neuron-ui/src/locales/zh.json | 52 ++- packages/neuron-ui/src/router.tsx | 11 + .../src/services/remote/cellManage.ts | 12 + .../neuron-ui/src/services/remote/index.ts | 1 + .../src/services/remote/remoteApiWrapper.ts | 5 + .../src/states/stateProvider/reducer.ts | 10 + packages/neuron-ui/src/styles/theme.scss | 1 - packages/neuron-ui/src/types/App/index.d.ts | 50 ++ .../neuron-ui/src/types/Controller/index.d.ts | 1 + .../src/utils/calculateUsedCapacity.ts | 12 + packages/neuron-ui/src/utils/enums.ts | 20 + packages/neuron-ui/src/utils/hooks/index.ts | 101 ++-- packages/neuron-ui/src/utils/index.ts | 2 + .../neuron-ui/src/utils/outPointTransform.ts | 11 + packages/neuron-ui/src/utils/parsers.ts | 25 +- .../widgets/Breadcrum/breadcrum.module.scss | 9 +- .../neuron-ui/src/widgets/Breadcrum/index.tsx | 9 +- .../src/widgets/Icons/CellManage.svg | 3 + .../neuron-ui/src/widgets/Icons/Consume.svg | 10 + packages/neuron-ui/src/widgets/Icons/Lock.svg | 3 + .../neuron-ui/src/widgets/Icons/LockCell.svg | 10 + .../neuron-ui/src/widgets/Icons/Unlock.svg | 10 + .../src/widgets/Icons/icon.module.scss | 6 + packages/neuron-ui/src/widgets/Icons/icon.tsx | 12 +- .../src/widgets/Pagination/index.tsx | 7 +- .../src/widgets/ShowOrEditDesc/index.tsx | 42 ++ .../ShowOrEditDesc/showOrEditDesc.module.scss | 38 ++ .../neuron-ui/src/widgets/Table/index.tsx | 57 ++- .../src/widgets/Tooltip/tooltip.module.scss | 10 +- packages/neuron-wallet/src/controllers/api.ts | 63 ++- .../src/controllers/asset-account.ts | 3 +- .../src/controllers/cell-management.ts | 84 ++++ .../neuron-wallet/src/controllers/sudt.ts | 4 +- .../neuron-wallet/src/controllers/wallets.ts | 8 +- .../chain/entities/cell-local-info.ts | 44 ++ .../1694228328076-CreateCellLocalInfo.ts | 14 + .../src/database/chain/ormconfig.ts | 4 + .../src/services/asset-account-service.ts | 27 +- .../src/services/cell-local-info.ts | 67 +++ packages/neuron-wallet/src/services/cells.ts | 237 +++++++--- .../src/services/sudt-token-info.ts | 53 +++ .../src/services/transaction-sender.ts | 20 +- .../src/services/tx/transaction-generator.ts | 12 +- .../src/services/tx/transaction-service.ts | 15 +- packages/neuron-wallet/src/utils/const.ts | 1 + .../tests/controllers/cell-management.test.ts | 174 +++++++ .../tests/controllers/sudt.test.ts | 14 +- .../services/asset-account-service.test.ts | 42 -- .../tests/services/cell-local-info.test.ts | 178 ++++++++ .../tests/services/cells.test.ts | 297 +++++++++++- .../tests/services/sudt-token-info.test.ts | 183 ++++++++ .../services/tx/transaction-sender.test.ts | 9 +- packages/neuron-wallet/tests/setup.ts | 15 + 69 files changed, 3241 insertions(+), 435 deletions(-) create mode 100644 packages/neuron-ui/src/components/CellManagement/cellManagement.module.scss create mode 100644 packages/neuron-ui/src/components/CellManagement/hooks.ts create mode 100644 packages/neuron-ui/src/components/CellManagement/index.tsx create mode 100644 packages/neuron-ui/src/services/remote/cellManage.ts create mode 100644 packages/neuron-ui/src/utils/calculateUsedCapacity.ts create mode 100644 packages/neuron-ui/src/utils/outPointTransform.ts create mode 100644 packages/neuron-ui/src/widgets/Icons/CellManage.svg create mode 100644 packages/neuron-ui/src/widgets/Icons/Consume.svg create mode 100644 packages/neuron-ui/src/widgets/Icons/Lock.svg create mode 100644 packages/neuron-ui/src/widgets/Icons/LockCell.svg create mode 100644 packages/neuron-ui/src/widgets/Icons/Unlock.svg create mode 100644 packages/neuron-ui/src/widgets/ShowOrEditDesc/index.tsx create mode 100644 packages/neuron-ui/src/widgets/ShowOrEditDesc/showOrEditDesc.module.scss create mode 100644 packages/neuron-wallet/src/controllers/cell-management.ts create mode 100644 packages/neuron-wallet/src/database/chain/entities/cell-local-info.ts create mode 100644 packages/neuron-wallet/src/database/chain/migrations/1694228328076-CreateCellLocalInfo.ts create mode 100644 packages/neuron-wallet/src/services/cell-local-info.ts create mode 100644 packages/neuron-wallet/src/services/sudt-token-info.ts create mode 100644 packages/neuron-wallet/tests/controllers/cell-management.test.ts create mode 100644 packages/neuron-wallet/tests/services/cell-local-info.test.ts create mode 100644 packages/neuron-wallet/tests/services/sudt-token-info.test.ts diff --git a/packages/neuron-ui/src/components/AddressBook/addressBook.module.scss b/packages/neuron-ui/src/components/AddressBook/addressBook.module.scss index c6f6a9d5d6..118ab0d4b2 100644 --- a/packages/neuron-ui/src/components/AddressBook/addressBook.module.scss +++ b/packages/neuron-ui/src/components/AddressBook/addressBook.module.scss @@ -132,6 +132,7 @@ height: 56px; line-height: 56px; min-width: 100px; + max-width: 200px; .descTips { @media screen and (max-width: 1400px) { transform: translateX(-70%) !important; @@ -165,47 +166,6 @@ transform: translateX(-40%) !important; } } - - .descTipRoot { - position: relative; - width: 208px; - .autoHeight { - width: 100%; - height: 100%; - position: absolute; - - & > svg { - position: absolute; - right: 0; - bottom: 8px; - } - } - .descInput { - border: none; - word-break: break-word; - resize: none; - width: 100%; - height: 100%; - line-height: 24px; - background-color: transparent; - color: var(--main-text-color); - caret-color: #000000; - pointer-events: none; - - @media (prefers-color-scheme: dark) { - caret-color: #fff; - } - } - & > .hidden { - word-break: break-word; - white-space: break-spaces; - visibility: hidden; - min-width: 100px; - min-height: 24px; - padding: 2px; - line-height: 24px; - } - } } @media screen and (max-width: 1330px) { diff --git a/packages/neuron-ui/src/components/AddressBook/index.tsx b/packages/neuron-ui/src/components/AddressBook/index.tsx index 02a9c597ba..5bcd15bd13 100644 --- a/packages/neuron-ui/src/components/AddressBook/index.tsx +++ b/packages/neuron-ui/src/components/AddressBook/index.tsx @@ -3,11 +3,12 @@ import { useTranslation } from 'react-i18next' import { useState as useGlobalState, useDispatch } from 'states' import Dialog from 'widgets/Dialog' import CopyZone from 'widgets/CopyZone' -import { Copy, Edit } from 'widgets/Icons/icon' +import { Copy } from 'widgets/Icons/icon' import Table, { TableProps, SortType } from 'widgets/Table' import { shannonToCKBFormatter, useLocalDescription } from 'utils' import { HIDE_BALANCE } from 'utils/const' import Tooltip from 'widgets/Tooltip' +import ShowOrEditDesc from 'widgets/ShowOrEditDesc' import styles from './addressBook.module.scss' enum TabIdx { @@ -42,8 +43,7 @@ const AddressBook = ({ onClose }: { onClose?: () => void }) => { }, [tabIdx, addresses]) const dispatch = useDispatch() - const { localDescription, onDescriptionPress, onDescriptionChange, onDescriptionFieldBlur, onDescriptionSelected } = - useLocalDescription('address', walletId, dispatch, 'textarea') + const { onChangeEditStatus, onSubmitDescription } = useLocalDescription('address', walletId, dispatch) const columns = useMemo['columns']>( () => [ @@ -87,32 +87,15 @@ const AddressBook = ({ onClose }: { onClose?: () => void }) => { dataIndex: 'description', align: 'center', render(description: string, _idx, item) { - const isSelected = localDescription.key === item.address return ( -
-