Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wallet-connect: fix ui crash when account unspecified by dapp #2712

Merged
merged 2 commits into from
May 29, 2024

Conversation

Tomasvrba
Copy link
Contributor

@Tomasvrba Tomasvrba commented May 13, 2024

Closes #2689

@Tomasvrba
Copy link
Contributor Author

pls review @benma @thisconnect

@shonsirsha
Copy link
Collaborator

shonsirsha commented May 14, 2024

@Tomasvrba testing on https://highlight.xyz , I can't seem to connect my wallet to begin with (although BBApp says it's successful).
Screenshot 2024-05-14 at 09 12 43

chainId not found 🤔

@thisconnect
Copy link
Collaborator

requesting review from @shonsirsha as he has more experience with WC 😇

@Tomasvrba
Copy link
Contributor Author

@Tomasvrba testing on https://highlight.xyz , I can't seem to connect my wallet to begin with (although BBApp says it's successful). Screenshot 2024-05-14 at 09 12 43

chainId not found 🤔

are you on mainnet or testnet? highlight.xyz probably doesn't support testnet
make sure to use make servewallet-mainnet

@shonsirsha
Copy link
Collaborator

Hm yeah I'm on mainnet.

xsaasxsax

@Tomasvrba
Copy link
Contributor Author

Hm yeah I'm on mainnet.
xsaasxsax

yeah, getting the same now, strange, worked yesterday, not sure what's going on yet, the error messages from highlight are useless

@thisconnect
Copy link
Collaborator

seems like a different problem, could you add a 2nd commit to catch and some the error in the BBApp?

@Tomasvrba
Copy link
Contributor Author

seems like a different problem, could you add a 2nd commit to catch and some the error in the BBApp?

I'll look into it, should have time tomorrow

@Tomasvrba
Copy link
Contributor Author

Tomasvrba commented May 21, 2024

@thisconnect fixed in: 1aa589d

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 (don't ask me why, no idea), requiredNamespace is not actually required, can be empty and
the necessary namespace details are instead defined in optionalNamespace FML

tested with Blur.io, opensea.io and se-sdk-dapp.vercel.app (wallet connect integration test) and all work now
also tested with highlight.xyz and there's improvement, I can log in and sign the log in message, but get a 422 error "Unprocessable content" from their privy.io authentication provider, no clue at the moment what this is about, for anyone wanting to access highlight.xyz I would recommend to connect via Rabby instead

@thisconnect
Copy link
Collaborator

untested lgtm, I asked @shonsirsha to test 😇

I wonder if there could be any other WC related errors that are currently not shown to the users.. other than that looks good.

const chains: string[] = eipList.flatMap(proposal =>
proposal.chains ? proposal.chains.filter(chain => Object.keys(SUPPORTED_CHAINS).includes(chain)) : []
proposal.chains ? proposal.chains.filter(chain => Object.keys(SUPPORTED_CHAINS).includes(chain)) : ['eip155:1']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 looks good, maybe one day we need to define the chain id as a constant (e.g eip155:1 to be ETHEREUM_MAINNET) just for clarity. But fine for now as it's only used once this way here.

Copy link
Collaborator

@shonsirsha shonsirsha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Thanks for already testing on several platforms

Further tested on:

Copy link
Collaborator

@thisconnect thisconnect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks 👍

@Beerosagos
Copy link
Collaborator

Nice!! @Tomasvrba can you add a CHANGELOG entry for this? 😇

some dapps may not populate Wallet Connect's Session Namespaces with
data about which account they are connecting to
while this is not recommended behavior, it is up to the wallet software to
handle (as per wallet connect namespace documentation)
since the user can have multiple accounts in the bitbox app, we rely
on the namespaces to show which one of these accounts the WC dapp
session is connected to, however, the session should work even in
absence of this information so we show "Unspecified account" instead
when the dapp doesn't provide this session information
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
@Tomasvrba
Copy link
Contributor Author

Nice!! @Tomasvrba can you add a CHANGELOG entry for this? 😇

done and rebased

@thisconnect thisconnect merged commit d649a36 into BitBoxSwiss:master May 29, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.42.0 walletconnect action button causes ui to crash
4 participants