-
Notifications
You must be signed in to change notification settings - Fork 194
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: send account switched messages to website #2504
Conversation
🚀 Thanks for the pull request! Here are the current build files for testing: Download and unzip the file for your browser. Refer to the readme for detailed install instructions. Don't forget: keep earning sats! |
best first also write a spec for window.nostr and window.webln |
Thanks for initiating this. With the possibility of having different Accounts in the extension, users have from time to time the wrong account selected without knowing it. |
@MoritzKa I think the only way to successfully propose it is to create a PR. If we already have a working implementation then the PR may be reviewed more closely so maybe it is best to wait for that? |
I have assigned @pavanjoshi914 to help updating this PR to use the new .on() method for window.webln and window.nostr |
to handle events in the best way we can use here is the use case:
the package provides a complete set of methods required to handle events under EventEmitter class such as removing listener, emitting events, etc other supported events: https://nodejs.org/dist/v11.13.0/docs/api/events.html#events_class_eventemitter same eventEmitters are used by metaMask as well |
2023-07-20.19-59-41.mp4website registering event
website remove the event, insure to pass same function to remove listener successfully
|
@pavanjoshi914 after this is merged and deployed, it would be great to do these follow up tasks:
|
@@ -109,6 +113,27 @@ export default class WebLNProvider { | |||
}); | |||
} | |||
|
|||
//webln events | |||
on(...args: Parameters<EventEmitter["on"]>) { |
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.
All this new code is duplicated in the two providers. I wonder if we can extend a common provider class or something. We could also move the common stuff like enabling and executing there.
I would do this as a follow up PR I guess.
signed-off-by: Pavan Joshi <>
signed-off-by: pavan joshi <pavanj914@gmail.com>
add explicit methods on, off and emit to be used in provider instead of extending whole class cleaning up correct nostr enable function problem which doesn't updates to latest value mechanism to catch and emit events fired webln.emit and nostr.emit signed-off-by: pavan joshi <pavanj914@gmail.com>
c70ae39
to
dde01a3
Compare
don't break application if webln is enabled, instead make events call always after enabling webln signed-off-by: pavan joshi <pavanj914@gmail.com>
Looks good to me. I cannot approve it as I originally made the PR. CC @bumi @reneaaron |
Describe the changes you have made in this PR
Send a message to the website when user switches account.
To listen to the event the website would add an event listener like:
Link this PR to an issue [optional]
Fixes #2503
Type of change
feat
: New feature (non-breaking change which adds functionality)Screenshots of the changes [optional]
Add screenshots to make your changes easier to understand. You can also add a video here.
How has this been tested?
Manually
Checklist