fix(dapps) bad error from status-go api for WalletConnect
Also don't allow undefined values to be passed by addresses. I found and intermittent issue of not having any account selected. I could not reproduce it anymore but the logs showed reporting `undefined` values for addresses. Tracing back the code path I found a potential error if the lookup of addresses failed and don't allow injecting `undefined`. Updates: #15884, #15815
This commit is contained in:
parent
e189246bca
commit
d2fa9c3a95
|
@ -57,8 +57,7 @@ proc getActiveSessions*(validAtTimestamp: int): JsonNode =
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
let jsonResultStr = rpcRes.result.getStr()
|
let jsonResultStr = rpcRes.result.getStr()
|
||||||
if jsonResultStr == "null":
|
if jsonResultStr == "null" or jsonResultStr == "":
|
||||||
# nil means error
|
|
||||||
return newJArray()
|
return newJArray()
|
||||||
|
|
||||||
if rpcRes.result.kind != JArray:
|
if rpcRes.result.kind != JArray:
|
||||||
|
|
|
@ -48,14 +48,18 @@ function buildSupportedNamespacesFromModels(chainsModel, accountsModel, methods)
|
||||||
}
|
}
|
||||||
for (let i = 0; i < accountsModel.count; i++) {
|
for (let i = 0; i < accountsModel.count; i++) {
|
||||||
let entry = SQUtils.ModelUtils.get(accountsModel, 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)
|
addresses.push(entry.address)
|
||||||
}
|
}
|
||||||
return buildSupportedNamespaces(chainIds, addresses, methods)
|
return buildSupportedNamespaces(chainIds, addresses, methods)
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildSupportedNamespaces(chainIds, addresses, methods) {
|
function buildSupportedNamespaces(chainIds, addresses, methods) {
|
||||||
var eipChainIds = []
|
let eipChainIds = []
|
||||||
var eipAddresses = []
|
let eipAddresses = []
|
||||||
for (let i = 0; i < chainIds.length; i++) {
|
for (let i = 0; i < chainIds.length; i++) {
|
||||||
let chainId = chainIds[i]
|
let chainId = chainIds[i]
|
||||||
eipChainIds.push(`"eip155:${chainId}"`)
|
eipChainIds.push(`"eip155:${chainId}"`)
|
||||||
|
@ -65,7 +69,13 @@ function buildSupportedNamespaces(chainIds, addresses, methods) {
|
||||||
}
|
}
|
||||||
let methodsStr = methods.map(method => `"${method}"`).join(',')
|
let methodsStr = methods.map(method => `"${method}"`).join(',')
|
||||||
return `{
|
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) {
|
function validURI(uri) {
|
||||||
|
|
Loading…
Reference in New Issue