From b79ebb49955bf981b48c45b776328765b3d6fbbd Mon Sep 17 00:00:00 2001 From: chenyan Date: Sun, 30 Jul 2023 11:12:47 +0800 Subject: [PATCH] fix: 244 --- .../src/components/SUDTAccountList/index.tsx | 18 +++++++++++++++++- .../src/components/SUDTAccountPile/index.tsx | 19 ++++++++++++++++++- .../sUDTAccountPile.module.scss | 5 ++++- packages/neuron-ui/src/locales/en.json | 4 +++- packages/neuron-ui/src/locales/zh-tw.json | 4 +++- packages/neuron-ui/src/locales/zh.json | 4 +++- 6 files changed, 48 insertions(+), 6 deletions(-) diff --git a/packages/neuron-ui/src/components/SUDTAccountList/index.tsx b/packages/neuron-ui/src/components/SUDTAccountList/index.tsx index 21eaa18618..d8410e60af 100644 --- a/packages/neuron-ui/src/components/SUDTAccountList/index.tsx +++ b/packages/neuron-ui/src/components/SUDTAccountList/index.tsx @@ -13,6 +13,7 @@ import { ReactComponent as EyesClose } from 'widgets/Icons/EyesClose.svg' import { ReactComponent as Search } from 'widgets/Icons/SearchIcon.svg' import { ReactComponent as AddSimple } from 'widgets/Icons/AddSimple.svg' import SUDTReceiveDialog, { DataProps } from 'components/SUDTReceiveDialog' +import Toast from 'widgets/Toast' import TableNoData from 'widgets/Icons/TableNoData.png' import { useState as useGlobalState, useDispatch, AppActions, NeuronWalletActions } from 'states' @@ -52,6 +53,7 @@ const SUDTAccountList = () => { const isMainnet = isMainnetUtil(networks, networkID) const [receiveData, setReceiveData] = useState(null) const [showBalance, setShowBalance] = useState(true) + const [notice, setNotice] = useState('') const existingAccountNames = sUDTAccounts.filter(acc => acc.accountName).map(acc => acc.accountName || '') @@ -162,7 +164,7 @@ const SUDTAccountList = () => { setDialog(null) }, [setDialog]) - const handleCreateAccount = useOnGenerateNewAccountTransaction({ + const createAccount = useOnGenerateNewAccountTransaction({ walletId, dispatch, onGenerated: onTransactionGenerated, @@ -206,6 +208,7 @@ const SUDTAccountList = () => { if (isSuccessResponse(res)) { fetchAndUpdateList() setDialog(null) + setNotice(t('s-udt.edit-account-success')) return true } throw new Error(typeof res.message === 'string' ? res.message : res.message.content) @@ -222,6 +225,17 @@ const SUDTAccountList = () => { } : undefined + const handleCreateAccount = useCallback( + async (info: TokenInfo) => { + const isSuccess = await createAccount(info) + if (isSuccess) { + setNotice(t('s-udt.create-account-success')) + } + return isSuccess + }, + [createAccount, setNotice] + ) + return ( { isMainnet={isMainnet} /> ) : null} + + setNotice('')} /> ) diff --git a/packages/neuron-ui/src/components/SUDTAccountPile/index.tsx b/packages/neuron-ui/src/components/SUDTAccountPile/index.tsx index 09b45e845b..bcfed9ff8c 100644 --- a/packages/neuron-ui/src/components/SUDTAccountPile/index.tsx +++ b/packages/neuron-ui/src/components/SUDTAccountPile/index.tsx @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next' import SUDTAvatar from 'widgets/SUDTAvatar' import { HIDE_BALANCE, DEFAULT_SUDT_FIELDS } from 'utils/const' import { sudtValueToAmount } from 'utils/formatters' +import Tooltip from 'widgets/Tooltip' import { ReactComponent as Send } from 'widgets/Icons/SendStroke.svg' import { ReactComponent as Receive } from 'widgets/Icons/ReceiveStroke.svg' import { ReactComponent as ArrowOpenRight } from 'widgets/Icons/ArrowOpenRight.svg' @@ -35,6 +36,16 @@ const SUDTAccountPile = ({ const isCKB = DEFAULT_SUDT_FIELDS.CKBTokenId === tokenId const disabled = !isCKB && !decimal + const balanceText = sudtValueToAmount(balance, decimal) + let overBalanceText = '' + + if (Number(decimal) > 8) { + const [integer, radix] = balanceText.split('.') + if (radix && radix.length > 8) { + overBalanceText = `${integer}.${radix.slice(0, 8)}` + } + } + return (
@@ -50,7 +61,13 @@ const SUDTAccountPile = ({
- {showBalance ? sudtValueToAmount(balance, decimal) || '--' : HIDE_BALANCE} + {overBalanceText && showBalance ? ( + {balanceText}} showTriangle> + {overBalanceText}... + + ) : ( + {showBalance ? balanceText || '--' : HIDE_BALANCE} + )}
diff --git a/packages/neuron-ui/src/components/SUDTAccountPile/sUDTAccountPile.module.scss b/packages/neuron-ui/src/components/SUDTAccountPile/sUDTAccountPile.module.scss index 713d0379f3..cbb83d2b7f 100644 --- a/packages/neuron-ui/src/components/SUDTAccountPile/sUDTAccountPile.module.scss +++ b/packages/neuron-ui/src/components/SUDTAccountPile/sUDTAccountPile.module.scss @@ -30,9 +30,12 @@ @include text-overflow-ellipsis; } } + .tip { + margin-top: -8px; + margin-left: -20px; + } .balance { margin-top: 8px; - text-overflow: ellipsis; font-weight: 500; font-size: 16px; line-height: 22px; diff --git a/packages/neuron-ui/src/locales/en.json b/packages/neuron-ui/src/locales/en.json index 9450151e06..1fa61bd63e 100644 --- a/packages/neuron-ui/src/locales/en.json +++ b/packages/neuron-ui/src/locales/en.json @@ -604,7 +604,7 @@ "115": "You need more capacities for change (more than 61 CKBytes), or click 'Max' button to send all your balance.", "201": "$t(messages.fields.{{fieldName}}) is required.", "202": "$t(messages.fields.{{fieldName}}) is used.", - "203": "$t(messages.fields.{{fieldName}}) is too long, it should be shorter than or equal to {{length}}.", + "203": "$t(messages.fields.{{fieldName}}) should be shorter than or equal to {{length}}", "204": "$t(messages.fields.{{fieldName}}) is too short, it should be longer than or equal to {{length}}.", "205": "$t(messages.fields.{{fieldName}}) {{fieldValue}} is invalid.", "206": "$t(messages.fields.{{fieldName}}) is invalid, please enter the $t(messages.fields.{{fieldName}}) with no more than {{length}} decimal places.", @@ -918,6 +918,8 @@ "view-in-explorer": "Explorer" }, "s-udt": { + "edit-account-success": "Edit account information successfully", + "create-account-success": "Asset account created successfully", "account-list": { "title": "Asset Accounts", "no-asset-accounts": "No sUDT asset has been detected", diff --git a/packages/neuron-ui/src/locales/zh-tw.json b/packages/neuron-ui/src/locales/zh-tw.json index 4a437feb2e..1c32609714 100644 --- a/packages/neuron-ui/src/locales/zh-tw.json +++ b/packages/neuron-ui/src/locales/zh-tw.json @@ -597,7 +597,7 @@ "115": "您需要有足夠的餘額來支付找零(大于 61 CKBytes),或者點擊 'Max' 按鈕發送全部餘額。", "201": "缺少$t(messages.fields.{{fieldName}})。", "202": "$t(messages.fields.{{fieldName}}) {{fieldValue}} 已被使用。", - "203": "$t(messages.fields.{{fieldName}})太長,其長度應不超過 {{length}}。", + "203": "$t(messages.fields.{{fieldName}})長度最大不超過{{length}}字符", "204": "$t(messages.fields.{{fieldName}}) {{fieldValue}} 太短,其長度應不小於 {{length}}。", "205": "$t(messages.fields.{{fieldName}}) {{fieldValue}} 無效。", "206": "$t(messages.fields.{{fieldName}}) {{fieldValue}} 無效,其小數位應不超過 {{length}}比特。", @@ -889,6 +889,8 @@ "view-in-explorer": "瀏覽器" }, "s-udt": { + "edit-account-success": "編輯賬戶信息成功", + "create-account-success": "創建資產賬戶成功", "account-list": { "title": "資產賬戶", "no-asset-accounts": "尚未檢索到您持有的 sUDT 資產", diff --git a/packages/neuron-ui/src/locales/zh.json b/packages/neuron-ui/src/locales/zh.json index 2d00fcaf72..baa358f900 100644 --- a/packages/neuron-ui/src/locales/zh.json +++ b/packages/neuron-ui/src/locales/zh.json @@ -597,7 +597,7 @@ "115": "您需要有足够的余额来支付找零(大于 61 CKBytes),或者点击 'Max' 按钮发送全部余额。", "201": "缺少$t(messages.fields.{{fieldName}})。", "202": "$t(messages.fields.{{fieldName}}) {{fieldValue}} 已被使用。", - "203": "$t(messages.fields.{{fieldName}})太长, 其长度应不超过 {{length}}。", + "203": "$t(messages.fields.{{fieldName}})长度最大不超过{{length}}个字符", "204": "$t(messages.fields.{{fieldName}}) {{fieldValue}} 太短, 其长度应不小于 {{length}}。", "205": "$t(messages.fields.{{fieldName}}) {{fieldValue}} 无效。", "206": "$t(messages.fields.{{fieldName}}) {{fieldValue}} 无效, 其小数位应不超过 {{length}} 位。", @@ -911,6 +911,8 @@ "view-in-explorer": "浏览器" }, "s-udt": { + "edit-account-success": "编辑账户信息成功", + "create-account-success": "创建资产账户成功", "account-list": { "title": "资产账户", "no-asset-accounts": "尚未检索到您持有的 sUDT 资产",