Skip to content

Commit 590e5f5

Browse files
committed
wallet-connect: fix ui crash when account unspecified by dapp
some dapps may not populate Wallet Connect's Session Namespaces with data about which account they are connecting to while this is not recommended behavior, it is up to the wallet software to handle (as per wallet connect namespace documentation) since the user can have multiple accounts in the bitbox app, we rely on the namespaces to show which one of these accounts the WC dapp session is connected to, however, the session should work even in absence of this information so we show "Unspecified account" instead when the dapp doesn't provide this session information
1 parent 034a351 commit 590e5f5

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

frontends/web/src/locales/en/app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,8 @@
17591759
"allSessions": "All sessions",
17601760
"disclaimer": "Walletconnect is a protocol to connect to Ethereum based Dapps. These dapps are run by third-party services, so only connect to dapps you trust and be sure to always know what you are signing when making a transaction.",
17611761
"newConnection": "New connection",
1762-
"noConnectedSessions": "No accounts are currently connected to any dapps."
1762+
"noConnectedSessions": "No accounts are currently connected to any dapps.",
1763+
"unspecifiedAccount": "Unspecified account"
17631764
},
17641765
"invalidPairingChain": "Error in approving pairing. Please make sure to use one of the supported chains: {{chains}}",
17651766
"pairingRequest": {

frontends/web/src/routes/account/walletconnect/components/session-card/session-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const WCSessionCard = ({ metadata, receiveAddress, onDisconnect }: TWCSes
6363
const { name, url, icons } = metadata;
6464
const accountDetail = useLoad(() => getEthAccountCodeAndNameByAddress(receiveAddress), []);
6565
const truncatedAddress = truncateAddress(receiveAddress);
66-
const accountName = accountDetail && accountDetail.success ? accountDetail.name : '';
66+
const accountName = accountDetail && accountDetail.success ? accountDetail.name : t('walletConnect.dashboard.unspecifiedAccount');
6767

6868
return (
6969
<div className={styles.container}>

frontends/web/src/routes/account/walletconnect/dashboard.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,16 @@ export const DashboardWalletConnect = ({ code, accounts }: TProps) => {
106106
{hasSession &&
107107
<div className={styles.sessionCardsContainer}>
108108
<p className={styles.allSessionsHeading}>{t('walletConnect.dashboard.allSessions')}</p>
109-
{sessions.map(session =>
110-
<WCSessionCard
111-
key={session.topic}
112-
receiveAddress={getAddressFromEIPString(session.namespaces['eip155'].accounts[0])}
113-
metadata={session.peer.metadata}
114-
onDisconnect={() => handleDisconnectSession(session.topic)}
115-
/>
116-
)}
109+
{sessions.map(session => {
110+
return (
111+
<WCSessionCard
112+
key={session.topic}
113+
receiveAddress={session.namespaces['eip155'].accounts[0] ? getAddressFromEIPString(session.namespaces['eip155'].accounts[0]) : ''}
114+
metadata={session.peer.metadata}
115+
onDisconnect={() => handleDisconnectSession(session.topic)}
116+
/>
117+
);
118+
})}
117119
</div>
118120
}
119121
{!hasSession &&

0 commit comments

Comments
 (0)