Skip to content

Commit 4956846

Browse files
committed
wallet-connect: fix "ChainId not found"
update namespace handling to conform to: https://docs.walletconnect.com/web3wallet/namespaces#case-no-1---recommended-default-for-all-apps Until now we were relying only on requiredNamespace to match the pairing request to the correct chain and account, however, for some reason, requiredNamespace is not actually required, can be empty and the necessary namespace details are instead defined in optionalNamespace
1 parent 590e5f5 commit 4956846

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,8 @@
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",

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

0 commit comments

Comments
 (0)