diff --git a/src/backend/wallet_connect.nim b/src/backend/wallet_connect.nim index 28414f9a26..d3863da3ba 100644 --- a/src/backend/wallet_connect.nim +++ b/src/backend/wallet_connect.nim @@ -57,8 +57,7 @@ proc getActiveSessions*(validAtTimestamp: int): JsonNode = return nil let jsonResultStr = rpcRes.result.getStr() - if jsonResultStr == "null": - # nil means error + if jsonResultStr == "null" or jsonResultStr == "": return newJArray() if rpcRes.result.kind != JArray: diff --git a/ui/app/AppLayouts/Wallet/services/dapps/helpers.js b/ui/app/AppLayouts/Wallet/services/dapps/helpers.js index 85b2fbc930..f0575518b4 100644 --- a/ui/app/AppLayouts/Wallet/services/dapps/helpers.js +++ b/ui/app/AppLayouts/Wallet/services/dapps/helpers.js @@ -48,14 +48,18 @@ function buildSupportedNamespacesFromModels(chainsModel, accountsModel, methods) } for (let i = 0; i < accountsModel.count; i++) { let entry = SQUtils.ModelUtils.get(accountsModel, i) + if (!entry || !entry.address) { + console.error("Invalid entry in accountsModel; skip reporting it", JSON.stringify(entry)) + continue + } addresses.push(entry.address) } return buildSupportedNamespaces(chainIds, addresses, methods) } function buildSupportedNamespaces(chainIds, addresses, methods) { - var eipChainIds = [] - var eipAddresses = [] + let eipChainIds = [] + let eipAddresses = [] for (let i = 0; i < chainIds.length; i++) { let chainId = chainIds[i] eipChainIds.push(`"eip155:${chainId}"`) @@ -65,7 +69,13 @@ function buildSupportedNamespaces(chainIds, addresses, methods) { } let methodsStr = methods.map(method => `"${method}"`).join(',') return `{ - "eip155":{"chains": [${eipChainIds.join(',')}],"methods": [${methodsStr}],"events": ["accountsChanged", "chainChanged"],"accounts": [${eipAddresses.join(',')}]}}` + "eip155": { + "chains": [${eipChainIds.join(',')}], + "methods": [${methodsStr}], + "events": ["accountsChanged", "chainChanged"], + "accounts": [${eipAddresses.join(',')}] + } + }` } function validURI(uri) {