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 committed by Alex Jbanca
parent d9a78da1d3
commit 03df126955
1 changed files with 3 additions and 1 deletions

View File

@ -61,13 +61,15 @@ SQUtils.QObject {
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();
})
if (!validAccount) {
console.warn("SessionRequestResolver - resolveEvent - invalid account", request.account)
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 }
} catch (e) {