fix(WalletConnect): Fix the parsed account in the session request

The account in the session request composed by the dApp can have a different case from what Status is using.
When resolving the session request the account address will be replaced with the one from the account model.
This commit is contained in:
Alex Jbanca 2024-11-12 16:40:50 +02:00
parent 00fb1ff60a
commit f60c3321ce
No known key found for this signature in database
GPG Key ID: 6004079575C21C5D
1 changed files with 3 additions and 1 deletions

View File

@ -61,13 +61,15 @@ SQUtils.QObject {
return { request: null, error: SessionRequest.InvalidChainId } return { request: null, error: SessionRequest.InvalidChainId }
} }
const validAccount = !!SQUtils.ModelUtils.getFirstModelEntryIf(accountsModel, (account) => { const validAccount = SQUtils.ModelUtils.getFirstModelEntryIf(accountsModel, (account) => {
return account.address.toLowerCase() === request.account.toLowerCase(); return account.address.toLowerCase() === request.account.toLowerCase();
}) })
if (!validAccount) { if (!validAccount) {
console.warn("SessionRequestResolver - resolveEvent - invalid account", request.account) console.warn("SessionRequestResolver - resolveEvent - invalid account", request.account)
return { request: null, error: SessionRequest.InvalidAccount } return { request: null, error: SessionRequest.InvalidAccount }
} }
// Override the account with the validated one to always match the case
request.account = validAccount.address
return { request, error: SessionRequest.NoError } return { request, error: SessionRequest.NoError }
} catch (e) { } catch (e) {