-
Notifications
You must be signed in to change notification settings - Fork 101
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
feat/264 - Handle third-party extension events #310
Conversation
c957acf
to
dbb6d62
Compare
dbb6d62
to
43fde59
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of minor comments, but code looks good to me and account switching works nicely 👍
packages/types/src/events.ts
Outdated
// Metamask extension window.ethereum events | ||
export enum MetamaskEvents { | ||
AccountChanged = "accountsChanged", | ||
NetworkChanged = "networkChanged", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see the networkChanged
event in the Metamask docs (although I did see it in a gist somewhere). Should this be chainChanged
?.
https://docs.metamask.io/wallet/reference/provider-api/#chainchanged
It doesn't look like it's used anyway so it could also be removed potentially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that was a typo on my part. As we're not really concerned with it, I'll just remove it! chainsChanged
would be appropriate, but yeah, not used at the moment.
} | ||
if (accounts) { | ||
dispatch(addAccounts(accounts)); | ||
dispatch(fetchBalances()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a question, but are these guaranteed to run one after the other i.e. is it possible balances will be fetched for the wrong account?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK in this case it will work because addAccounts is synchronous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, I see it now. I just assumed addAccounts
was also asynchronous. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested! Works nice!
} | ||
if (accounts) { | ||
dispatch(addAccounts(accounts)); | ||
dispatch(fetchBalances()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK in this case it will work because addAccounts is synchronous
f172f6b
to
bd35ab2
Compare
Resolves #264
Testing
Keplr
Metamask
TODO