diff --git a/packages/kit-bg/src/services/ServiceToken.ts b/packages/kit-bg/src/services/ServiceToken.ts index ab4fee4b18e..74540a867c7 100644 --- a/packages/kit-bg/src/services/ServiceToken.ts +++ b/packages/kit-bg/src/services/ServiceToken.ts @@ -195,7 +195,7 @@ class ServiceToken extends ServiceBase { } resp.data.data.tokens.data = resp.data.data.tokens.data.map((token) => ({ - ...this.mergeTokenMetadataWithCustomData({ + ...this.mergeTokenMetadataWithCustomDataSync({ token, customTokens, networkId, @@ -207,7 +207,7 @@ class ServiceToken extends ServiceBase { resp.data.data.riskTokens.data = resp.data.data.riskTokens.data.map( (token) => ({ - ...this.mergeTokenMetadataWithCustomData({ + ...this.mergeTokenMetadataWithCustomDataSync({ token, customTokens, networkId, @@ -220,7 +220,7 @@ class ServiceToken extends ServiceBase { resp.data.data.smallBalanceTokens.data = resp.data.data.smallBalanceTokens.data.map((token) => ({ - ...this.mergeTokenMetadataWithCustomData({ + ...this.mergeTokenMetadataWithCustomDataSync({ token, customTokens, networkId, @@ -287,7 +287,16 @@ class ServiceToken extends ServiceBase { return resp.data.data; } - private mergeTokenMetadataWithCustomData({ + @backgroundMethod() + async mergeTokenMetadataWithCustomData(params: { + token: T; + customTokens: IAccountToken[]; + networkId: string; + }): Promise { + return Promise.resolve(this.mergeTokenMetadataWithCustomDataSync(params)); + } + + private mergeTokenMetadataWithCustomDataSync({ token, customTokens, networkId, @@ -521,7 +530,7 @@ class ServiceToken extends ServiceBase { networkId, }); - tokenInfo = this.mergeTokenMetadataWithCustomData({ + tokenInfo = this.mergeTokenMetadataWithCustomDataSync({ token: tokenInfo, customTokens, networkId, diff --git a/packages/kit/src/components/Hardware/Hardware.tsx b/packages/kit/src/components/Hardware/Hardware.tsx index 7e1ac3a927f..c700183b223 100644 --- a/packages/kit/src/components/Hardware/Hardware.tsx +++ b/packages/kit/src/components/Hardware/Hardware.tsx @@ -21,6 +21,7 @@ import { useMedia, } from '@onekeyhq/components'; import { ETranslations } from '@onekeyhq/shared/src/locale'; +import platformEnv from '@onekeyhq/shared/src/platformEnv'; import { SHOW_CLOSE_ACTION_MIN_DURATION } from '../../provider/Container/HardwareUiStateContainer/constants'; import { isPassphraseValid } from '../../utils/passphraseUtils'; @@ -349,6 +350,42 @@ export function EnterPhase({ const [secureEntry1, setSecureEntry1] = useState(true); const [secureEntry2, setSecureEntry2] = useState(true); + const handleSubmit = form.handleSubmit(async () => { + const values = form.getValues(); + if ( + !isSingleInput && + (values.passphrase || '') !== (values.confirmPassphrase || '') + ) { + Toast.error({ + title: intl.formatMessage({ + id: ETranslations.feedback_passphrase_not_matched, + }), + }); + return; + } + const passphrase = values.passphrase || ''; + onConfirm({ passphrase, save: true }); + }); + + const handleKeyPress = useCallback( + async (event: KeyboardEvent) => { + if (event.key === 'Enter') { + void handleSubmit(); + } + }, + [handleSubmit], + ); + + useEffect(() => { + if (platformEnv.isRuntimeBrowser && typeof document !== 'undefined') { + document.addEventListener('keypress', handleKeyPress); + return () => { + document.removeEventListener('keypress', handleKeyPress); + }; + } + return undefined; + }, [handleKeyPress]); + return ( @@ -443,41 +480,7 @@ export function EnterPhase({ } as any } variant="primary" - onPress={form.handleSubmit(async () => { - const values = form.getValues(); - if ( - !isSingleInput && - (values.passphrase || '') !== (values.confirmPassphrase || '') - ) { - Toast.error({ - title: intl.formatMessage({ - id: ETranslations.feedback_passphrase_not_matched, - }), - }); - return; - } - // allow empty passphrase - const passphrase = values.passphrase || ''; - onConfirm({ passphrase, save: true }); - - // Dialog.show({ - // icon: 'CheckboxSolid', - // title: 'Keep Your Wallet Accessible?', - // description: - // 'Save this wallet to your device to maintain access after the app is closed. Unsaved wallets will be removed automatically.', - // onConfirm: () => { - // onConfirm({ passphrase: values.passphrase, save: true }); - // }, - // onConfirmText: 'Save Wallet', - // confirmButtonProps: { - // variant: 'secondary', - // }, - // onCancel: () => { - // onConfirm({ passphrase: values.passphrase, save: false }); - // }, - // onCancelText: "Don't Save", - // }); - })} + onPress={handleSubmit} > {intl.formatMessage({ id: ETranslations.global_confirm })} diff --git a/packages/kit/src/views/AssetList/hooks/useTokenManagement.ts b/packages/kit/src/views/AssetList/hooks/useTokenManagement.ts index 7673c8af43d..97dde1d20ee 100644 --- a/packages/kit/src/views/AssetList/hooks/useTokenManagement.ts +++ b/packages/kit/src/views/AssetList/hooks/useTokenManagement.ts @@ -39,7 +39,15 @@ export function useTokenManagement({ allNetworkAccountId: isAllNetwork ? accountId : undefined, }), ]); - const allTokens = [...tokenList.tokens, ...customTokens]; + const allTokens = await Promise.all( + [...tokenList.tokens, ...customTokens].map((token) => + backgroundApiProxy.serviceToken.mergeTokenMetadataWithCustomData({ + token, + customTokens, + networkId, + }), + ), + ); const uniqueTokens = allTokens.filter( (token, index, self) => index === diff --git a/packages/kit/src/views/Discovery/pages/SearchModal/index.tsx b/packages/kit/src/views/Discovery/pages/SearchModal/index.tsx index 46d33372e57..09411cb685d 100644 --- a/packages/kit/src/views/Discovery/pages/SearchModal/index.tsx +++ b/packages/kit/src/views/Discovery/pages/SearchModal/index.tsx @@ -101,10 +101,7 @@ function SearchModal() { setSearchList([]); return; } - const logo = - await backgroundApiProxy.serviceDiscovery.buildWebsiteIconUrl( - 'https://google.com', - ); + const logo = 'https://uni.onekey-asset.com/static/logo/google.png'; setSearchList([ { dappId: SEARCH_ITEM_ID,