-
Notifications
You must be signed in to change notification settings - Fork 735
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: decrypted notifications #3997
Conversation
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.
LGTM - left questions and nits. All non blocking
import { IEcho } from "@walletconnect/types"; | ||
import { ECHO_CONTEXT, ECHO_URL } from "../constants"; | ||
|
||
export class Echo extends IEcho { |
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.
nit: Why did we make an entire class for this? Couldn't we have just had a function defined somewhere to register the token? I feel like it's just extra complexity and more state to store needlessly
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.
the idea is to have dedicated handling allowing functionality to be reused and expanded as needed in the future
@@ -98,6 +98,11 @@ export class Engine extends IWeb3WalletEngine { | |||
return this.authClient.formatMessage(params, iss); | |||
}; | |||
|
|||
// Push // |
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.
// Push // | |
// ---------- Push -------------------------------------------------- // |
packages/core/src/core.ts
Outdated
@@ -77,6 +78,7 @@ export class Core extends ICore { | |||
}); | |||
this.pairing = new Pairing(this, this.logger); | |||
this.verify = new Verify(this.projectId || "", this.logger); | |||
this.echo = new Echo(this.projectId || "", this.logger); |
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.
Why are we putting this in core? Sign/Auth/Chat
won't make a use of this, no?
|
||
const echoUrl = `${ECHO_URL}/${this.projectId}/clients`; | ||
|
||
await fetch(echoUrl, { |
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.
Don't we need to use isomorphic-unfetch
or something here? Or is it already polyfilled
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'm actually kind of surprised this hasn't come up before here where there's already a fetch
call: https://github.com/WalletConnect/walletconnect-monorepo/blob/v2.0/packages/core/src/controllers/verify.ts#L103
Is the Verify
controller called only in browsers?
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.
🔥 🔥
|
||
const echoUrl = `${ECHO_URL}/${this.projectId}/clients`; | ||
|
||
await fetch(echoUrl, { |
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'm actually kind of surprised this hasn't come up before here where there's already a fetch
call: https://github.com/WalletConnect/walletconnect-monorepo/blob/v2.0/packages/core/src/controllers/verify.ts#L103
Is the Verify
controller called only in browsers?
|
||
export const Notifications: Web3WalletTypes.INotifications = { | ||
decryptMessage: async (params) => { | ||
const core = new Core({ |
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.
Bit concerned regarding memory and creating a new Core reference on every decryptMessage
call. Is there any way to avoid this and init the Core once? Guessing this may have to be stateless right.
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 don't think we have a way around this because our modules are not stateless/pure - crypto depends on core
and having a store AFAIK
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.
Good point 💯 I will thinker a solution as we do need to reinitialize to update the data
Description
This includes
Echo
controller inCore
that allows devices to be registered with Echo serverWeb3Wallet
callednotifications
that allows for decrypting push payloads & getting the peer's metadata without initializing the whole clientUsage
Registering device
core.echo.registerDeviceToken(params)
or shorthandweb3wallet.registerDeviceToken(params)
Decrypting notification payload
Type of change
How has this been tested?
tests
dogfooding
Checklist
Additional Information (Optional)
specs WalletConnect/walletconnect-specs#147