Skip to content

Commit d649a36

Browse files
committed
Merge remote-tracking branch 'tom/wc-unspecified-account'
2 parents 034a351 + 4956846 commit d649a36

File tree

5 files changed

+27
-15
lines changed

5 files changed

+27
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
- Fix BitBoxApp crash on GrapheneOS and other phones without Google Play Services when scanning QR codes.
1010
- Add DMG installer for macOS
1111
- Use mempool.space as preferred fee estimation source for BTC
12+
- Fix Wallet Connect issue where account unspecified by the connecting dapp caused a UI crash
13+
- Fix Wallet Connect issue with required/optionalNamespace and handling all possible namespace definitions
1214

1315
## 4.42.0
1416
- Preselect backup when there's only one backup available

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,13 +1753,15 @@
17531753
"connect": {
17541754
"button": "Connect",
17551755
"dappLabel": "Enter URI address of dapp",
1756-
"invalidPairingUri": "Invalid pairing uri"
1756+
"invalidPairingUri": "Invalid pairing uri",
1757+
"missingNamespace": "Connecting app request did not define necessary namespace"
17571758
},
17581759
"dashboard": {
17591760
"allSessions": "All sessions",
17601761
"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.",
17611762
"newConnection": "New connection",
1762-
"noConnectedSessions": "No accounts are currently connected to any dapps."
1763+
"noConnectedSessions": "No accounts are currently connected to any dapps.",
1764+
"unspecifiedAccount": "Unspecified account"
17631765
},
17641766
"invalidPairingChain": "Error in approving pairing. Please make sure to use one of the supported chains: {{chains}}",
17651767
"pairingRequest": {

frontends/web/src/routes/account/walletconnect/components/incoming-pairing/incoming-pairing.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,18 @@ export const WCIncomingPairing = ({
6161
setPairingLoading(true);
6262
try {
6363
const { id, params } = currentProposal;
64-
const { requiredNamespaces } = params;
65-
const eipList = Object.values(requiredNamespaces);
64+
const { requiredNamespaces, optionalNamespaces } = params;
65+
const eipList = Object.keys(requiredNamespaces).length !== 0 ? Object.values(requiredNamespaces) : Object.values(optionalNamespaces);
66+
if (!eipList) {
67+
alertUser(`${t('walletConnect.connect.missingNamespace')}`);
68+
await handleRejectPairing();
69+
setPairingLoading(false);
70+
return;
71+
}
6672
const accounts = eipList.flatMap(eip => eip.chains?.map(chain => `${chain}:${receiveAddress}`) || []);
67-
// For supported chains, use an intersection of supported chains and required chains
73+
// For supported chains, use an intersection of supported chains and required chains, default to mainnet if no chains present
6874
const chains: string[] = eipList.flatMap(proposal =>
69-
proposal.chains ? proposal.chains.filter(chain => Object.keys(SUPPORTED_CHAINS).includes(chain)) : []
75+
proposal.chains ? proposal.chains.filter(chain => Object.keys(SUPPORTED_CHAINS).includes(chain)) : ['eip155:1']
7076
);
7177

7278
// buildApprovedNamespaces is a

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)