From ea6b9a727c1e90f13b8bef2a03601992c2f9f964 Mon Sep 17 00:00:00 2001 From: devchenyan Date: Sat, 4 Jan 2025 21:59:45 +0800 Subject: [PATCH] fix: comment --- .../components/Receive/receive.module.scss | 1 - .../src/components/ViewPrivateKey/index.tsx | 32 +++++++++---------- .../tests/services/address.test.ts | 4 ++- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/packages/neuron-ui/src/components/Receive/receive.module.scss b/packages/neuron-ui/src/components/Receive/receive.module.scss index 0f9587a1e..cf85d6b6a 100644 --- a/packages/neuron-ui/src/components/Receive/receive.module.scss +++ b/packages/neuron-ui/src/components/Receive/receive.module.scss @@ -136,7 +136,6 @@ border: none; background: none; font-size: 12px; - font-family: PingFang SC; font-style: normal; font-weight: 500; color: var(--primary-color); diff --git a/packages/neuron-ui/src/components/ViewPrivateKey/index.tsx b/packages/neuron-ui/src/components/ViewPrivateKey/index.tsx index b076b8dd1..d1d63d5e1 100644 --- a/packages/neuron-ui/src/components/ViewPrivateKey/index.tsx +++ b/packages/neuron-ui/src/components/ViewPrivateKey/index.tsx @@ -35,7 +35,7 @@ const ViewPrivateKey = ({ onClose, address }: { onClose?: () => void; address?: ) const onSubmit = useCallback( - async (e?: React.FormEvent) => { + (e?: React.FormEvent) => { if (e) { e.preventDefault() } @@ -43,23 +43,21 @@ const ViewPrivateKey = ({ onClose, address }: { onClose?: () => void; address?: return } setIsLoading(true) - try { - const res = await getPrivateKeyByAddress({ - walletID, - address, - password, + getPrivateKeyByAddress({ + walletID, + address, + password, + }) + .then(res => { + if (!isSuccessResponse(res)) { + setError(errorFormatter(res.message, t)) + return + } + setPrivateKey(res.result) + }) + .finally(() => { + setIsLoading(false) }) - - setIsLoading(false) - - if (!isSuccessResponse(res)) { - setError(errorFormatter(res.message, t)) - return - } - setPrivateKey(res.result) - } catch (err) { - setIsLoading(false) - } }, [walletID, password, setError, t] ) diff --git a/packages/neuron-wallet/tests/services/address.test.ts b/packages/neuron-wallet/tests/services/address.test.ts index b546176a5..5720bccc6 100644 --- a/packages/neuron-wallet/tests/services/address.test.ts +++ b/packages/neuron-wallet/tests/services/address.test.ts @@ -748,7 +748,9 @@ describe('integration tests for AddressService', () => { const addresses = await wallet.checkAndGenerateAddresses(false, 5, 5) if (addresses) { - const obj = addresses[Math.floor(Math.random() * addresses.length)] + const crypto = require('crypto') + const randomIndex = crypto.randomInt(addresses.length) + const obj = addresses[randomIndex] address = obj.address }