Skip to content
This repository was archived by the owner on Dec 3, 2025. It is now read-only.

Commit ac1b40f

Browse files
authored
chore: forward notify message to notify notification (#110)
* chore: forward notify message to notify notification * chore: fix typo * test: update unit test to reflect changes * chore: run prettier * chore: bump version
1 parent 86c04ed commit ac1b40f

5 files changed

Lines changed: 23 additions & 2 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/notify-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@walletconnect/notify-client",
33
"description": "WalletConnect Notify Client",
4-
"version": "1.1.3",
4+
"version": "1.1.4",
55
"author": "WalletConnect, Inc. <walletconnect.com>",
66
"homepage": "https://github.com/walletconnect/notify-client-js/",
77
"license": "Apache-2.0",

packages/notify-client/src/controllers/engine.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,11 @@ export class NotifyEngine extends INotifyEngine {
903903
topic,
904904
params: { message: messageClaims.msg },
905905
});
906+
this.client.emit("notify_notification", {
907+
id: payload.id,
908+
topic,
909+
params: { notification: messageClaims.msg },
910+
});
906911
};
907912

908913
protected onNotifyMessageResponse: INotifyEngine["onNotifyMessageResponse"] =

packages/notify-client/src/types/client.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export declare namespace NotifyClientTypes {
1717
type Event =
1818
| "notify_subscription"
1919
| "notify_message"
20+
| "notify_notification"
2021
| "notify_delete"
2122
| "notify_update"
2223
| "notify_subscriptions_changed";
@@ -34,6 +35,10 @@ export declare namespace NotifyClientTypes {
3435
message: NotifyClientTypes.NotifyNotification;
3536
};
3637

38+
type NotifyNotificationRequestEventArgs = {
39+
notification: NotifyClientTypes.NotifyNotification;
40+
};
41+
3742
type NotifyDeleteRequestEventArgs = { id: number; topic: string };
3843

3944
interface BaseEventArgs<T = unknown> {
@@ -49,6 +54,7 @@ export declare namespace NotifyClientTypes {
4954
}
5055
>;
5156
notify_message: BaseEventArgs<NotifyMessageRequestEventArgs>;
57+
notify_notification: BaseEventArgs<NotifyNotificationRequestEventArgs>;
5258
notify_delete: BaseEventArgs<NotifyResponseEventArgs>;
5359
notify_update: BaseEventArgs<
5460
NotifyResponseEventArgs & {

packages/notify-client/test/clients.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,29 @@ describe("Notify", () => {
261261
let gotNotifyMessageResponse = false;
262262
let notifyMessageEvent: any;
263263

264+
let gotNotifyNotificationResponse = false;
265+
let notifyNotificationEvent: any;
266+
264267
wallet.once("notify_message", (event) => {
265268
console.log("notify_message", event);
266269
gotNotifyMessageResponse = true;
267270
notifyMessageEvent = event;
268271
});
269272

273+
wallet.once("notify_notification", (event) => {
274+
gotNotifyNotificationResponse = true;
275+
notifyNotificationEvent = event;
276+
});
277+
270278
const sendResponse = await sendNotifyMessage(account, "Test");
271279

272280
expect(sendResponse.status).toBe(200);
273281

274282
await waitForEvent(() => gotNotifyMessageResponse);
283+
await waitForEvent(() => gotNotifyNotificationResponse);
275284

276285
expect(notifyMessageEvent.params.message.body).toBe("Test");
286+
expect(notifyNotificationEvent.params.notification.body).toBe("Test");
277287
});
278288

279289
it("reads the dapp's did.json from memory after the initial fetch", async () => {

0 commit comments

Comments
 (0)