From cf2b30198597ac98352dcef3b8339a3a6d6d33ce Mon Sep 17 00:00:00 2001 From: Hodor Date: Thu, 9 Jan 2025 10:23:57 +0800 Subject: [PATCH] chore: fix some ui bugs --- _raw/locales/en/messages.json | 7 ++++++- package.json | 2 +- .../controller/provider/internalMethod.ts | 8 ++++++++ .../Approval/components/Connect/SelectWallet.tsx | 11 +++++++---- .../views/Approval/components/Connect/index.tsx | 4 ++-- .../components/CurrentConnection/index.tsx | 3 +++ src/ui/views/MetamaskModeDapps/index.tsx | 2 +- src/utils/message/broadcastChannelMessage.ts | 16 ++++++++++++++-- yarn.lock | 8 ++++---- 9 files changed, 46 insertions(+), 15 deletions(-) diff --git a/_raw/locales/en/messages.json b/_raw/locales/en/messages.json index 88d44cc1bbd..1645cc68c94 100644 --- a/_raw/locales/en/messages.json +++ b/_raw/locales/en/messages.json @@ -1841,7 +1841,12 @@ "SignTestnetPermission": { "title": "Signing permission" }, - "ignoreAll": "Ignore all" + "ignoreAll": "Ignore all", + "otherWalletBtn": "Connect with Another Wallet", + "SelectWallet": { + "title": "Select a Wallet to Connect", + "desc": "Choose from the wallets you have installed" + } }, "addressDetail": { "add-to-whitelist": "Add to Whitelist", diff --git a/package.json b/package.json index bd95ff5f3c5..29341ec3a0b 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "@rabby-wallet/eth-walletconnect-keyring": "2.1.5", "@rabby-wallet/eth-watch-keyring": "1.0.0", "@rabby-wallet/gnosis-sdk": "1.3.10", - "@rabby-wallet/page-provider": "0.4.3-alpha.1", + "@rabby-wallet/page-provider": "0.4.3-alpha.2", "@rabby-wallet/rabby-action": "0.1.8", "@rabby-wallet/rabby-api": "0.9.9", "@rabby-wallet/rabby-security-engine": "2.0.7", diff --git a/src/background/controller/provider/internalMethod.ts b/src/background/controller/provider/internalMethod.ts index 2bd06fb8e9e..11c055b191c 100644 --- a/src/background/controller/provider/internalMethod.ts +++ b/src/background/controller/provider/internalMethod.ts @@ -93,6 +93,13 @@ const getProvider = ({ origin }: { origin: string }) => { return permissionService.getSite(origin)?.rdns; }; +const resetProvider = ({ origin }: { origin: string }) => { + const site = permissionService.getSite(origin); + if (site) { + permissionService.setSite({ ...site, rdns: undefined }); + } +}; + export default { tabCheckin, getProviderState, @@ -100,4 +107,5 @@ export default { hasOtherProvider, isDefaultWallet, 'rabby:getProvider': getProvider, + 'rabby:resetProvider': resetProvider, }; diff --git a/src/ui/views/Approval/components/Connect/SelectWallet.tsx b/src/ui/views/Approval/components/Connect/SelectWallet.tsx index 41349fe01cc..560ca796b13 100644 --- a/src/ui/views/Approval/components/Connect/SelectWallet.tsx +++ b/src/ui/views/Approval/components/Connect/SelectWallet.tsx @@ -1,5 +1,6 @@ import clsx from 'clsx'; import React from 'react'; +import { useTranslation } from 'react-i18next'; import { ReactComponent as RcIconBack } from 'ui/assets/icon-back-cc.svg'; export interface EIP6963ProviderInfo { @@ -19,6 +20,7 @@ export const SelectWallet: React.FC = ({ providers, onSelect, }) => { + const { t } = useTranslation(); return (
@@ -27,10 +29,10 @@ export const SelectWallet: React.FC = ({

- Select a Wallet to Connect + {t('page.connect.SelectWallet.title')}

- Choose from the wallets you have installed + {t('page.connect.SelectWallet.desc')}

@@ -41,8 +43,9 @@ export const SelectWallet: React.FC = ({ key={item.uuid} className={clsx( 'p-[20px] w-[172px] h-[100px] cursor-pointer', - 'bg-r-neutral-card-2 rounded-[8px]', - 'flex flex-col items-center justify-center' + 'bg-r-neutral-card-2 rounded-[8px] border-[1px] border-transparent', + 'flex flex-col items-center justify-center', + 'hover:bg-r-blue-light1 hover:border-rabby-blue-default' )} onClick={() => { onSelect?.(item); diff --git a/src/ui/views/Approval/components/Connect/index.tsx b/src/ui/views/Approval/components/Connect/index.tsx index 38034449f7d..516c012ef2d 100644 --- a/src/ui/views/Approval/components/Connect/index.tsx +++ b/src/ui/views/Approval/components/Connect/index.tsx @@ -776,13 +776,13 @@ const Connect = (props: ConnectProps) => {
{ setIsShowSelectWallet(true); }} > - Connect with Another Wallet + {t('page.connect.otherWalletBtn')}
) : null} diff --git a/src/ui/views/Dashboard/components/CurrentConnection/index.tsx b/src/ui/views/Dashboard/components/CurrentConnection/index.tsx index 82388ddd53a..2eba5b5dd3e 100644 --- a/src/ui/views/Dashboard/components/CurrentConnection/index.tsx +++ b/src/ui/views/Dashboard/components/CurrentConnection/index.tsx @@ -116,6 +116,9 @@ export const CurrentConnection = memo((props: CurrentConnectionProps) => { placement="top" overlayClassName={clsx('rectangle max-w-[225px]')} visible={isShowTooltip} + align={{ + offset: [0, 4], + }} title={ {
{t('page.metamaskModeDapps.desc')} diff --git a/src/utils/message/broadcastChannelMessage.ts b/src/utils/message/broadcastChannelMessage.ts index 19e5b8db594..d3bb24605c3 100644 --- a/src/utils/message/broadcastChannelMessage.ts +++ b/src/utils/message/broadcastChannelMessage.ts @@ -17,7 +17,13 @@ export default class BroadcastChannelMessage extends Message { } connect = () => { - this._channel.on('data', ({ data: { type, data } }) => { + this._channel.on('data', (res) => { + if (!res.data) { + return; + } + const { + data: { type, data }, + } = res; if (type === 'message') { this.emit('message', data); } else if (type === 'response') { @@ -31,7 +37,13 @@ export default class BroadcastChannelMessage extends Message { listen = (listenCallback) => { this.listenCallback = listenCallback; - this._channel.on('data', ({ data: { type, data } }) => { + this._channel.on('data', (res) => { + if (!res.data) { + return; + } + const { + data: { type, data }, + } = res; if (type === 'request') { this.onRequest(data); } diff --git a/yarn.lock b/yarn.lock index a231ee25b8a..3d2a2ace922 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4851,10 +4851,10 @@ typescript "^4.4.4" web3-core "^1.6.0" -"@rabby-wallet/page-provider@0.4.3-alpha.1": - version "0.4.3-alpha.1" - resolved "https://registry.yarnpkg.com/@rabby-wallet/page-provider/-/page-provider-0.4.3-alpha.1.tgz#68f4313c7c5b3f49f286d2e4708eab3e36185ac2" - integrity sha512-oLO2ar8hAayW2eG9nvsvtT/n776sR+TlzzuuAa6vgje7Kr47qVFW/edFuMm4i56r/fPi0R27Fh6CPK0QlBNjMg== +"@rabby-wallet/page-provider@0.4.3-alpha.2": + version "0.4.3-alpha.2" + resolved "https://registry.yarnpkg.com/@rabby-wallet/page-provider/-/page-provider-0.4.3-alpha.2.tgz#63eb19b6b12a8184bd79ccd8dbda6769b7da9516" + integrity sha512-7d1Hvuba0JNySF6eIDau/2iCllAld1rNBCbBRTUeKXNmNjNLpVsa2qX1WcCFnyWT09Y5oiMPL+DgswIrTqWrlA== dependencies: "@ledgerhq/devices" "^6.27.1" "@metamask/post-message-stream" "8.1.0"